Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Variables to a .pm file 1

Status
Not open for further replies.

skosterow

Technical User
Feb 23, 2002
135
US
The easiest way for me to exaplain this one is to give you guys and gals the script:

# Main File
#!/usr/bin/perl
use CGI qw:)standard escapeHTML);
use strict;
unshift(@INC, "subrutines/");
require subrutines;
<-- Unrelevant Script parts -->
$student_name = &quot;Scott&quot;;
&SUBRUTINES::EXAM_NAME ($student_name);
print &quot;Main Name: $student_name&quot;;
exit;
<-- Unrelevant Script parts -->


# subrutines.pm
sub EXAM_NAME {
package SUBRUTINES;
print &quot;Sub Name: $student_name&quot;;
}

1; Return true value

< END OF SCRIPTS >

Okay heres the delema, $student_name WILL NOT PRINT from the EXAM_NAME subrutine. This is the output:

Sub Name: Main Name: Scott

HELP HELP

I gave tried a few variations of sending the variable such as: &SUBRUTINES::EXAM_NAME (&quot;$student_name&quot;, $student_name);
and none seem to work.

Please help....

Scott


 
Try the following:
Code:
sub EXAM_NAME {
    my $student_name = @_;
    package SUBRUTINES;
    print &quot;Sub Name: $student_name&quot;;
  }

1; Return true value
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top