Hello again brethren, Having dealt with the file-writing problem with your help, Im confronted with confusing error messages concerning my regexps to remove letter-spacing and word-spacing attributes from my in-document style sheet. The code's clunky but it's just a little test of my budding regexps. What am I missing?! Could someone explain why this is occuring? Here are the error messages and the code:
use of unintialised value in pattern match (m//)... An undefined value was used as if it were already defined
#!/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 +"; }
Many thanks for your wisdom and time! Tricky

In reply to Regexp conundrum by Tricky

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.