ALL,
I have following:
This is perl 5, version 26, subversion 3 (v5.26.3) built for x86_64-linux-thread-multi
(with 57 registered patches, see perl -V for more detail)
Copyright 1987-2018, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
And the script I'm using have given
and when
.
Trying to Google I found this, which says it will be changed in an incompatible way.
I'm on RHEL8 and moving forward.
I'd like to fix the script, so that other get advantage of the script as well and don't see those warnings anymore.
How do I rewrite it to get rid of the warning?
TIA!
EDIT:
Sorry for not being explicit enough - by fixing the script I meant eliminating the problematic call/rewriting it.
EDIT2:
given($pl) {
when(0) { print "A"; }
when(1) { print "B"; }
when(2) { print "C"; }
when(3) { print "D"; }
when(4) { print "E"; }
default { print "Illegal "; }
}
where $pl
is just an integer (unsigned short in C).
The script reads some data from the file. The file contains some hex values. Those values are parsed - some bits are extracted ` and then the string representation of those bits are printed on screen.
EDIT3:
I tried to use following code:
my %table_pl = (
0 => sub { print "A"; },
1 => sub { print "B"; },
2 => sub { print "C"; },
3 => sub { print "D"; },
4 => sub { print "E"; },
);
for $pl( 0..5 )
{
if( exists $table_pl{$pl} )
{
$table_pl{$pl}->();
}
else
{
print "Illegal ";
}
}
but I got an error:
Number found where operator expected near 1
(Missing semicolon on the previous line?)