[clug-talk] Perl regular expressions ?

Michael Gale michael.gale at bluesuperman.com
Mon Mar 21 18:38:48 PST 2005


Hello,

I wrote this little test script to my regular expressions:

#!/usr/bin/perl -w

while(<STDIN>)
{
my($input) = $_;
chomp($input);

#my($input,$check) = $input =~ m/(.*\|)(.*)$/;

if ($input =~ "DONE")
         {
                 exit;
         }

$input =~ /.*(\d+)/;


print "#################\n";
print "### OUTPUT IS ###\n";
print "#################\n";
print "### ";
print $_;
print "\n";
print "#################\n";
print "\n\n\n";

}


Michael.


Michael Gale wrote:
> Hello,
> 
> I am going to start playing around with perl regular expressions but 
> first have some questions I am hoping someone on the list can answer ?
> 
> 1. Can I test them from the command line ?
> 
> echo "some string of text" | perl place_regular_expression_here
> 
> 2. How would I go about producing arguments are out put, for example:
> 
> echo "Memory Usage: 25% used warning 75%" | perl 'Memory.Usage:.\d+'
> 
> The about would produce "Memory Usage: 25" but I only want to output the 
> 25 but I also need to make sure that the first part contains "Memory 
> Usage:" ?
> 
> Thanks.
> 
> Michael.
> 
> _______________________________________________
> clug-talk mailing list
> clug-talk at clug.ca
> http://clug.ca/mailman/listinfo/clug-talk_clug.ca
> Mailing List Guidelines (http://clug.ca/ml_guidelines.php)
> **Please remove these lines when replying



More information about the clug-talk mailing list