in reply to Re: eval segfaults when $@ isn't writable
in thread eval segfaults when $@ isn't writable

To set $! to a constant 1, you need to give the typeglob a reference to it:

What I meant was not to assign the constant 1 to $!, but to make $! an alias for $1, which is read only too:

*! = 1; "text" =~ /.(..)/; print "$!\n"; __END__ ex
It's notable that the typeglob assignment to constant destroys $!'s dual value magic:
$ perl -e'$! = 1; print "$!\n"'

I don't get this. There's no typeglob assignment in your example. Maybe a typo? If you meant *! = 2 then you'll get an alias for $2, as expected. So no $! magic. (Thank you anyway for remembering me that there's a CUFP I wanted to share :)).

--
David Serrano

Replies are listed 'Best First'.
Re^3: eval segfaults when $@ isn't writable
by Zaxo (Archbishop) on Jul 04, 2006 at 15:31 UTC

    The $! = 1; fragment was just to demonstrate the dual value magic - compare to the example before that.

    After Compline,
    Zaxo

      Then it isn't a typeglob assignment, and no magic is lost. This is the same code as yours, using errno 111 instead of 1:

      $ perl -e'$! = 111; print "$!\n"' Connection refused

      Either you were fooled by the "Operation not permitted" error (which is unlikely since it isn't a Perl error according to perldiag), or I still don't get your point.

      --
      David Serrano