Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Shorter version in perl' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Shorter version in perl
Authored by: zed on Oct 18, '02 11:00:09AM

Heres a improvement...

This script is:

1. shorter
2. handles multiple filenames on the cmd line
3. only creates files if -c and does not exist!


#!/usr/bin/perl

use Getopt::Std;
getopts(\'c\');

foreach (@ARGV) {
$filename = $_;
if (! -e $filename ) {
if ($opt_c) { system \"touch $filename\"; }
else {print \"$filename doesn\'t exist. Specify -c to create.\\n\" ;}
}
elsif ($opt_c) {print \"$filename already exists. Cannot create.\\n\" ;}
system \"open -a /Developer/Applications/Project\\\\ Builder.app \\\'$filename\\\'\" ;
}

Cheers,

----Zed



[ Reply to This | # ]