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

RE: [PBML] Search/Replace in File (Discuss)

Expand Messages
  • Paul Archer
    ... The vertical bar | is the alternation character in regular expressions. So your pattern of /|/ means match on nothing or nothing . You need to escape
    Message 1 of 2 , Mar 1, 2004
    • 0 Attachment
      10:30am, Fortuno, Adam wrote:

      > #! usr/bin/perl
      >
      > # The delimiter to use.
      > my($delim) = '|';
      >
      > # Break the file into an array, locate the specified line,
      > # and replace the specified value.
      > while (<>) {
      > chomp;
      > my(@line) = split(/$delim/);
      > $_[3] = 'un-read' if ("\L$_[0]" == "\Lread");
      > print (join($delim, @line));
      > }
      >
      > However, one problem I have is a I get really bizzar (to me) results. The
      > result of the line `my(@line) = split(/$delim/);` give me an array where
      > each element gets 1-char (e.g. 123|Name|Subject|Read|Receipt equals
      > 1|2|3|N|a|m|e|...). That certainly wasn't what I expected, and I'm not sure
      > why. Any ideas?
      >
      The vertical bar '|' is the alternation character in regular expressions. So
      your pattern of /|/ means match on 'nothing' or 'nothing'. You need to
      escape the bar (put a backslash in front of it) to tell Perl to treat it as
      a literal.

      Paul
    Your message has been successfully submitted and would be delivered to recipients shortly.