Here is the code that is not working
#!/usr/bin/perl
use diagnostics;
use strict;
...
my $dud1 = "dud1";
my $dud2 = "dud2";
my $w_player = "?";
my $n_player = "?";
my $e_player = "?";
my $s_player = "?";
# $_ = $Board_1[3];
$_ = " H K53 deloresg Bills Hank99
Pellinor";
if (/\s*(\w+)\s*(\w+)\*(\w+)\s*(\w+)\s*(\w+)\s*(\w+)/i) {
$dud1 = $1;
$dud2 = $2;
$w_player = $3;
$n_player = $4;
$e_player = $5;
$s_player = $6;
}
The program runs to completion with this block of code included.
After the program ends diagnostics complains that the program tried to
print $dud2 which had not been initiated. The other match variables
print with their assigned initiated values.
My system is Debian Wheezy with perl 5.14.2-21 installed.
I am working from Learning Peal, 4th ed, which says it is updated to perl 5.8.
Page 113 includes an example using the match variables $1, $2, and $3.
That code works perfectly. Since it used \S+ for not-whitespace words I
tried this in my code with the same problem as with \w+
I would apprecite any resolution of this problem and any recommendations
to improve the code.
Tom George
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/