robocop100
asked on
Perl string parsing
I have a string with the value:
200 result=12345
There is sometimes a newline character after the 5, sometimes not.
Using Perl how can I extract 12345 into a new variable?
200 result=12345
There is sometimes a newline character after the 5, sometimes not.
Using Perl how can I extract 12345 into a new variable?
ASKER
the string result may be of unknown length (it's just 5 in this example)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Even simpler...
$string = "200 result=12345\n"; # below works with or without the newline in the string
$string =~ m{=(.*)$};
$result = $1;
$string = "200 result=12345\n"; # below works with or without the newline in the string
$string =~ m{=(.*)$};
$result = $1;
Open in new window