Advertisement

05.09.2008 at 07:29AM PDT, ID: 23389456
[x]
Attachment Details

passing variables between calling program and package

Asked by kathys39 in Perl Programming Language

Tags: ubuntu, perl, 5.8.8

I'm running perl 5.8.8 on Ubuntu 7.10.

I have a basic perl script, checkdir.pl that checks a directory for files, parses them, then moves them.  I get the list of filenames in the directory ok, the problem comes in when I pass the filename to the parser pubroutine, located in a package in another file.  

My initial checkdir.pl file includes the following:
[code]
   use Parse;
.....
 print "Processing file...$file\n";   -> $file is correct at this point....
 ($return) = Parse::parse_file($file);
....

In File 2, Parse.pm, I have the following:

package Parse;
use vars qw($file, $date);
print "Entering parse\n";  -> ok until here

sub parse_file {
   print "file is $file\n";   -> $file is NOT correct here - it is blank
.....
  return $file, $date;
}


My output shows the filename is correct in the first file, but is not getting passed to the sub parse_file, in the package Parse.  Can anyone see what I am doing wrong??Start Free Trial
[+][-]05.09.2008 at 07:40AM PDT, ID: 21533292

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.09.2008 at 07:51AM PDT, ID: 21533422

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.09.2008 at 08:23AM PDT, ID: 21533787

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Perl Programming Language
Tags: ubuntu, perl, 5.8.8
Sign Up Now!
Solution Provided By: Adam314
Participating Experts: 1
Solution Grade: B
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628