Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-24 21:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found