
maciejp
New User
May 1, 2013, 1:30 AM
Post #1 of 7
(1691 views)
|
Passing arguments to module's function
|
Can't Post
|
|
Hello. First of all sorry about my English. I'm trying to write a new module to my program with one function and two arguments from main script: $Mail, $Haslo. Here's code: Module:
package Own::database; use locale; use strict; use warnings; use CGI ':standard'; use Spreadsheet::ParseExcel; require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(check_base); sub check_base { my($Mail, $Haslo) = @_; my $q = new CGI; my $parser = Spreadsheet::ParseExcel->new(); my $workbook = $parser->parse('baza.xls'); if ( !defined $workbook ) { die $parser->error(), ".\n"; } my $worksheet = $workbook->worksheet(0); my $pomocnicza=0; my ( $row_min, $row_max ) = $worksheet->row_range(); for my $row ( $row_min .. $row_max ) { if ($row == $row_max) {$pomocnicza=1}; my $cell = $worksheet->get_cell($row, 0); my $value = $cell->value(); if ($value eq $Mail) { my $cell = $worksheet->get_cell( $row, 1); my $value = $cell->value(); if ($value eq $Haslo) { return 1; last; } } else { return 0; } } } 1; Script
#!C:\Strawberry\perl\bin\perl -w use locale; use strict; use warnings; use CGI ':standard'; use Spreadsheet::ParseExcel; use Own::database; my $q = new CGI; my $Mail = $q->param('mail'); my $Haslo = $q->param('haslo'); my $checked = check_base($Mail, $Haslo); if ($checked) { print redirect('http://localhost/zalogowano.html'); } else { print header(-type=>"text/html; charset=ISO-8859-2"); print start_html(-title=>'Organizer', -lang=>'pl-PL', -encoding=>'ISO-8859-2'); print '<form action="/cgi-bin/logowanie.cgi" method="post">'; print 'Adres e-mail: '; print '<br>'; print textfield(-name=>'mail', -size=>15, -maxlength=>30); print '<br>'; print 'Hasło: '; print '<br>'; print textfield(-name=>'haslo', -size=>15, -maxlength=>30); print '<br>'; print submit(-name=>'Logowanie', -value=>'Zaloguj'); print '</form>'; print '<form action="http://localhost/index.html" method="link">'; print submit(-name=>'przypomnienie', -value=>'Przypomnij hasło', -action=>'przypomnienie.cgi'); print '</form>'; print '<font color="red"> Błędne dane logowania.</font>'; print '<br>'; print a({ -href=>'http://localhost/rejestracja.html'}, 'Rejestracja'); print end_html; } I'm still getting error:
Use of uninitialized calue $Mail in string eq at../module.pl line 38. I can't find mistake but my perl programming ability isn's as good as it should. Can you help me, what is wrong?
|