On Tue, 24 Sep 2002, Brian Ling wrote:

> Hi
> 
> Does anyone know how to save any data that is matched
> by regular expression, from within a string or array,
> the match could occur any number of times.
> 
> I can happily discard any matched data, but not the
> other way round.
> 
> Help this is driving me up the wall, I'm sure there is
> an easy answer to this, as I have a large amount of
> data returned form a system command and I only need to
> keep a small easily match amount.

We can help you better if you can post the output or a small sample of how 
it looks like. 

If you want to save the matched string or substring read through 
perldoc perlre
perldoc perlvar # Search for and start from $<digits>

If you want to filter the output of a command you can do without using 
these variables (actually depends on the complexity of your filtering)
This is an example of filetering the output of ls 
(do not print the directory or file named 'perl')
#!/usr/bin/perl -w
use strict;

open (LIST, "ls |") or die "Error\n";
while (<LIST>) {
    chomp;
    print "$_\n" if (!/^perl$/);
}


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to