Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: question about perl

by Ryszard (Priest)
on Mar 13, 2002 at 00:10 UTC ( #151272=note: print w/ replies, xml ) Need Help??


in reply to How do I change the shebang line for all perl scripts in a directory

A quick (untested) hack:

#!/usr/bin/perl -w use strict; my @files = `find . -name "*.pl"`; foreach my $file (@files) { local*FH; open(FH, ">$file"); my @contents = <FH>; $contents[0]="#!/usr/local/bin/perl -w"; print FH $_ foreach (@contents); close FH; }

Yup, I'm aware of the bad practice in this script, however, its just a quick hack.

NB: I've taken the liberty to add warnings (-w) to your shebang, and it may break your scripts, although, it shouldnt.. :-)

Update: Fixed typo as per defyance's comment. Please note the "untested" disclaimer.


Comment on Re: question about perl
Download Code
Re: Re: question about perl
by defyance (Curate) on Mar 13, 2002 at 00:26 UTC
    If you change this:

    my @files = `find . -name "*.pl";

    To this:

    my @files = `find . -name "*.pl"`;

    It will work, but make all of your *.pl files say nothing but #!/usr/local/bin/perl. Thought I'd point that out.

    -- Yes, I am a criminal. My crime is that of defyance.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2014-12-25 06:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (159 votes), past polls