473,396 Members | 1,945 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

uninitialized value in pattern match

rk
Hi,

I'm a beginner for perl/cgi programs and i tried to write a cgi script
and when i ran it, i got the following error. But when i verified it
from the book i typed exactly whatever it is there and i checked other
examples too. I did't get any clue.Can someone please help me on this.

#!/usr/bin/perl

use warnings;
use strict;
use CGI qw( :standard );

print redirect( "http://localhost/cgi-bin/auto/submitReport.html")
unless para
m( "name" );

my $visitor_name = param("visitor_name");
my $visitor_email = param("visitor_email");
my $date = param( "date" );
my $time = param( "time" );

print header();

print start_html( -title => "Reports" );

if ( $visitor_name =~ /^\w+$/ ) {
print "<p>Name: \L\u$visitor_name.</p>";
}

if ($visitor_email = ~ /^\w+$/ ) {
print "<p>E-mail: \L\u$visitor_email.</p>";
}

if ( $date =~ m#^(1[012]|0?[1-9])/([012]?\d|3[01])/(\d\d)$# ) {
print "<p>Date: $1 / $2 / $3.</p>";
}

if ( $time =~ m#^(1[012]|[1-9]):([0-5]\d):([0-5]\d)$# ) {
print "<p>Time: $1: $2: $3.</p>";
}

print end_html();

---------------
Here are the errors i got.

perl submitReport.pl
Status: 302 Moved
location: http://localhost/cgi-bin/auto/submitReport.html

Content-Type: text/html; charset=ISO-8859-1

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"
"http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
lang="en-US"><head><title>Seahaven QA Status Reports</title>
Use of uninitialized value in pattern match (m//) at submitReport.pl
line 22.
Use of uninitialized value in pattern match (m//) at submitReport.pl
line 26.
Use of uninitialized value in pattern match (m//) at submitReport.pl
line 30.
Use of uninitialized value in pattern match (m//) at submitReport.pl
line 34.

Thanks,
rk
Jul 19 '05 #1
1 15504
rk wrote:

my $date = param( "date" );
my $time = param( "time" );
What's the point with submitting date and time? (You can have the
script grab them without input.)
Here are the errors i got.
<snip>
Use of uninitialized value in pattern match (m//) at
submitReport.pl line 22.


<snip>

Those are not errors. They are warnings, letting you know that the
submit form didn't include the expected fields.

A standard way to get rid of such warnings is to do:

my $visitor_name = param("visitor_name") || '';

etc., but that method should only be used when it's normal that a
variable else can be used without having been initialized. In this
case you'd better fix the submit form instead.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: G Kannan | last post by:
Hey all! I have written a perl script to retrieve information from a HTML Form and insert the data into an Oracle database table. I am gettting the the following error message: "Use of...
4
by: Pat Turner | last post by:
Hi, I have some XML like this: <family> <person name="bob"> <father ref="../../person" /> </person> <person name="charlie"> <child ref="../../person" />
8
by: sherifffruitfly | last post by:
Hi, I've been searching as best I can for this - coming up with little. I have a file that is full of lines fitting this pattern: (?<year>\d{4}),(?<amount>\d{6,7}) I'm likely to get a...
2
by: laredotornado | last post by:
Hi, I'm having trouble with preg_match. I want to get the value in parenthese from this pattern $pattern = "/ab(.*)cde/"; $str = "abxyzcde"; What preg_match expression would i have to...
5
by: jobs | last post by:
I've got a string that will look like this: zzz='hello',kkk='goodbye',jpjh='zz7t8d8',mary='Thank You',jane='idontwantthis',somethingelse='nothinghere' It will have undefined number comma...
6
by: samthemist | last post by:
When perl comes out with errors like this: Use of uninitialized value in concatenation (.) or string at NQII.pl line 18, <STDIN> line 2. Argument "" isn't numeric in numeric ne (!=) at NQII.pl...
19
by: konrad Krupa | last post by:
I'm not expert in Pattern Matching and it would take me a while to come up with the syntax for what I'm trying to do. I hope there are some experts that can help me. I'm trying to match...
3
by: konrad Krupa | last post by:
This message is a continuation of my previous post "Pattern Match" Doug - Thank you for your help. Doug Semler was able to solve my problem to some point but I still need some help. Doug's...
3
by: zcabeli | last post by:
Hi my $x = "1-6"; if ($x =~ /^\s*(+)\-(+)$\s*$/) { print "SUCCEED \n"; } else { print "FAILED \n"; }
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.