in reply to Re^2: ::'s role in strings
in thread ::'s role in strings

I used 5.6.1.

a: Undefined variable.

I'm susprised by the output you get. Is that really what you got for output? from perl? No, it's from your shell. Use single quotes.

Why does/should this work?

It's probably just an unintentional side-effect. It's to avoid ambiguitities when using indirect method calls. I wouldn't use :: as a quoting mechanism.

Updated: Thanks to japhy and jhourcle for the corrections/elaborations.

Replies are listed 'Best First'.
Re^4: ::'s role in strings
by japhy (Canon) on Apr 27, 2006 at 19:05 UTC
    It works so that you can write:
    use Foo; # defines Foo::new() among others sub Foo { "Oh no, Mr. Bill!" } $x = new Foo::;
    because $x = new Foo would NOT work under those circumstances.

    Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
    How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart
Re^4: ::'s role in strings
by eff_i_g (Curate) on Apr 27, 2006 at 19:47 UTC
    Oops. The shell problem should have been obvious--sorry about that. Thanks for clearing this up everyone.
Re^4: ::'s role in strings
by jhourcle (Prior) on Apr 27, 2006 at 19:18 UTC

    I'm not surprised at all. Double quoted strings are bad in some shells, as '$a' might be processed by the shell, not by perl, therefore, might result in a shell error.

    $ perl -v This is perl, v5.8.6 built for darwin-thread-multi-2level (with 2 registered patches, see perl -V for more detail) ... $ perl -e "$a = Class::; print $a" syntax error at -e line 1, near "=" Execution of -e aborted due to compilation errors. $ perl -e '$a = Class::; print $a' Class

    Update: inserted word 'some'

      Double quoted strings are bad in shells, as '$a' might be processed by the shell,

      That bit is false. Double quotes are required by my shell. $ does not have a special meaning for it, and single-quoting the argument does not work. Your statement should read:

      Double quoted strings are bad in some shells, as '$a' is processed by them,

      I'm sure you're right that double-quoted strings are bad for his shell (and it, not perl, produced the error he posted).