Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Grepping with Perl: How to stop after first match?

by BrowserUk (Patriarch)
on Dec 06, 2007 at 10:25 UTC ( [id://655352]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    ...## get $fh from somewhere (eg.open)
    my $last = '';
    ...
        $last = $_;
    }
    ...
    
  2. or download this
    perl -ne"($last.$_)=~m[cpuinfo\nvendor_id\s+:\s(.*?)\n]&&print qq[CPU:
    +$1]&&exit;$last=$_" yourfile
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-24 00:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found