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
#! /usr/bin/perl
use strict;
use warnings;
my $templateformat = 'w<NM>b<NM>cm<CH>sw<SW>';
my $inputexample = 'w8b8cm512swno';
if ($templateformat =~ /w(.+)b(.+)cm(.+)sw(\S*)\s*$/ ) {
print "template found\n";
my $first = $1;
my $second = $2;
my $third = $3;
my $fourth = $4;
print "first=$first, second=$second, third=$third, fourth=$fourth\n"
+;
}
if ($inputexample =~ /w(.+)b(.+)cm(.+)sw(\S*)\s*$/ ) {
print "input found\n";
my $first = $1;
my $second = $2;
my $third = $3;
my $fourth = $4;
print "first=$first, second=$second, third=$third, fourth=$fourth\n"
+;
}
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 =+;' *|