Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: Regex in a printfile?

by Andrew_Levenson (Hermit)
on Nov 16, 2006 at 02:00 UTC ( [id://584346]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://584346]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2024-04-20 11:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found