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

Hi all, just trying to print the size of a ftp'd file.

for $file (@files) { $ftp->get($file) and $ftp->delete($file); $remotesize = $ftp->size($file); $localssize=(stat ($file))[7]; print "$file $localsize $remotesize $theGMTime"; #<-line 25 }

but it throws " Use of uninitialized value in concatenation (.) or string at -e line 25" and the remotesize and localsize has no value

Replies are listed 'Best First'.
Re: NEWBIE: posible sintax error
by FunkyMonk (Bishop) on Jul 02, 2010 at 16:32 UTC
    $localssize=(stat ($file))[7]; # ^^ print "$file $localsize $remotesize $theGMTime"; #<-line 25 # ^

    Of course

    use strict; use warnings;

    would have found that for you!

      Thanks funky, i'm really tire seeing that code, i never saw the differences you point. thanks again

        That's exactly why strict and warnings are so important. Use them, and they'll find errors for you!
Re: NEWBIE: posible sintax error
by johngg (Canon) on Jul 02, 2010 at 16:31 UTC

    The first thing that strikes me is that you get the file then delete it from the remote host and, only after it has been deleted, then try to size a file that no longer exists.

    Cheers,

    JohnGG

      Thanks, i'd never figure out. that was deleted...

Re: NEWBIE: posible sintax error
by zek152 (Pilgrim) on Jul 02, 2010 at 16:37 UTC

    More information would be useful. What module are you using for the ftp interface? Also the line $ftp->get($file) and $ftp->delete($file); struck me as odd. Again as I do not know what module you are using I can't say for sure but it seems like you wouldnt want to get and delete the file before you do anything.

    Also for future reference, please spend five seconds doing a simple proofreading of your post. When 50% of your title is misspelled and 25% is all capitalized many monks will answer other people's questions first.

      I'm very sorry zek152, being newbie doesn't excuse me. thanks for your suggestions.