Loading ...
Sorry, an error occurred while loading the content.

[PBML] Parsing a config variable

Expand Messages
  • dalekh@hotmail.com
    I have a variable in a config file that I would like to parse and create a list from the space delimited values. Here is the format: elist = younme @work.com
    Message 1 of 2 , Jun 10, 1999
    • 0 Attachment
      I have a variable in a config file that I would like to parse and create a list from the space delimited values. Here is the format:

      elist = "younme\@... shenhim\@... itnher\@...";

      Is there a regexpr that can do the job to create the list.


      ------------------------------------------------------------------------

      eGroups.com home: http://www.egroups.com/group/perl-beginner
      http://www.egroups.com - Simplifying group communications
    • Jeff Boes
      ... A regexpr? Heck, you are using a cannon to kill a flea. $elist = younme @work.com shenhim @work.com itnher @work.com ; @elistList = split(/ s+/, $elist);
      Message 2 of 2 , Jun 10, 1999
      • 0 Attachment
        > -----Original Message-----
        > From: dalekh@... [mailto:dalekh@...]
        > Sent: Thursday, June 10, 1999 4:38 PM
        > To: perl-beginner@egroups.com
        > Subject: [PBML] Parsing a config variable
        >
        >
        >
        >
        > I have a variable in a config file that I would like to parse and
        > create a list from the space delimited values. Here is the format:
        >
        > elist = "younme\@... shenhim\@... itnher\@...";
        >
        > Is there a regexpr that can do the job to create the list.

        A regexpr? Heck, you are using a cannon to kill a flea.

        $elist = "younme\@... shenhim\@... itnher\@...";

        @elistList = split(/\s+/, $elist);

        split() breaks up the second argument into chunks separated by the pattern
        in the first argument. I could have used

        @elistList = split(/ /, $elist);

        but that doesn't handle well things like multiple spaces, tab, etc. The "\s+
        pattern matches one or more whitespace characters. Hope this helps!

        ----
        "Every law is an infraction of liberty."
        --Jeremy Bentham


        ------------------------------------------------------------------------

        eGroups.com home: http://www.egroups.com/group/perl-beginner
        http://www.egroups.com - Simplifying group communications
      Your message has been successfully submitted and would be delivered to recipients shortly.