NoHero
January 2nd, 2005, 02:24 PM
Hi guys
I just tried to get a small introduction into perl and now I am facing a little problem:
In C you can use the printf() to do number formations. Such as adding nulls to the front until a maximum length is reached:
for ( int i = 1; i < 15
printf("%02d", number);
Will result in 01, 02, 03, 04 etc. But how can I do this in PERL?
I have the following script:
#!/usr/bin/perl
use warnings;
use strict;
use diagnostics;
use LWP::Simple;
print "Content-Type: text/html\n\n";
for my $index(1..14)
{
my $filename='http://www.aperfectcircle.com/posters/poster'.$index.'.jpg';
print "$filename\n";
my $bild= get($filename);
if(defined $bild)
{
open DAT,'> C:/apc/'.$index.'.jpg';
binmode DAT;
print DAT $bild;
close DAT;
}
}
I need the formation in the bold line, because the files are named poster01.jpg, poster02.jpg and so on.
Any help would be very appreciated!
Thanks, Florian
I just tried to get a small introduction into perl and now I am facing a little problem:
In C you can use the printf() to do number formations. Such as adding nulls to the front until a maximum length is reached:
for ( int i = 1; i < 15
printf("%02d", number);
Will result in 01, 02, 03, 04 etc. But how can I do this in PERL?
I have the following script:
#!/usr/bin/perl
use warnings;
use strict;
use diagnostics;
use LWP::Simple;
print "Content-Type: text/html\n\n";
for my $index(1..14)
{
my $filename='http://www.aperfectcircle.com/posters/poster'.$index.'.jpg';
print "$filename\n";
my $bild= get($filename);
if(defined $bild)
{
open DAT,'> C:/apc/'.$index.'.jpg';
binmode DAT;
print DAT $bild;
close DAT;
}
}
I need the formation in the bold line, because the files are named poster01.jpg, poster02.jpg and so on.
Any help would be very appreciated!
Thanks, Florian