($domain) = $url =~ m|www.([A-Z a-z 0-9]+.{3}).|x;

Just a side note: The regex quoted above is unlikely to be doing what you expect.

c:\@Work\Perl\monks>perl -wMstrict -le "use YAPE::Regex::Explain; ;; my $rx = qr{www.([A-Z a-z 0-9]+.{3}).}x; ;; print YAPE::Regex::Explain->new($rx)->explain; " The regular expression: (?x-ims:www.([A-Z a-z 0-9]+.{3}).) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?x-ims: group, but do not capture (disregarding whitespace and comments) (case-sensitive) (with ^ and $ matching normally) (with . not matching \n): ---------------------------------------------------------------------- www 'www' ---------------------------------------------------------------------- . any character except \n ---------------------------------------------------------------------- ( group and capture to \1: ---------------------------------------------------------------------- [A-Z a-z 0-9]+ any character of: 'A' to 'Z', ' ', 'a' to 'z', ' ', '0' to '9' (1 or more times (matching the most amount possible)) ---------------------------------------------------------------------- .{3} any character except \n (3 times) ---------------------------------------------------------------------- ) end of \1 ---------------------------------------------------------------------- . any character except \n ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------

Update: I'm not familiar with URL matching in general, but I cannot imagine this problem has not already been addressed in a Perl module — or modules! Maybe search CPAN or MetaCPAN with terms like  URL regex


In reply to Re: Perl prints only last line of array by AnomalousMonk
in thread Perl not printing any special characters in array by myfrndjk

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.