Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Question regarding options like -i -n -p

by Laurent_R (Canon)
on May 29, 2013 at 20:34 UTC ( #1035917=note: print w/replies, xml ) Need Help??


in reply to Question regarding options like -i -n -p

I am not sure of what you want exactly, but if you want to get rid of bakcup files, you can do something like this:

$ perl -i.bak -pe 's/ /  /g; END {unlink "*.bak"}' file.txt

This is *nix syntax, but I guess you could have this untested equivalent under Windows:

perl -i.bak -pe "s/ /  /g; END {unlink qq/*.bak/}" file.txt

Replies are listed 'Best First'.
Re^2: Question regarding options like -i -n -p
by AnomalousMonk (Chancellor) on May 29, 2013 at 21:16 UTC

    I don't remember about (and cannot test (and don't want to bother looking up)) unlink under *nix, but under Windoze it doesn't do wildcards. But this sure works (for Windose):

    >perl -wMstrict -le "unlink glob '*.bak'; "

      Yes, you are right, my mistake. The unlink function does not take wildwards, also not under *nix. So the use of the additional glob function would be necessary to get it to work.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1035917]
help
Chatterbox?
[GotToBTru]: okay, fess up, who installed CB::Typo?
[Discipulus]: at 7th floor seagulls eat mice
[Discipulus]: just in Eataly: brain surgery while playing clarinet..
[erix]: installing perfect pitch?

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (13)
As of 2017-11-17 20:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (272 votes). Check out past polls.

    Notices?