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

Re: Regex: how to consider an unknown number of tabs?

by balakrishnan (Monk)
on Apr 04, 2010 at 16:05 UTC ( #832716=note: print w/ replies, xml ) Need Help??


in reply to Regex: how to consider an unknown number of tabs?

You can also try the below code to achieve your need.

use IO::File; my $fh = new IO::File "input_file", "r"; my @lines = <$fh>; my $pattern = "r145"; my ($para,@output); foreach my $line(@lines) { if($line =~ /^(\S+)/ ) { if($line =~ /^$pattern/) { $para = undef; } else { $para = $1; push @output,$line; } } elsif(defined($para) ) { push @output,$line; } } print @output;


Comment on Re: Regex: how to consider an unknown number of tabs?
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (10)
As of 2014-09-02 08:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (20 votes), past polls