- ^ is match at beginning ..
- \d is looking for a digit character
- + is find \d 1 or more times
- (...) Groups subexpressions for capturing to $1, $2,$3 ...

In this case, $scrip will return the the complete sub expression match (which is inside the brackets : (\d+\.\d+\.\d+\.\d+) ):
my ($scrip) = $ARGV[0] =~ /^(\d+\.\d+\.\d+\.\d+)/; print "\$scrip returned : $scrip\n"; print "match 1 : $1\nmatch 2 : $2\nmatch 3 : $3\nmatch 4 : $4\n";
INPUT
C:\Perl\bin>perl bleh.pl 1.0.3.3_1.3.45.44

OUTPUT
$scrip returned : 1.0.3.3
match 1 : 1.0.3.3
match 2 :
match 3 :
match 4 :

If "\d+\.\d+\.\d+\.\d+" wasn't inside the brackets, $scrip would return 1, if it matched the reg-ex:
my ($scrip) = $ARGV[0] =~ /\d+\.\d+\.\d+\.\d+/; if($scrip) { print "matched $ARGV[0] !\n"; }else{ print "did not match $ARGV[0] !\n"; } print "\$scrip = $scrip\n";
OUTPUT EXAMPLES:

C:\Perl\bin>perl bleh.pl 13.3.3.3_
matched 13.3.3.3_ !
$scrip = 1

C:\Perl\bin>perl bleh.pl 13.3.
did not match 13.3. !
$scrip =

In reply to Re: Need advice on PERL by kabeldag
in thread Need advice on PERL by ccrash

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.