Re: How to filter out lines from a variable that has multi-lines?
- From: Narthring <Narthring@xxxxxxxxx>
- Date: Sat, 29 Sep 2007 01:25:10 -0000
On Sep 28, 8:09 pm, mike <needpass...@xxxxxxxxx> wrote:
suppose a variable $a has multi-lines, e.g.
happy
new
new password
year
get password of micky
LOL
What is best way to filter out lines that have "password" involved?
Thanks in advance
One way would be to split on newlines and use a regular expression to
filter out 'password':
use strict;
use warnings;
my $text = '
happy
new
new password
year
get password of micky
LOL';
my (@array) = split(/\n/, $text);
my ($result);
foreach my $line (@array){
$result .= "$line\n" unless ($line =~ m/password/);
}
print "$result";
.
- References:
- Prev by Date: Re: using IPC::Open3 to write to *and* read from a process...
- Next by Date: Re: How to filter out lines from a variable that has multi-lines?
- Previous by thread: How to filter out lines from a variable that has multi-lines?
- Next by thread: Re: How to filter out lines from a variable that has multi-lines?
- Index(es):
Relevant Pages
|