Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
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 exploiting the Monastery: (16)
As of 2015-07-31 21:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (282 votes), past polls