in reply to deleting a file in perl

Below is the Perl equivalent of "rm currentlog_*.log" or "del currentlog_*.log" on the command prompt:

unlink glob "currentlog_*.log";

Replies are listed 'Best First'.
Re^2: deleting a file in perl
by keralaqueen234 (Initiate) on Apr 02, 2013 at 06:53 UTC

    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

      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...