asdfghjkl has asked for the wisdom of the Perl Monks concerning the following question:

this code promts for the arguments when excecuted.instead of prompting out help me out with a code by giving the arguments on the command line when exceuting the code it self i.e ./code arg1(source) arg2(dest)
#!/usr/bin/perl use strict; use warnings; use File::Copy; use File::Spec; my $dest="...."; print "the source direcotry name: \n"; my $source = ''; chomp($source = <STDIN>); if (opendir(my $DIR, $source)){ my @files = grep { /\.log$/ } readdir ($DIR); foreach my $f (@files){ my $src = File::Spec->catfile($source , $f); my $dst = File::Spec->catfile($dest , $f); copy($src , $dst) or die "Failed to copy $src to $dest ($!)\n" +; } closedir ($DIR); } else { warn "Failed to open '$source ' for reading ($!)\n"; }

20071110 Edited by Co-Rion: Restored content

Replies are listed 'Best First'.
Re: command line invocation
by dwu (Monk) on Nov 05, 2007 at 02:00 UTC