Tricky has asked for the wisdom of the Perl Monks concerning the following question:
use of unintialised value in pattern match (m//)... An undefined value was used as if it were already defined
Many thanks for your wisdom and time! Tricky#!/usr/bin/perl # read letter and word spacing attributes.plx # Program will read in an html file, scan for word and letter spacing +attributes # and print out entire doc. # 1. No need for file variable yet: open (INFILE, "<".$htmlFile) or di +e("Can't read source file!\n"); use warnings; use diagnostics; use strict; # Declare and initialise variables. my $pattern1 =~ /(word)-(spacing):\s*[\d]+px/; # word spacing regexp my $pattern2 =~ /(letter)-(spacing):\s*[\d]+px/; # letter spacing re +gexp my @htmlLines; # Open HTML test file and read into array. open INFILE, "E:\\Documents and Settings\\Richard Lamb\\My Documents\\ +HTML\\test2InDocCSS.html" or die "Sod! Can't open this file.\n"; @htmlLines = <INFILE>; close (INFILE); while(@htmlLines) { # check for word spacing attributes in array sub wordSpacing { foreach my $line (@htmlLines) { if(/$pattern1 && $pattern2/) { printHTML(); } else { notFound(); } } } } # prints the reformatted HTML doc sub printHTML { for my $i (0..@htmlLines-1) { print $htmlLines[$i]; print "Success!\n"; } } # Prints error message sub notFound { print "Letter and word spacing attributes note found in HTML file.\n +"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regexp conundrum
by Abigail-II (Bishop) on Aug 19, 2003 at 15:26 UTC | |
by Tricky (Sexton) on Aug 22, 2003 at 10:15 UTC | |
by Abigail-II (Bishop) on Aug 22, 2003 at 10:34 UTC | |
|
Re: Regexp conundrum
by Limbic~Region (Chancellor) on Aug 19, 2003 at 15:27 UTC | |
by Tricky (Sexton) on Aug 22, 2003 at 09:38 UTC | |
|
Re: Regexp conundrum
by batkins (Chaplain) on Aug 19, 2003 at 15:30 UTC | |
by Tricky (Sexton) on Aug 22, 2003 at 09:26 UTC |