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

Re^2: deleting a file in perl

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

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

could you please tell me how exactly do i do the coding for this? i need to first see which all files in the diectory has the file named currentlog*.log . and i need to delete all the files with that name pattern,but need to retain currentlog.log(which is the latest log file ) ..pleasee help me :(

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

    The script shown in my previous post, should work.
    Usage: perl <directory_name>
    Where is your Perl script, directory_name the directory you which to go through, checking which file to delete, after you have been shown the name of the file, if you want to delete the file you answer y, if not just press ENTER.

    If you tell me, I'll forget.
    If you show me, I'll remember.
    if you involve me, I'll understand.
    --- Author unknown to me

      yes that works .. but in my folder xyz , i have files with names currentlog.log,currentlog123.log,currentlog233.log,detail.txt,see.txt .... i need to delete only the files which has the name pattern of 'currentlog'. other files including currentlog.log need to be do i find the patern of filenames ?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1026597]
[Corion]: Meh ... Minion really doesn't want to run under the fork() emulation on Windows (which I understand), but has no other way either (which I find inconvenient)
[Corion]: Other than that, it seems really polished

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2018-06-21 14:59 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (118 votes). Check out past polls.