Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Got restless ...

Ok, Took the advice and made a few changes ... :)

I could not get the "when" usage to work!
Running at least Perl v5.16.0
Tried as described in perlsys

So the latest version.

#!/usr/bin/perl use strict; use warnings; # ** # * BCE 42. # * Read a list of file names from a file and delete them. # ** # # ** # * It is what it is, you can do with it as you please. [with respect +, leave the credits] # * # * Just don't blame me if it teaches your computer to smoke! # * # * -Enjoy # * fh :)_~ # ** # # ** Example clean.list # * : Everything after a : and blank lines are ignored # * : Wildcards are valid, be careful. # * : # * # * install_manifest.txt # * cmake_install.cmake # * CMakeCache* # * examples/*.a # ** use File::Basename; my $Prog = "cmake -E"; my $RmDir = "remove_directory"; my $RmFile = "remove -f"; my $RmLink = "remove -f"; sub runCommand { return `$Prog $_[0] \"$_[1]\"` if $_[0] && $_[1]; return -1; } sub cleanup_Link # non Win32 { print "Deleting Link: $_[0]"; runCommand($RmLink, $_[0]); print " ... Deleted!" if not -l $_[0]; print "\n"; } sub cleanup_Dir { print "Deleting Dir : $_[0]"; runCommand($RmDir, $_[0]); print " ... Deleted!" if not -d $_[0]; print "\n"; } sub cleanup_File { print "Deleting File: $_[0]"; runCommand($RmFile, $_[0]); print " ... Deleted!" if not -f $_[0]; print "\n"; } sub cleanup { for (glob qq("$_[0]")) { cleanup_Link($_) if -l; # non Win32 cleanup_Dir ($_) if -d _; cleanup_File($_) if -f _; } } sub main { my $Dir = dirname(__FILE__); open(FILE, "$Dir/clean.list") or die("Unable to open file: $Dir/cl +ean.list."); my @Data = <FILE>; close(FILE); foreach my $line (@Data) { next if $line =~ /^$/; # skip blank lines next if $line =~ /:/; # skip comment lines with ':' (colon) +in them chomp $line; # trim the newline cleanup($line); } } main();

Critiques ??
Comments ??
Suggestions ??
Improvements ??

Thanks

-Enjoy
fh : )_~


In reply to Re: File existance check failure by Festus Hagen
in thread File existance check failure by Festus Hagen

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others surveying the Monastery: (6)
    As of 2015-07-05 05: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 (60 votes), past polls