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

RE: [PBML] Variable in split function

Expand Messages
  • Kipp, James
    ... You sure? it works fine here: $line = test:this:now ; $pattern = : ; @Arr = split(/$pattern/, $line); print $_ n for @Arr; prints: test this now
    Message 1 of 3 , Dec 31, 2002
    • 0 Attachment
      >
      > Hi all,
      > Can we use a variable in the /PATTERN/ argument of the split
      > function. I tried it but was not able
      > to get it to work. Is there something I am missing??
      >
      > $pattern = ":";
      > @Arr = split(/$pattern/, $Line);
      >
      > puts the whole $Line as the first element in the array
      > without splitting.
      >

      You sure? it works fine here:

      $line = "test:this:now";
      $pattern = ":";
      @Arr = split(/$pattern/, $line);
      print "$_\n" for @Arr;

      prints:
      test
      this
      now
    Your message has been successfully submitted and would be delivered to recipients shortly.