Solved

Module definition problem

Posted on 2002-07-20
2
187 Views
Last Modified: 2010-03-05
I'm trying to define a module:

package Foo;

use strict;

require Exporter;

our @ISA = qw(Exporter);
our @EXPORT = qw(bar);
our $VERSION = "1.0";

sub bar() {
    my $val = shift;

    print $val;
}

1;

However when I try to use the bar function as follows:

use strict;

use lib 'E:/Programming/Perl/libs';
use Foo;

bar("Test");

I get the following error:

Too many arguments for Foo::bar at test.pl line 6, near ""Test")"
Execution of test.pl aborted due to compilation errors.

What's going on here?
0
Comment
Question by:derekl
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 100 total points
Comment Utility
You used the prototype bar() which means that bar has no arguments.
You probably wanted either

sub bar($) {
    my $val = shift;
    print $val;
}

or

sub bar {
    my $val = shift;
    print $val;
}
0
 

Author Comment

by:derekl
Comment Utility
Thank I would have stared at that for 4 or 5 more hours before picking it up.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now