Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^4: magic-diamond <> behavior -- WHAT?! (sanity)

by ikegami (Pope)
on Oct 30, 2008 at 09:09 UTC ( #720425=note: print w/ replies, xml ) Need Help??


in reply to Re^3: magic-diamond <> behavior -- WHAT?! (sanity)
in thread magic-diamond <> behavior -- WHAT?!

Not really. It prevents odd file names from being treated as shell commands, but it dos so by killing your program instead of treating them as the names of files to read as intended.

It's like fixing a flat tire by removing the car's battery. Sure, you won't ruin your car by driving with a flat. But you also won't be driving your car.


Comment on Re^4: magic-diamond <> behavior -- WHAT?! (sanity)
Re^5: magic-diamond <> behavior -- WHAT?! (sanity)
by Anonymous Monk on Oct 30, 2008 at 11:41 UTC
    Its more like pulling over when you get nailed, then you get out, fix your tire.

      The program won't run with certain file names. <> just won't work with them. Are you suggesting that all scripts should reimplement <> to use 3-arg open? You're talking about extremely tricky code if you don't want to break -i.

        Well, what most people ranting about magic open say is that files ending in '|' get created either by accident, or they are there to try to exploit something. In such cases, I would like to see the files removed; I rather have my filter stop and complain in stead of silently processing the file and leaving the potential exploit there.

        Now, if you actually want to have files that start with '<', '>', '|' or whitespace, or end with '|' or whitespace, then you are in for a lot of suffering - not just from Perl, but from the shell as well. But still, Perl has a documented solution (see for instance, 'perlopentut'):

        BEGIN {s!^(\s)!./$1!,s/^/</,s/$/\0/ for @ARGV}
        Yes, and that works with -i as well.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2014-11-23 00:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (125 votes), past polls