Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Regex question

by YuckFoo (Abbot)
on Aug 19, 2005 at 02:35 UTC ( #485005=note: print w/ replies, xml ) Need Help??


in reply to Regex question

cajun,

Seems like a natural for split. You get the bonus filename too.

SplitFoo

#!/usr/bin/perl use strict; while (my $line = <DATA>) { chomp $line; my ($dir, $file) = (split(m{/}, $line))[-2, -1]; print "$dir $file\n"; } __DATA__ http://www.domain.com/data/2005/sales/01012005.txt http://www.domain.com/data/2005/sales-jan/01232005.txt http://www.domain.com/data/2005/sales-local/01012005.txt http://www.domain.com/data/2005/sales-outside-jan/01012005.txt


Comment on Re: Regex question
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2015-07-28 10:46 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 (254 votes), past polls