Rob Richardson wrote:
> Dave,
>
> Your response dovetails nicely with my next question.

I don't think the list has a response from Dave at the time of writing?

> The module I'm working in begins as follows:
>
> use warnings;
> use strict;
> use CGI qw/:standard center strong *big delete_all/;

'strong' and 'big' are exported by default as part of ':standard'.
'center' has to be imported explicitly.

> After putting parentheses after my calls to "br", the program compiled
> and started running.

Calls to 'br' shouldn't need parentheses. The subroutine is prototyped
and Perl knows what it is before you use it.

> It barfed, though, at the following line:
>
> $htmlString = p(center(strong("There are not any trains running on this
> day.<br>Use the date dropdowns above to select a different day.")));
>
> It complained that $Schedule::strong was undefined.  As you
> illustrated, changing "strong" to "CGI::strong" fixed that problem, and
> it proceeded to complain about "$Schedule::center" being undefined.

So after the code you show, you have a 'package Schedule'.

> I had thought that the "use CGI" line would tell Perl enough about
> those functions that I wouldn't have to qualify them.

Chris's response to your previous thread explained this. Your call to
'use CGI' imports the nmaes into 'main' - the default package before
you declare anything different. You then have '$CGI::strong' and
'$main::strong' as synonyms for the same subroutine. There is still,
however, no 'Schedule::strong'.

> What do I have
> to do to avoid putting the package name before every subroutine that
> doesn't come from the package I'm developing?  For a complicated
> program, I would imagine qualifying every subroutine call would get
> very cumbersome!

  use strict;
  use warnings;

  package Schedule;

  use CGI qw/:standard center delete_all/;

  my $htmlString = p( center( strong(
      'There are not any trains running on this day.', br,
      'Use the date dropdowns above to select a different day.' )));

> P.S.  In the little test program, if I leave the semicolon off the last
> line, it compiles.  If I put it on, it complains about the "br"
> bareword.  I'm using IndigoPerl.

May we see your little test program?

Cheers,

Rob




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

Reply via email to