Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re^2: getting a while loop to terminate

by Datz_cozee75 (Pilgrim)
on Apr 17, 2012 at 16:41 UTC ( #965532=note: print w/replies, xml ) Need Help??

in reply to Re: getting a while loop to terminate
in thread getting a while loop to terminate

Yay! first taste of victory....

$ perl site_13 $ cd site_13 $ ls image_1 image_2 image_3 ... $ cd .. $ cat #!/usr/bin/perl -w use strict; use WWW::Mechanize; use LWP::Simple; my $domain = ''; my $m = WWW::Mechanize->new; $m->get( $domain); my $counter = 0; my $dir = &dirname; my @list = $m->images(); 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"; } sub dirname { my $word = "site"; my $counter = 1; my $flag = 1; while ($flag) { my $name = "$word" . "_" . "$counter"; if ( -d $name) { $counter++; next; } else { mkdir $name, 0755 or warn "Cannot make dir $name: $!"; $flag = 0; } print "$name \n"; return $name; } } $

I have a whole bunch of questions at this point, but don't want to ask them all. Let me ask this one, because it goes to readability: Is there an indent command that works well for perl? indent -i2 was not a winner.

Replies are listed 'Best First'.
Re^3: getting a while loop to terminate
by GrandFather (Sage) on Apr 18, 2012 at 01:18 UTC

    You may be looking for Perl::Tidy which does an excellent job of pretty printing Perl and is highly configurable.

    True laziness is hard work

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://965532]
[Corion]: Heh - I just realized, $work management just declared "no raises for anybody this year", and I'm not even angry about that. Even though that implicitly means "raises for the people with an automatic 5% raise in their contract", which the newly-merged ...
[Corion]: ... coworkers have. But I guess I've gone more mellow since I get to relax more, and such stuff doesn't make me as angry as it used to.
[Corion]: $boss will still get to listen to my interpretation :-D
[Eily]: hey, I'm just behind Larry in SioB \o/

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2018-01-22 11:08 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (233 votes). Check out past polls.