[ic] Interesting Failure Reading Scratch Variables from Session

Mike Heins interchange-users@icdevgroup.org
Thu Jul 18 13:43:01 2002


Quoting John C. Beima (jbeima@palb.com):
[snip]
> > > > test_putvar.html:
> > > > ---------------------------------------------------
> > > > <html>
> > > > <body>
> > > >
> > > > [set whatever]ABC[/set]
> > > > <p>
> > > > This is a test.
> > > > </p>
> > > >
> > > > </body>
> > > > </html>
> > > > ---------------------------------------------------
> > > >
> > > > test_getvar.html:
> > > > ---------------------------------------------------
> > > > <html>
> > > > <body>
> > > >
> > > > <p>
> > > > This is a test - retrieve the value:
> > > > [perl]
> > > > $Scratch->{whatever};
> > > > [/perl]
[snip]
> > > Actually your test shouldn't show ABC... It is done wrong...
> > >
> > > [set test]ABC[/set]
> > >
> > > [perl]
> > >   my $out = '';
> > >   $out = $Scratch->{test};
> > >   return $out;
> > > [/perl]
> > >
> > > Would return an output of you scratch variable. Not what you are doing.
> > >
> > I can't see anything that's done wrong there.  That 'corrected' Perl
> > block does the same job as the original test code, but with a couple
> > of extra lines of code and an unnecessary variable.  Of course, using
> > [perl] in that context is an overkill anyway, but it's just a test
> > after all.
> 
> What is wrong with the original Perl tag is the Perl tag dose not return
> anything unless it is told to return it. His use of the tag is wrong. So
> unless something stupid has been done to the perl tag like the [calcno] tag,
> the return should be there.
> 

This is not true. The "return" is optional -- a Perl function always returns
the last value reached.

-- 
Mike Heins
Perusion -- Expert Interchange Consulting    http://www.perusion.com/
phone +1.513.523.7621      <mike@perusion.com>

"All you need in this life is ignorance and confidence, and
then success is sure." -- Mark Twain