Anarion has asked for the wisdom of the Perl Monks concerning the following question:

Playing at some ofu i find something i doesn't understand, perhaps someone can enlight me:

This, prints nothing:
perl -lwe '*c=*!;print %c'
Anyone knows why ?



Replies are listed 'Best First'.
Re: special magic in "%!" ?
by Hofmator (Curate) on Mar 08, 2003 at 15:46 UTC
    The question is: What are you expecting it to print? If you are expecting a 'used only once' warning, these don't show up for all the special variables composed of only a special char, like %! or %^ or @# ...

    -- Hofmator

      I was expenting to print the same than:
      print %!


        Aha, which it doesn't do here. As was figured out in the meantime here in this thread this behaviour changed between perl 5.6 and 5.8. And as you can guess by now, I'm on 5.6 :) - therefore my question. I get the same results as bbfu below.

        -- Hofmator

Re: special magic in "%!" ?
by janx (Monk) on Mar 08, 2003 at 17:26 UTC
    %! (aka %ERRNO) is only defined if you use Errno;

    Thus, %c cannot be defined either and does not become anything special when you print it.



      The reference to %! requires Errno.pmc, then if that fails,


      perl -le 'print for keys ::'
      perl -le 'print for keys(%!); print for keys ::'
      update: This is perl, v5.8.0 built for i686-linux
        You are rigth, thx :)
        It loads some modules if you use %!:
        lorien:~$ perl -le 'print %INC' lorien:~$ perl -le '%!;print %INC' +.0/ +perl/5.8.0/

      The keys of the hash are defined:

      lorien:~$ perl -v This is perl, v5.8.0 built for i386-linux-thread-multi
      Well its just for fun when i read in perlvar about %! and the last news about sendmail and bind it just comes to my head, ode to sendmail and bind here it is.


        My perl doesn't do that.

        [johnsca@CORY johnsca]$ perl -wle 'print %!' [johnsca@CORY johnsca]$ perl -wle '*c=*!; print %c' [johnsca@CORY johnsca]$ perl -wle 'use Errno; print %!' ECOMMOEPIPE ...(etc) [johnsca@CORY johnsca]$ perl -wle 'use Errno; *c=*!; print %c' ECOMMOEPIPE ...(etc) [johnsca@CORY johnsca]$ perl -v This is perl, v5.6.1 built for cygwin-multi ...(etc)

        And I get the same results for my ActiveState Perl 5.6.1.

        Black flowers blossum
        Fearless on my breath


        My bleadperl does the same thing. I'm currently looking into it.
        This behaviour seems to have changed between 5.6 and 5.8.


        Exactly the same for me on Darwin.

        Anarion could you provide the complete script?
        Maybe we can work that one out.