Archive for January, 2012

Published by Pui-chor on 23 Jan 2012

Perl Program to auto-downloading from site

Just save this for my future reference. I have a bunch of file I like to use a program to download it rather than accessing the site and click download or right-click and then choose save and then enter the file name. This is the one:

#! /usr/bin/perl
use CGI qw(:standard);
use strict;
use LWP::UserAgent;

my $ua = new LWP::UserAgent;
my $url=’人-order.gif’;

my $request = new HTTP::Request(‘GET’, $url);
my $response = $ua->request($request);
my $content = $response->content();

print header(-type => ‘image/gif’);
print $content;


This program outputs the download but the download can be saved. Mulitple download can be done using a loop as long as there is a pattern for the name of the download.

Published by Pui-chor on 23 Jan 2012

Joining All MP3’s

I did not expect making one mp3 file from a bunch of mp3’s file is so easy. Just to save what is to be done with the perl code that I created in my cantonese site:

my $temp=$sounddir.”/temp”;
my $all=$FROM_IP.”_”.int(rand(100));
my $tempfile=$temp.”/$all.mp3″;
my $sounds=join(‘ ‘,@sndlist);
system(“cat $sounds > $tempfile”);
$text.=”<a id=’whole’ style=’display:none;’_href=’$all.mp3′>.</a>\n”;

I am using just a system cat command which appends one mp3’s content to another untile all file are put together in one single file. Same is for the text using cat command. If anyone does not know cat command will do in unix, you can search for it.