473,574 Members | 2,510 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

uninitialized value in pattern match


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.


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

print redirect( "http://localhost/cgi-bin/auto/submitReport.ht ml")
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_na me.</p>";

if ($visitor_email = ~ /^\w+$/ ) {
print "<p>E-mail: \L\u$visitor_em ail.</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"
<html xmlns="http://www.w3.org/1999/xhtml"
lang="en-US"><head><titl e>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.

Jul 19 '05 #1
1 15523
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.
Use of uninitialized value in pattern match (m//) at
submitReport.pl line 22.


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

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 uninitialized value in concatenation (.) at register.pl line 38, <STDIN> line 10." The PERL code is as follows:
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" />
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 bunch of hits with this - I'm only interested in the *last* one. Is there a way to build the concept "last" into the
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 write to get the value "xyz" into a string?
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 seperated tokens. I want to write a VB function that when passed a matching left side identifier, returns it's assigned value. If none match, returns...
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 line 342, <STDIN> line 2. Argument "neopets.com/hi.phtml" isn't numeric in numeric ne (!=) at NQII.pl line 342, <STDIN> line 2. Argument "POST" isn't...
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 /d/d/d/s/d/d in any text. There could be spaces in front or after the pattern (the nnn nn could be without spaces also) but it shouldn't pick it up in...
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 pattern is going to make sure that I don't get match of ddd dd embeded in number. For example
by: zcabeli | last post by:
Hi my $x = "1-6"; if ($x =~ /^\s*(+)\-(+)$\s*$/) { print "SUCCEED \n"; } else { print "FAILED \n"; }
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.