Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
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;

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 rifling through the Monastery: (4)
As of 2016-06-25 07:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (323 votes). Check out past polls.