CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
get size in a variable

 



sajanagr
Novice

Jan 26, 2010, 11:58 PM

Post #1 of 4 (3337 views)
get size in a variable Can't Post

Hi
I have a simple query to get the size output of a command into a variable. This is what i have tried :
The command output is like :

Code
   68.58G


Regular expression :

Code
if ($out =~ /(\d*\.\d*\S)/){ 
$out=$1;
}


This seemed to work earlier and i hav updated perl and it now gives me output ' .p '; I don't seem to understand the issue.

Kindly help!!
Not all who wander are lost ---- /me


shawnhcorey
Enthusiast


Jan 27, 2010, 5:10 AM

Post #2 of 4 (3330 views)
Re: [sajanagr] get size in a variable [In reply to] Can't Post

Print out the contents of $out. I think you'll find it has at least two periods in it.

__END__

I love Perl; it's the only language where you can bless your thingy.

Perl documentation is available at perldoc.perl.org. The list of standard modules and pragmatics is available in perlmodlib.

Get Markup Help. Please note the markup tag of "code".


sajanagr
Novice

Jan 27, 2010, 5:20 AM

Post #3 of 4 (3328 views)
Re: [shawnhcorey] get size in a variable [In reply to] Can't Post

The issue has been solved. The expression was fine, but not perfect. Checked out the output of $out and solved it. Modified the expression by -


Code
$out =~  /(\d+\.\d+G\s+)/

Not all who wander are lost ---- /me


shawnhcorey
Enthusiast


Jan 27, 2010, 5:53 AM

Post #4 of 4 (3323 views)
Re: [sajanagr] get size in a variable [In reply to] Can't Post


Code
$out =~  /(\d+\.\d+G\b);/


\b works even at the end of a string.

__END__

I love Perl; it's the only language where you can bless your thingy.

Perl documentation is available at perldoc.perl.org. The list of standard modules and pragmatics is available in perlmodlib.

Get Markup Help. Please note the markup tag of "code".

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives