siddheshsawant has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks,
I was working on regex in perl and I am stuck at one problem. The code that I wrote is as follows:
#!/usr/bin/perl -w use strict; my $str = "TEST_ENVIRONMENT OS_NAME=AIX BUILD_TYPE= KERNEL_BI +TNESS=64 USER_BITNESS=32 OS_RELEASE=6.1.0.0 CPU_CLASS=powerp +c MACHINE_CLASS=IBM,8203-E4A HOSTNAME=lcla114 NUM_CPUS=5 +CUSTOM= "; my $machine_class = ($str =~ /MACHINE_CLASS=\s*(\w*)/); print "MACHINE CLASS=$machine_class";
As a output of above code I am not getting IBM . Instead, I am getting number 1. So where I am doing mistake? I want to match the string and extract the required value and then have to store that value in the variable and print it.
If anybody knows where I am doing that mistake then let me know about.Thanks in advance !!!!!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regular Expression
by ikegami (Patriarch) on May 14, 2010 at 15:15 UTC | |
by siddheshsawant (Sexton) on May 14, 2010 at 15:29 UTC | |
|
Re: @ Regular Expression
by kennethk (Abbot) on May 14, 2010 at 15:17 UTC | |
|
Re: @ Regular Expression
by wfsp (Abbot) on May 14, 2010 at 15:15 UTC | |
|
Re: @ Regular Expression
by marto (Cardinal) on May 14, 2010 at 15:16 UTC | |
|
Re: @ Regular Expression
by toolic (Bishop) on May 14, 2010 at 15:16 UTC |