I am not sure what you want.
It would be helpful if you could give an OUTPUT section like you have a DATA section.
Why does this have to be so complex?
Update: small formatting change.
#!/usr/bin/perl -w
use strict;
while (<DATA>)
{
print "testing: $_";
chomp;
my @digits = m/\d+/g;
print "digits only: @digits\n";
my @numletters = m/\d[^\d]+/g;
print "digits_and_letters:@numletters\n\n";
}
#Prints:
#testing: 1c
#digits only: 1
#digits_and_letters:1c
#
#testing: 2w
#digits only: 2
#digits_and_letters:2w
#
#testing: 2c3w
#digits only: 2 3
#digits_and_letters:2c 3w
#
#testing: 1w1w
#digits only: 1 1
#digits_and_letters:1w 1w
#
#testing: 1w2r
#digits only: 1 2
#digits_and_letters:1w 2r
#
#testing: 2r1c
#digits only: 2 1
#digits_and_letters:2r 1c
__DATA__
1c
2w
2c3w
1w1w
1w2r
2r1c
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.