How do I match urls in a regular expression?

You need a regular expression to match urls in some text.

Solution: use Regexp::Common

Don't reinvent the wheel. A module called Regexp::Common contains many, many common regular expression - including those for matching urls.

    use strict;
    use warnings;

    use Regexp::Common qw(URI);
    my @urls;
    while (<>) {
        # Provide a way out
        last if ($_ eq "\n");
        # Match URLs
        push (@urls, /$RE{URI}{HTTP}/g);

See also

Read through the Regexp::Common documentation for further common regular expressions:

    perldoc Regexp::Common

For more general regular expression information, see:

    perldoc perlretut
    perldoc perlre