in reply to Re^2: Regex in a printfile?
in thread Regex in a printfile?

huh, there's already a solution that doesn't use any modules in this thread.

But apply can be implemented using map pretty easily.

print OUTFILE map { my $s = $_; $s =~ s/\s*#.*/; $s } grep { !/^\s*#/ } <INFILE>;

You could even merge the map with the grep, but then it looks like spagetti.

Replies are listed 'Best First'.
Re^4: Regex in a printfile?
by Andrew_Levenson (Hermit) on Nov 16, 2006 at 02:57 UTC
    Hey, I understand that! Well, all except the final $s in map. What does that do?
    Thanks.
      It's like return $s (but you can't use return that way in map). map create a list from the return value(s) of the expression in the curlies.