Think about Loose Coupling | |
PerlMonks |
Re: text extraction questionby wulvrine (Friar) |
on Dec 05, 2006 at 19:24 UTC ( [id://587958]=note: print w/replies, xml ) | Need Help?? |
echoangel911 The simplest way would be to use a regular expression, for example /w(.+)b(.+)cm(.+)sw(\S*)\s*$/ Which would mean find anything (not assuming digits) after the w, the b, the cm, and the sw. The final (\S)\s*$ points to any non white space(\S) followed by any whitespace(\s*), followed by end of line ($). This will take anything after the 'sw' tag that ISNT white space but would leave any extra spacing (space/tabs etc) at the end of the line out of the match. The matches themselves are stored in the variables $1 thru $4. Here is an example
Output is: template found first=<NM>, second=<NM>, third=<CH>, fourth=<SW> input found first=8, second=8, third=512, fourth=no I hope that helps!
s&&VALKYRIE &&& print $_^q|!4 =+;' *|
In Section
Seekers of Perl Wisdom
|
|