Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: using basename on a list of filesnames

by jcb (Parson)
on Nov 13, 2019 at 04:27 UTC ( [id://11108610]=note: print w/replies, xml ) Need Help??


in reply to using basename on a list of filesnames

This is an XY Problem. You are using basename correctly. Try changing print "$file\n"; to push @Files, $file; and adding my $file = join(' ', @Files); just before line 24. Meditate upon those changes and you will gain understanding.

Replies are listed 'Best First'.
Re^2: using basename on a list of filesnames
by 1nickt (Canon) on Nov 13, 2019 at 05:03 UTC

    How is it correct usage to pass a list of filenames?! Only the first is handled as a filename; the rest are possible suffix matches.

    From the doc:

    $basename = basename($fullname,@suffixlist);

    $ perl -MFile::Basename -wE 'say basename("foo.psd","bar.psd",".psd")' foo


    The way forward always starts with a minimal test.

      You are right. I had misread the code because passing the entire list a loop is iterating over instead of the current item is not a mistake I have ever made.

      The change I suggested is still needed, since our questioner is currently iterating over a list, but only passing a single value to his output routine.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (2)
As of 2024-04-26 07:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found