Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Perl stricter than my OS regarding file/dir names

by dsb (Chaplain)
on Feb 15, 2006 at 20:11 UTC ( #530502=note: print w/ replies, xml ) Need Help??


in reply to Perl stricter than my OS regarding file/dir names

Are you initializing $dir or $current_filename with values from STDIN? If so, chomp'ing them might help.


dsb
This @ISA my( $cool ) %SIG


Comment on Re: Perl stricter than my OS regarding file/dir names
Re^2: Perl stricter than my OS regarding file/dir names
by je44ery (Hermit) on Feb 15, 2006 at 20:19 UTC
    No, I am creating $dir and $current_filename using random ASCII values > 0 and < 128. I need to keep the newlines and other funky characters as-is. I think I'm only having trouble with newlines at this point.

      You aren't telling us if the directory exists or not. Perl only gives you a helpfull warning, just in case you are trying to stat a file/directory with a newline in it - which would be a common programming error.

      If you want to avoid the warning, just use

      { no warnings 'newline'; next if -d "$dir/$current_filename"; };

        A bare block is a loop construct, so that next won't propagate out. Quick demonstration:

        $ perl -le 'for (1..10) { { next if 1 }; print }' 1 2 3 4 5 6 7 8 9 10
        Not sure why the existence of the directory would matter. Most of the time, it doesn't exist.
        user@host:/home # perl -w print "OK" if -d 'I_swear_this_file_aint_here'; print "See, I told you.\n" <CTRL+D> See, I told you. user@host:/home
        I see no special output if the tested for file doesn't exist. It just silently fails.

        But...

        Thanks for the warnings info! That looks to be what I need, I'll bet.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2014-07-28 05:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (186 votes), past polls