Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Use of grep and foreach

by crouchingpenguin (Priest)
on Aug 11, 2003 at 14:22 UTC ( #282885=note: print w/ replies, xml ) Need Help??


in reply to Use of grep and foreach

Give this a try:

#!/usr/bin/perl use strict; use warnings; use Tie::File; my @file; tie @file, 'Tie::File', '/tmp/filename' or die "Failed to tie file: $!"; foreach my $matching_line ( grep { m/^myLine/ } @file ){ $matching_line =~ s/^myLine/this_was_a_match/; }

cp
----
"Never be afraid to try something new. Remember, amateurs built the ark. Professionals built the Titanic."


Comment on Re: Use of grep and foreach
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (14)
As of 2014-07-23 11:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (140 votes), past polls