I am not sure about that.
It is perfectly allowed to use a character class Perl short-cut within brackets, [\d] means the same as [0-9]
[\w] would mean same as [a-zA-Z0-9_]
use strict; use warnings; my $x = 'a34x5'; my @y = $x =~ /([\d]+)/g; my @z = $x =~ /([0-9]+)/g; print "@y\n"; # 34 5 \d worked fine print "@z\n"; # 34 5 my @b = $x =~ /([\d\w]+)/g; print "@b\n"; # a34x5 \d irrelevant but \w works my @c = $x =~ /([\w]+)/g; #brackets not needed print "@c\n"; #a34x5 my @d = $x =~ /(\w+)/g; print "@d\n"; #a34x5
No matter what, the OP's code is bizarre.

Added: The idea of using an anchor to the beginning of the string, followed by any amount of random stuff, makes no sense to me. Better to leave that off entirely (don't put /^.*(match)/, just put /(match)/.

I think if you want \ in the character set, you have to escape it with another \


In reply to Re^3: In my it is printing in the else i want to get output for the for loop in linux. by Marshall
in thread In my it is printing in the else i want to get output for the for loop in linux. by Anonymous Monk

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.