The spec-by-example is imprecise. Does "89" fit your use of "words" or should it be excluded for lack of an alpha character?
If the latter (which is the way I read "words") you'll need slightly more complex code:
#!/usr/bin/perl
use 5.016;
use strict;
use warnings;
# 1041443
my @array=("aqw","asd8dsa","sd8sd","89","aws", "17A", "bc24", );
for my $elem (@array) {
if ( $elem =~ /\d/ ) {
if ( $elem !~ /[\D]/ ) {
say "No non-digits in *| $elem |*";
next;
}
say $elem;
} else {
say "No numerals in *| $elem |*";
}
}
OUTPUT:
No numerals in *| aqw |*
asd8dsa
sd8sd
No non-digits in *| 89 |*
No numerals in *| aws |*
17A
bc24
If you didn't program your executable by toggling in binary, it wasn't really programming!
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.