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

Re: File deletion

by choroba (Cardinal)
on May 06, 2013 at 10:55 UTC ( [id://1032241]=note: print w/replies, xml ) Need Help??


in reply to File deletion

Only keep file names in your textfile, the rm is of no use if you are going to implement this in Perl.
20130119-154557_9417560919_rubika_CANARARE-all.mp3 20130122-151714_9003230528_desigans_RELINST-all.mp3 20130128-110435_9865934829_gowrih_CLUBNEW-all.mp3 20130119-172714_9994641778_gowrih_CLUBNEW-all.mp3 20130110-150044_9833539373_ezhil_CANARARE-all.mp3 20130131-094051_8754558656_selvakumarir_BAXANEW-all.mp3 20130117-154031_9884040442_karthikae_CLUB-all.mp3 20130110-100956_9952927800_bhagatsinghd_RELINST-all.mp3 20130107-184842_9841118822_karthikae_CLUB-all.mp3 20130102-162259_9789096778_babysheelaa_CLUB-all.mp3 20130123-145333_9841169173_Anandkumarc_RELINST-all.mp3 20130125-161408_9841274078_karthikae_CLUB-all.mp3 20130130-094413_9840454410_prithivrajb_RELINST-all.mp3 20130104-133223_2030578020_karthick_DB748-all.mp3 20130107-145805_9884020568_jesinthamary_REL-INS-all.mp3 20130102-162826_9566118210_dhanasekarank_RELINST-all.mp3

You can now process the file line by line in Perl. For each line, you remove the end-of-line, try to remove the file and report the success:

#!/usr/bin/perl use warnings; use strict; my $filename = '1.txt'; my $logfile = '1.log'; open my $INPUT, '<', $filename or die "$filename: $!"; open my $LOG, '>', $logfile or die "$logfile: $!"; while (my $line = <$INPUT>) { chomp $line; my $status = unlink $line; my $error = 'OK'; $error = $! unless $status; print $LOG "$line: $error\n"; } close $LOG;
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: File deletion
by 14sudharsan (Initiate) on May 06, 2013 at 11:10 UTC
    Thanks for your support San..

    My last name also san :)

      Where i have to mention the text file path and log file path pls explain me

      /home/san/Desktop/file.txt

      /home/san/Desktop/test/log.txt

        The variables $filename and $logname are fairly self explanatory. If this isn't what you're asking please be more specific.

        Assing the paths to $filename and $logfile on lines 5 and 6 in my script.
        لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2024-04-16 06:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found