Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
How to pass arguments to subroutines of another package?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Babaloogats  
View profile  
 More options Oct 9, 2:13 am
From: Babaloogats <babaloog...@gmail.com>
Date: Thu, 8 Oct 2009 23:13:48 -0700 (PDT)
Local: Fri, Oct 9 2009 2:13 am
Subject: How to pass arguments to subroutines of another package?
I'm having problems when I try to pass an argument to a subroutine
that I defined in a package that's in another file.

I defined the package as this:


package MyPackage_1;

# Set the Exporter so functions can be called in other areas
BEGIN
{
   use Exporter();
   @ISA = qw(Exporter);
   @EXPORT = qw (&PrintVar);

}

sub PrintVar()
{
  my $st = @_[0];
  print "String: $$st \n";

  return 1;

}

return 1;
<<

The package is in MyPackage_1.pm

I now call the PrintVar() function from my main script like this:

>> Code >>

#!/usr/bin/perl

# My own modules
use MyPackage_1;

my $teststring = "Hello there!";

$ret = Browser::PrintVar (\$teststring);

<<

The main script (above) is in a file called getPIN.pl

I try checking for syntax errors before executing so I issue a perl -c
against my file.  The MyPackage_1.pm file compiles correctly but I get
an error against the getPIN.pl file:

root@Ubuntu:/home/perl# perl -c getPIN.pl
Too many arguments for MyPackage_1::PrintVar at getPIN.pl line 90,
near "$teststring)"

What am I doing wrong here?  Can I pass arguments thru the stack "@_"
to PrintVar() as if it was a subroutine defined in the main perl file?

Thanx,
Baba


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google