Sonika Sachdeva wrote:
> Hi List,
Hello,
> I have a perl program scheduled to do some processing and generate
> output as
> .zip files ( activeState perl on WinXP)
> Now the last part of the program moves .zip files from
> c:\<folder1> to samba share 'S:\<folder2>'
> Though there is no error reported , but it actually doesn't move the files.
> What could be the reason ?
You have to specify the file name for the destination as well as the source.
> Following is the subroutine for moving the file
>
> sub copyFile($$) {
Your subroutine _moves_ files, it does not _copy_ files, so why is it named
'copyFile'? You really, really shouldn't use prototypes. If you need to
verify the number of arguments you could do something like:
sub moveFile {
unless ( @_ == 2 ) {
warn 'Sub moveFile expected 2 arguments but was called with ' . @_ . "
arguments.\n";
return;
}
> my $filename = shift;
> my $destination = shift;
>
> $destination = $log if ( !( -d $destination ) );
> return if ( !( -s "$SRCDIR\\$filename" ) );
Where are $log and $SRCDIR defined? You should pass this data to the sub
instead of using globals. Why all the parentheses?
$destination = $log unless -d $destination;
return unless -s "$SRCDIR/$filename";
> if ( ( -s "$SRCDIR\\$filename" ) && ( -d $destination ) ) {
> my $return = File::Copy::move( "$SRCDIR\\$filename", $destination );
You have to include the file name in the destination:
my $return = File::Copy::move( "$SRCDIR/$filename",
"$destination/$filename" );
> if ( $return != 1 ) {
You shouldn't use "magic numbers" like that, just test for true or false.
unless ( $return ) {
> logmsg( *LF, "Copy Error ", $filename, $destination, "$!" );
*LF is another global that you should pass to the subroutine.
> return;
> }
> } # end if for -s and -d
> }
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>