Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
We don't bite newbies here... much
 
PerlMonks  

Re: Re: split to get the dir name

by dvergin (Monsignor)
on Sep 29, 2003 at 18:56 UTC ( #295069=note: print w/ replies, xml ) Need Help??


in reply to Re: split to get the dir name
in thread split to get the dir name

Quothe dragonchild:
    my $filename = (split ' ', $_)[-1];

But what if the filename contains a space?

------------------------------------------------------------
"Perl is a mess and that's good because the
problem space is also a mess.
" - Larry Wall


Comment on Re: Re: split to get the dir name
Re3: split to get the dir name
by dragonchild (Archbishop) on Sep 29, 2003 at 19:02 UTC
    Then split will break. You'd have to go with substr (which would be platform-dependent) or change the ls pipe from 'ls -l' to 'ls -1'. *shrugs*

    ------
    We are the carpenters and bricklayers of the Information Age.

    The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

    Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

      Just curious, how is substr platform-dependent? And how is ls not platfrom-dependent?

      Nonsense. You never liked me anyway. You wouldn’t even come to my birthday party!
        The output of 'ls -l' is dependent on which *nix you're using. Hence, the index into substr will change depending on the *nix you run on. 'ls -l' is actually not as platform-dependent as you think. It runs on Win2003Pro ...

        ------
        We are the carpenters and bricklayers of the Information Age.

        The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

        Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (8)
As of 2014-04-16 06:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (414 votes), past polls