Automating Perl Script