Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Re: Re: syntax error with constant

by TomDLux (Vicar)
on Aug 04, 2003 at 01:08 UTC ( [id://280535]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: syntax error with constant
in thread syntax error with constant

But why does it happen with multi-character constant names?

DB<1> use constant foo => 1 DB<2> print 1-foo Ambiguous use of -foo resolved as -&foo() at (eval 15)[/usr/lib/perl5/ +5.8.0/perl5db.pl:17] line 2. eval '($@, $!, $^E, $,, $/, $\\, $^W) = @saved;package main; $ +^D = $^D | $DB::db_stop; print 1-foo; ;' called at /usr/lib/perl5/5.8.0/perl5db.pl line 17 DB::eval called at /usr/lib/perl5/5.8.0/perl5db.pl line 1323 DB::DB called at -e line 1 0

Same thing happens with FOO.

I don't encounter this problem, because I put spaces between terms and operators. Insert invisible 'nyah nyah' here

--
TTTATCGGTCGTTATATAGATGTTTGCA

Replies are listed 'Best First'.
Re: Re: Re: Re: syntax error with constant
by liz (Monsignor) on Aug 04, 2003 at 07:30 UTC
    I think the issue that is resolved has to do with my original assessment:

    What I think happens is that the parser gets confused with trying to handle the:

    -key => value
    notation.

    The warning does not occur when you have "-foo()" because the parentheses indicated a subroutine call. However, without it, "-foo" could still be a key specification. So the parser must take that into account after parsing -foo. Then it hits the ";" and it can resolve the issue. Although in this case strictly speaking, I don't see an ambiguity. So the warning seems superfluous to me.

    I guess a p5per with more perl internals knowledge should speak up ;-)

    Liz

Re: Re: Re: Re: syntax error with constant
by sgifford (Prior) on Aug 04, 2003 at 06:56 UTC
    Huh, that's interesting. I get the same thing if I use quux as a constant, even though -q isn't a filetest operator. And this contradicts the documentation given by perldoc -f -X:
    Note that "-s/a/b/" does not do a negated substitution. Saying "-exp($foo)" still works as expected, however--only single letters following a minus are interpreted as file tests.

Log In?
Username:
Password:

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

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

    No recent polls found