
extracting a chunk with regexp?
Welcome to perl, Jesse!
Quote:
>I'm a newbie perl user, and this has me stumped.. I'm trying to
>grab a chunk from a string, using regexp. In this case, I want
>to get the load average on the server and stick it in a variable.
>$_ = `uptime` ;
>#if (/average: (.\...),/) {
>if (/average: (*),/) {
> $loadnow = $1 ;
>}
You're getting confused by the (slight) differences between shell
regular expression syntax and perl regular expression syntax. What
you want is something more like:
if (/average: (\S+),/) { # get multiple non white space
or:
if (/average: ([\d.]+),/) { # get multiple digit or period
Have fun!
--
Hal Wine