Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Perl Beginners Cgi > Re: Variable em...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 1465 of 1478
Post > Topic >>

Re: Variable empty in try block

by tom@[EMAIL PROTECTED] (Tom Storey) Apr 28, 2008 at 10:01 AM

Nevermind. A semicolon at the end of the otherwise block did the trick. ;-)

Thanks all.


> Hi,
>
> Im unsure if this is 100% the correct list, but I am using Perl to form
> dynamic web pages (CGI afaik?) so I'll give it a shot.
>
> I have a script which implements a try-catch block. Before entering the
> try ****tion of this block, I am defining a variable and placing some
> content into it, which is a hash table.
>
> The problem seems to be that when I go to access this variable inside
the
> try block, and subsequently any catch blocks, or the otherwise block,
the
> variable seems to be empty.
>
> Here is a snip of the code I am using:
>
>         my $session = new App($query, $thisModule);
>
>         try {
>                 $session->{AccessControl}->checkAccess();
>                 &$method($session);
>         } catch App::AccessControlException with {
>                 my $e = ****ft;
>                 print "Content-type: text/plain\n\n";
>                 print "An access control exception has occurred.\n\n";
>                 print Dumper($e);
>         } otherwise {
>                 my $e = ****ft;
>                 print "Content-type: text/plain\n\n";
>                 print "An error has occurred.";
>                 print Dumper($e);
>         }
>
> The first line creates a new instance of an object which contains some
> runtime variables and other content based on the request being
performed.
>
> If I chuck the following line in immediately after the first line:
>
> warn(Dumper($session));
>
> I see the following in my webserver log file:
>
> $VAR1 = bless( {
>                  'thisModule' => 'module',
>                  'Request' => {
>                                 'params' => [
>                                               'b',
>                                               'c'
>                                             ],
>                                 'what' => 'a'
>                               },
>                  'cgiQuery' => bless( {
>                                         '.parameters' => [],
>                                         'use_tempfile' => 1,
>                                         '.charset' => 'ISO-8859-1',
>                                         '.fieldnames' => {},
>                                         'escape' => 1
>                                       }, 'CGI' )
>                }, 'App' );
>
> This is fine, its what I want to see.
>
> But if I place this Dumper line inside the try block, I only see the
> following:
>
> $VAR1 = bless( {}, 'App' );
>
> So it appears that the variable has no content inside the try block.
>
> I dont see any complaints about the variable being undefined, so it
> obviously exists, just not its content.
>
> Can anyone think of a reason, or does anyone know the reason, why this
> would be occurring?
>
> Let me know if any further details are needed, or if you know of a
better
> list to post this question.
>
> Thanks,
> Tom
>
>
> --
> To unsubscribe, e-mail: beginners-cgi-unsubscribe@[EMAIL PROTECTED]
> For additional commands, e-mail: beginners-cgi-help@[EMAIL PROTECTED]
> http://learn.perl.org/
>
>
>
 




 1 Posts in Topic:
Re: Variable empty in try block
tom@[EMAIL PROTECTED] (T  2008-04-28 10:01:03 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Jul 26 0:58:34 CDT 2008.