> -----Original Message-----
> From: Nikola Janceski [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, August 14, 2002 2:54 PM
> To: Beginners (E-mail)
> Subject: possible RFC?
> 
> 
> WTF doesn't perl -c check for valid subroutines/function calls?
> 
> I can write a perlscript calling a function that doesn't 
> exist but perl -c
> will say syntax ok.
> ie:
> % perl -ce "nothing_here('some junk')"
> -e syntax OK
> 
> % perl -e "nothing_here('some junk')"
> Undefined subroutine &main::nothing_here called at -e line 1.
> 
> That doesn't make sense!
> It should check function calls at compile time, correct?

No, otherwise CGI.pm and tons of other stuff would never work.

> So why not for -c?

Consider the following program:

  $_ = 'sub foo { print "Hello World\n" }';
  eval $_;
  foo();

foo() is not defined a compile-time, but it's still a perfectly valid
program. Because of this, perl -c cannot check the call to foo() at
compile-time.

Thinking of perl -c as a "compiler" is a bit of a misnomer. Just for kicks,
wrap the code above in a BEGIN { } block and run perl -c on it. See what I
mean?

> 
> Excuse me if I have overstepped my bounds. I still love Perl 
> regardless, but
> it can be better.

No way! :~)

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to