Missing warning(s)

--Sig_/rgYTwq_QFOJccBd18Ia9Aa_
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable

-- not enough: no warning
$ perl -wE'use strict; $a =3D pack "s>s>s> s>", 1, 2, 3'

-- explicit undef: warning
$ perl -wE'use strict; $a =3D pack "s>s>s> s>", 1, 2, 3, undef'
Use of uninitialized value in pack at -e line 1.

So, what is the difference? Why does the first *not* warn?

Likewise

-- not enough: no warning
$ perl -wE'use strict; my @v =3D (1..3); $a =3D pack "s>s>s> s>", @v'

-- too many: no warning
$ perl -wE'use strict; my @v =3D (1..5); $a =3D pack "s>s>s> s>", @v'

-- explicit undef: warning
$ perl -wE'use strict; my @v =3D (1..3,undef); $a =3D pack "s>s>s> s>", @v'
Use of uninitialized value $v[3] in pack at -e line 1.

It took my hours to find why

 my @v =3D unpack "..... s>s>s>" =3D> $input;

 had three trailing zeroes where the value was generated in another
 process passing it through a pipe

 $input =3D pack "..... s>s>s>", @values;

and @values was missing the three last values

--=20
H.Merijn Brand  http://tux.nl   Perl Monger  http://amsterdam.pm.org/
using perl5.00307 .. 5.31      porting perl5 on HP-UX, AIX, and Linux
https://useplaintext.email  https://tux.nl  http://www.test-smoke.org
http://qa.perl.org   http://www.goldmark.org/jeff/stupid-disclaimers/

--Sig_/rgYTwq_QFOJccBd18Ia9Aa_
Content-Type: application/pgp-signature
Content-Description: OpenPGP digital signature

-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEEGolmczWuFi3lJEbAA6FHoT5dwJgFAl3D85UACgkQA6FHoT5d
wJgr5AgAoCZPufZOXCXhYrzTvrx5Dfr4poTG3B1TTRZ304YX+s924rb/I+gAMnqr
JOX/W01U6xRHZ5qVHANGAGmJ9wmEL3M70zfM+HTAYG1CBiWERybOP8bGofXupAse
3BfvWrG1quizsWlognSNCl5kQ1LmR+IXMRGHtUAJO5+eScmjwQQBDFaKMtmxI6Rs
hBlgRq7PaeDMdpqSzAKNqaFUE8efvcY9BG3viwD55AesNjPZOjIZj95QdNhSgb6Y
5QuJbUj4vaR+3OMsyQOHSR9fViMm0YfkixmUiNfwlbre1hy970kJR32ZAlkceGNx
Sxi9jpR7GU/xTLQ9O2WrBvglElWYSQ==
=hfCB
-----END PGP SIGNATURE-----

--Sig_/rgYTwq_QFOJccBd18Ia9Aa_--
0
h
11/7/2019 10:36:04 AM
perl.perl5.porters 47862 articles. 1 followers. Follow

0 Replies
7 Views

Similar Articles

[PageSpeed] 59

Reply: