Flyghost has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to parse a file, loaded that file into an array and want to select lines in the array which have a certain nick as the first argument of that line. using @found = grep { /^$handle/ } @notes; for that. Seems to work fine except when the $handle has a ^ as first character. Anyway around this ?

Replies are listed 'Best First'.
Re: grep with perl characters
by btrott (Parson) on May 19, 2000 at 03:18 UTC
    Sounds like you want to quote metacharacters in your regular expression, so that they're not treated as meta:
    @found = grep { /^\Q$handle\E/ } @notes;
    The \Q and \E should do it for you. More in perlre.