this is a perl scritp to get the wallpaper on the top of the /w board
sorry for my bad english :P
i use wakawall.jpg at default desktop on gnome
and make the system execute it every times i start the sesion
#!/usr/bin/perl
use LWP::Simple;
$url="http://www.cyril.dreamhost.com/w/wakaba.html";
$webpage = get($url);
if ($webpage =~ /.jpg/){
#take code between the first and second "<span clas..."
@trozo = split ('<span class="filesize">',$webpage,2);
#take all the code between 'href="' and 'jpg">' incusive
$begin = index( $trozo[1], 'href="');
$end = index ( $trozo[1], 'jpg">');
$ImageString = substr ($trozo[1], $begin, $end-$begin);
#whitout all html code
$ImageString =~ s/^href="//g;
$UriImage = 'http://www.cyril.dreamhost.com'.$ImageString.'jpg';
#image name without w/src/
$ImageName = substr ($ImageString,7 )."jpg";
#any knows a better way to do this?
#using only perl, no "system"
system("wget $UriImage");
system("cp $ImageName ~/wakawall.jpg");
system("mv $ImageName wakawall");
}
#end --------------------------------------
2GET
#any knows a better way to do this?
#using only perl, no "system"
system("wget $UriImage");
system("cp $ImageName ~/wakawall.jpg");
system("mv $ImageName wakawall");
sorry for my bad english :P
Why not just repeat what you did to get the HTML? Probably something along these lines:
$data = get $UriImage;
open(FD, ">wakawall");
binmode FD;
print(FD, $data);
close FD;
copy ("wakawall", "~/wakawall.jpg");
Don't forget to include File::Copy, nor your die()s (nor strict mode...).
I've forgotten most of perl though, so I defer to anyone who actually knows how to beat it into submission.
>>6
Is it possible to cheat a bit and do this?
print(FD, get $UriImage);
...instead of the original two lines?
Sure. Actually, I think you're supposed to write it as
print FD get $UriImage;
With no comma or parentheses. I am not sure if your version also works, though.
getstore( $UriImage, "$ENV{HOME}/wakawall/wakawall.jpg" );
This is assuming you already have a ~/wakawall directory.