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

Is there any way to do it without using any modules? (Just curious.)

Thanks!

Replies are listed 'Best First'.
Re^3: Regex in a printfile?
by ikegami (Patriarch) on Nov 16, 2006 at 02:13 UTC

    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.

      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.