473,725 Members | 2,409 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 15534
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 "Error No Match"
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 numeric in numeric eq (==) at NQII.pl line 343, <STDIN> line 2. Argument "POST" isn't numeric in...
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 case like this 1234 56768
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: 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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.