mw has asked for the wisdom of the Perl Monks concerning the following question:
Greetings Monks,
This must be an extremely easy question to answer, but much searching has not yielded the answer I seek. I am parsing messages from TSM, which have a format like this:
Menno
ANE4954I Total number of objects backed up: 3I need the "ANE4951I" part of the string, which can be found by simply applying the following regular expression: s/\s.*// However, I don't wish to change the original text, so I reasoned that as $a=+1 is equivalent to $a=$a+1, so $a=~s/\s.*// should be equivalent to $a = $a ~ s/\s.*//, enabling me to express my needs thus:
Sadly, this gives me a syntax error. What is the correct syntax for this? For now, I have coded it like this:$message_id=$message ~ s/\s.*//;
But I suspect there is a better way. Thanks,$message_id=$message; $message_id=~s/\s.*//;
Menno
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Applying a regular expression to a string
by ysth (Canon) on Apr 04, 2005 at 11:54 UTC | |
by mw (Sexton) on Apr 07, 2005 at 07:50 UTC | |
Re: Applying a regular expression to a string
by ambs (Pilgrim) on Apr 04, 2005 at 11:42 UTC | |
Re: Applying a regular expression to a string
by BazB (Priest) on Apr 04, 2005 at 11:46 UTC | |
by Smylers (Pilgrim) on Apr 04, 2005 at 13:22 UTC | |
Re: Applying a regular expression to a string
by Zaxo (Archbishop) on Apr 04, 2005 at 11:45 UTC |
Back to
Seekers of Perl Wisdom