Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Extracting Page Name

by choroba (Canon)
on Apr 26, 2012 at 23:20 UTC ( #967487=note: print w/ replies, xml ) Need Help??


in reply to Extracting Page Name

You can use a regular expression. It matches non-slash characters up to the end of the URL.

my ($pagename) = $url =~ m{([^/]+)$};


Comment on Re: Extracting Page Name
Download Code
Re^2: Extracting Page Name
by JimStone (Initiate) on Apr 27, 2012 at 00:07 UTC
    Thanks everyone for the quick replies. This regular expression is just what I needed to see what I was doing wrong.
Re^2: Extracting Page Name
by ww (Bishop) on Apr 27, 2012 at 13:54 UTC

    ... but has a (greedy) failure mode:

    C:\>perl -e "my $url = 'http://www.perlmonks.com/index.pl?node_id=9674 +84'; my ($pagename) = $url =~ m{([^/]+)$}; print $pagename;" index.pl?node_id=967484 C:\>

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://967487]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (8)
As of 2015-07-02 04:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (27 votes), past polls