Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: using basename on a list of filesnames

by flieckster (Scribe)
on Nov 13, 2019 at 02:08 UTC ( #11108605=note: print w/replies, xml ) Need Help??


in reply to Re: using basename on a list of filesnames
in thread using basename on a list of filesnames

that didn't seem to work
Use of uninitialized value $_[0] in substitution (s///) at /System/Lib +rary/Perl/5.18/File/Basename.pm line 341, <GEN0> line 10. fileparse(): need a valid pathname
i also tried.
my $basename = basename (@TIFFfolder_list, ".psd"); print "$basename\n";
that only gave one filename output from the array.

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

    Did you add a debug print statement inside the loop to see what you are passing to basename() in $file? It really works:

    $ perl -MFile::Basename -wE 'say basename("foo.psd",".psd")' foo
    ... but passing an undefined value does not:
    $ perl -MFile::Basename -wE 'say basename(undef,".psd")' Use of uninitialized value $_[0] in substitution (s///) at /Users/1nic +kt/perl5/perlbrew/perls/perl-5.30.0/lib/5.30.0/File/Basename.pm line +341. fileparse(): need a valid pathname at -e line 1.


    The way forward always starts with a minimal test.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2022-05-18 14:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (71 votes). Check out past polls.

    Notices?