Good Afternoon Monks,
My question is not so much a question but an explanation is needed concerning the following code:
#!/usr/bin/perl -w use strict; use warnings; my $file = "data.txt"; local $^I = ".bak"; local @ARGV = ($file); while (<>) { chomp; my @field = split(':'); if ($field[1] =~ s/E/L/g) { print "$field[0]:$field[1]\n"; } elsif ($field[1] =~ s/L/E/g) { print "$field[0]:$field[1]\n"; } else { print "$_\n"; } } unlink("$file.bak"); print "UPDATED!!"; sleep 5; exit(); __DATA__ 1:E 2:L 3:L
As you can see once the code is executed it does change the L to an E and vice versa. My question is why is it saying use of uninitialized value in $field1 in substitution ring when in fact $field1 does have a value? Thanks for the clarification.
In reply to Uninitialized Value by PilotinControl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |