in reply to Re: Calling package function returns 1, not data from function
in thread Calling package function returns 1, not data from function

#!/usr/bin/perl use warnings; use strict; sub latest { my $late = `ssh root\@10.10.21.15 'cat /usr/local/LATEST_VULN'` +; chomp($late); } print "$late\n";

The result of above script shows as:

<p>/Perl$ ./latest.pl Global symbol "$late" requires explicit package name at ./latest.pl li +ne 11. Execution of ./latest.pl aborted due to compilation errors.</p>

When I use undermentioned subroutine as updated by you, it displays error like this:

ERROR:

~/Perl$ ./latest.pl Global symbol "$late" requires explicit package name at ./latest.pl line 11. Execution of ./latest.pl aborted due to compilation errors.

#!/usr/bin/perl use warnings; use strict; sub latest { my $late = `ssh root\@10.10.21.15 'cat /usr/local/qualys/LATEST +_VULNSIGS'`; chomp($late); print "$late\n"; } return $late;
Please assist. I am sure I am doing some stupid mistake. Thanks!!!

Replies are listed 'Best First'.
Re^3: Calling package function returns 1, not data from function
by ikegami (Patriarch) on Dec 23, 2009 at 18:49 UTC
    You didn't follow the instructions. The sub should look like:
    sub latest { my $late = `ssh root\@10.10.21.15 'cat /usr/local/LATEST_VULN'`; chomp($late); return $late; }
    Nothing else should be changed. Well, ok, one thing.
    print $lat;
    should be changed to
    print "$lat\n";
      I got the solution.