in reply to character class problem

First of all, "[no\nluck]" and '[no\nluck]' are not the samething. \n in double quotes is expanded to return, while in single quotes is set to character \ followed by character n.

Your regular expression 2a doesn't work because there is no character \ in the $VALID1 set.

Replies are listed 'Best First'.
Re: Re: character class problem
by smackdab (Pilgrim) on Oct 23, 2003 at 05:13 UTC
    I guess then I need to figure out how to get a line read from a file to be "no\nluck" instead of 'no\nluck' Do i have to convert every line after I read it or is there a better way?
      I am not sure what you are trying to achieve here. Do you want to read the entire file into a single string? If so, try the following:

      use IO::File; use strict; my $f = new IO::File "data", "r" or die "can not open file"; my $data; { local $/; $data = <$f>; } # at here, $data is your entire data file with embedded \n.