Thx toolic, I was reading the example page wrong and missed that my file was there with a tdy suffix. Looks like it's all straightened out now:
$ perltidy -b tg6.pl
$ perl tg6.pl
downloaded 2 images from http://www.perlmonks.org
to folder site_5
$ echo "wow, that's minimal."
wow, that's minimal.
$ cat tg6.pl
#!/usr/bin/perl -w
# creates a new directory and downloads images from url to it
# perlmonks node 965537; thx aaron and A.M.
use strict;
use feature ':5.10';
use WWW::Mechanize;
use LWP::Simple;
use Errno qw[ EEXIST ];
# get information about images
my $domain = 'http://www.perlmonks.org';
my $m = WWW::Mechanize->new();
$m->get($domain);
my @list = $m->images();
# create new folder and download images to it.
my $counter = 0;
my $dir = &mk_new_dir;
for my $img (@list) {
my $url = $img->url_abs();
$counter++;
my $filename = $dir . "/image_" . $counter;
getstore( $url, $filename ) or die "Can't download '$url': $@\n";
}
# output
print "downloaded ", $counter, " images from ", $domain, "\n";
print "to folder ", $dir, "\n";
sub mk_new_dir {
my $counter2 = 1;
while (1) {
my $word = "site";
my $name = $word . '_' . $counter2++;
if ( mkdir $name, 0755 ) {
return $name; # success, return new dir name
}
else {
next if $!{EEXIST}; # mkdir failed because file exists
die sprintf "(%d) %s", $!, $!; # other failure; bail ou
+t!
}
}
}
$
I think, if I were going to change anything, it might be the number of spaces (or tab-length, whichever it is) after a statement and before a right comment and maybe go from 4 to 3 spaces for a general indenting. You can see that I have a bit of fold-over in the display (not real fold-over with a newline tho)
Let me ask this. Are there specific choices that matter a whole bunch in the negative sense here. For example, if I went with -i3 indenting, are there people that matter out there who would say, "gosh, the perl here is one thing, but this 3-space indenting is giving me a headache and crossing my eyes. What moron does that when he could have done 2 or 4: nice even numbers?"?