CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
error: explicit package name

 



dalehend
stranger

Feb 1, 2001, 7:27 PM

Post #1 of 3 (928 views)
error: explicit package name Can't Post

I am trying to run a test script using a module HTML::Pager that has 'use
strict'.
It does not like the callback subroutine although it is declared
The error msg with the script after:

syntax error at testPager2.pl line 25, near "my "
Global symbol "$get_data_sub" requires explicit package name at
testPager2.pl line 25. Execution of testPager2.pl aborted due to
compilation errors.



#!/usr/bin/perl -w
use HTML::Pager;
use CGI;
use strict;
local $SIG{__WARN__} = \&Carp::cluck;

my $pager;
# my $get_data_sub;
# get CGI query object
my $query = CGI->new();

# create a callback subroutine to generate the data to be paged
my $get_data_sub = sub {
my ($offset, $rows) = @_;
my @return_array;

for (my $x = 0; $x < $rows; $x++) {
push(@return_array, [ time() ]);
}
return \@return_array;
}


# create a Pager object
my $pager = HTML::Pager->new( query => $query, get_data_callback =>
$get_data_sub, rows => 100, page_size => 10, debug => 1);


# make it go - send the results to the browser.
print $pager->output;







RFQ Project Developer


Jasmine
Administrator / Moderator

Feb 1, 2001, 8:41 PM

Post #2 of 3 (925 views)
Re: error: explicit package name [In reply to] Can't Post

You're missing the ; at the end of the anonymous sub:


Code
# create a callback subroutine to generate the data to be paged 
my $get_data_sub = sub {
my ($offset, $rows) = @_;
my @return_array;

for (my $x = 0; $x < $rows; $x++) {
push(@return_array, [ time() ]);
}
return \@return_array;
}; # <--- missing ;



dalehend
stranger

Feb 1, 2001, 9:08 PM

Post #3 of 3 (924 views)
Re: error: explicit package name [In reply to] Can't Post

thanks

RFQ Project Developer

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives