Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: deleting a file in perl

by keralaqueen234 (Initiate)
on Apr 02, 2013 at 06:53 UTC ( #1026595=note: print w/ replies, xml ) Need Help??


in reply to Re: deleting a file in perl
in thread deleting a file in perl

i tried with unlink glob. but it deleted my currentlog file also :( ..... i dont want to delete it .eventhough i gave currentlog*.log, it deleted currentlog.log too. Please help me out


Comment on Re^2: deleting a file in perl
Replies are listed 'Best First'.
Re^3: deleting a file in perl
by hdb (Prior) on Apr 02, 2013 at 07:01 UTC

    currentlog.log fits the pattern currentlog*.log. The "_" makes the difference. If you need something more general than "currentlog_*.log" try this:

    my @logs = glob "currentlog*.log"; for (@logs) { next if $_ eq "currentlog.log"; unlink $_; }

    I hope you have copies of your logfiles before do any testing...

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (10)
As of 2015-07-30 07:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (270 votes), past polls