in reply to Re^6: Warnings on unused variables?
in thread Warnings on unused variables?

Turns out it was easy to install on my Windows machine. It stops behaving "properly" when the eval is in a function. Warnings for both $foo and $bar are emitted as soon as the function is compiled.
#!/usr/bin/perl use warnings; use warnings::unused; use strict; BEGIN { print("1\n"); } sub foo { my $foo = 42; my $bar = 43; eval '$foo++'; print("4\n"); <>; # <-- Segfaults when this is executed. } # <-- Warns when this is compiled BEGIN { print("2\n"); } print("3\n"); foo(); print("5\n"); <>;

Replies are listed 'Best First'.
Re^8: Warnings on unused variables?
by AZed (Monk) on Sep 28, 2008 at 02:01 UTC

    ... very interesting. On my Debian box, I get a different result, with no segfault.

    1 Unused variable my $foo at ./warntest.pl line 9. Unused variable my $bar at ./warntest.pl line 10. 2 3 4 5

    The blank link after 4 and 5 indicate spots where I pressed return to get it to continue. Did it pass all of the tests in 'make test' in your build environment? My current Windows test box is running ActiveState, so I can't get it to build to test it myself there. One of these days after my current project is finished I plan to rip it out and try Strawberry again.

      I get a different result, with no segfault

      That's the same result, with no segfault

      My current Windows test box is running ActiveState

      Same here.

      Did it pass all of the tests in 'make test' in your build environment?

      Yes:

      Running make test Microsoft (R) Program Maintenance Utility Version 6.00.8168.0 Copyright (C) Microsoft Corp 1988-1998. All rights reserved. C:\Progs\perl588\bin\perl.exe "-MExtUtils::Command::MM" "-e" " +test_harness(0, 'inc', 'blib\lib', 'blib\arch')" t/*.t t/00_load............1/1 # Testing warnings::unused 0.01 t/00_load............ok t/01_unused..........ok t/02_used............ok t/03_in_mod..........ok t/99_pod-coverage....ok t/99_pod.............ok All tests successful. Files=6, Tests=20, 2 wallclock secs ( 0.11 usr + 0.05 sys = 0.16 CP +U) Result: PASS GFUJI/warnings-unused-0.01.tar.gz nmake test -- OK cpan[2]>

        Ah, that's the difference. I pulled down 0.02, you have 0.01. The segfault may have just been fixed, since that upload is new.