Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

special magic in "%!" ?

by Anarion (Hermit)
on Mar 08, 2003 at 15:25 UTC ( [id://241395]=perlquestion: print w/replies, xml ) Need Help??

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 ?

$anarion=\$anarion;

s==q^QBY_^=,$_^=$[x7,print

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 %!

      $anarion=\$anarion;

      s==q^QBY_^=,$_^=$[x7,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.

    Regards,

    janx

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

      Compare:

      perl -le 'print for keys ::'
      to
      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' strict.pm/usr/share/perl/5.8.0/strict.pmExporter.pm/usr/share/perl/5.8 +.0/Exporter.pmConfig.pm/usr/lib/perl/5.8.0/Config.pmErrno.pm/usr/lib/ +perl/5.8.0/Errno.pm
        $anarion=\$anarion;

        s==q^QBY_^=,$_^=$[x7,print
      The keys of the hash are defined:
      lorien:~$ perl -le 'print %!' EBADR0ENOMSG0ENOTSUP0ESTRPIPE0EADDRINUSE0EL3HLT0EBADF0ENAVAIL0ECHRNG0E +NOTBLK0ENOTNAM0ELNRNG0EXDEV0EBADE0EBADSLT0ECONNREFUSED0ENOSTR0EISCONN +0EOVERFLOW0ENONET0EFBIG0ECONNRESET0ELIBMAX0EWOULDBLOCK0EREMOTEIO0ENOP +KG0ELIBSCN0EMEDIUMTYPE0EDESTADDRREQ0ENOTSOCK0EIO0EINPROGRESS0ERANGE0E +ADDRNOTAVAIL0EAFNOSUPPORT0EINTR0EILSEQ0EREMOTE0ENOMEM0ENETUNREACH0EPI +PE0ENODATA0EUSERS0EOPNOTSUPP0EPROTO0EISNAM0ESPIPE0EALREADY0ENAMETOOLO +NG0ENOEXEC0EISDIR0EBADRQC0EEXIST0EDOTDOT0ELIBBAD0ESRCH0EFAULT0EAGAIN0 +EDEADLOCK0EXFULL0ENOPROTOOPT0ENETDOWN0EPROTOTYPE0EL2NSYNC0ENETRESET0E +ADV0EUCLEAN0EROFS0ESHUTDOWN0EMULTIHOP0EPROTONOSUPPORT0ENFILE0ENOLCK0E +CONNABORTED0ECANCELED0EDEADLK0ENOLINK0ESRMNT0ENOTDIR0ETIME0EINVAL0ENO +TTY0ENOANO0ELOOP0ENOENT0EPFNOSUPPORT0EBADMSG0ENOMEDIUM0EL2HLT0EDOM0EB +FONT0EMSGSIZE0ENOCSI0EL3RST0ENOSPC0EIDRM0ENOBUFS0ENOSYS0EHOSTDOWN0EBA +DFD0ENOSR0ENOTCONN0ESTALE0EDQUOT0EMFILE0EACCES0EBUSY0EPERM0E2BIG0ELIB +EXEC0ETOOMANYREFS0ELIBACC0ENOTUNIQ0ECOMM0ERESTART0EUNATCH0ESOCKTNOSUP +PORT0ETIMEDOUT0ENXIO0ETXTBSY0ENODEV0EMLINK0ECHILD0EHOSTUNREACH0EREMCH +G0ENOTEMPTY0

      Update:
      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.
      $anarion=\$anarion;

      s==q^QBY_^=,$_^=$[x7,print

        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.

        bbfu
        Black flowers blossum
        Fearless on my breath

        Ok!

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

        janx

        Exactly the same for me on Darwin.

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

        janx

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://241395]
Approved by Tomte
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-23 22:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found