TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

That perl thing again



Here's what I got.  This code runs, and seems to work the way I'd expect,
anyways.  I *think* this does what you set out to do -- in any case, I
changed as little of the code as I could, I just altered the flow.


#!/usr/bin/perl
@pwinfo = getpwuid($<);
$DELETEDIR = "$pwinfo[7]/.Trash";
if (@ARGV[0] eq  "") {print "Syntax:\ndel [files and directories to
delete]\n"}
else {
 foreach $test (@ARGV) {
        if ($test eq  "--recursive") {}

        elsif ( $test !~ /^-.*/) { $new = C("$test"); }
        elsif ( $test =~ s/[rR]//g) { $new = C("$test"); }
 }
}

sub C {
        my $new .= '"';
        $new .= shift;
        $new .= '" ';
        if (!-e "$DELETEDIR") {`mkdir $DELETEDIR`};
	  `mv $new $DELETEDIR`;
}