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 =+;' *|

In reply to Re: text extraction question by wulvrine
in thread text extraction question by echoangel911

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.