My full test program is here:while(<FH>) { my $line = $_; chomp($line); $line =~ /^[\d]+ rows in set \(([^\)]+)/; $retValue = $1 if (defined($1)); } close FH; print "The value is '$retValue'\n";
To explain, the pattern match /^[\d]+ rows in set \(([^\)]+)/ captures everthing between the parens into $1.#!/usr/bin/perl -w # my $text=<<EOL; mysql> select * from shop; +---------+--------+-------+ | article | dealer | price | +---------+--------+-------+ | 0001 | A | 3.45 | | 0001 | B | 3.99 | | 0002 | A | 10.99 | | 0003 | B | 1.45 | | 0003 | C | 1.69 | | 0003 | D | 1.25 | | 0004 | D | 19.95 | +---------+--------+-------+ 7 rows in set (0.00 sec) EOL if ( ! open(FH,"echo '$text' |" ) ) { die "can't open\n"; } my $retValue = ''; while(<FH>) { my $line = $_; chomp($line); $line =~ /^[\d]+ rows in set \(([^\)]+)/; $retValue = $1 if (defined($1)); } close FH; print "The value is '$retValue'\n";
In reply to Re: MySQL Query Time DBI
by elmoz
in thread MySQL Query Time DBI
by KynkoKat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |