The script begins:
>
> #!/usr/bin/perl
>
> use Tie::File;
> use File::Copy 'copy';
> use File::Spec;
>
>


I think this problem becomes much clearer if you enable strict.

-- [ A.pl ] ---
my @list = qw( a b c );

print "X $list Y";

-- [ A.pl  output ] --
X Y

-- [ B.pl ] --
use strict;

my @list = qw( a b c );

print "X $list Y";
-- [ B.pl output ]--

Global symbol "$list" requires explicit package name at /tmp/nostrict.pl
line 6.
Execution of /tmp/nostrict.pl aborted due to compilation errors.

---


What you meant to do, I imagine, is this:


-- [ C.pl ]--

use strict;

my @list = qw(a b c);

print "X " . @list . " Y";

-- [ C.pl output ]--

X 3 Y

-----

Or perhaps:

--- [ D.pl ]---

use strict;

my @list = qw(a b c);

print "X $#list Y";  # last item number, not length

--- [ D.pl output ]--
X 2 Y

----


So unless there's deleted code we're not seeing, this does indeed seem to
reaffirm the mantra "use strict; use warnings, and let perl tell you what
is wrong" =)



-- 
Kent

*KENTNL* - https://metacpan.org/author/KENTNL

Reply via email to