Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language

Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Perl Programming Language

2 examples of packages 1 has error the other does not

I'm writing and testing a module that can be executed as a standalone script
for debugging purposes.
It's part of a very large system of regression testing.  Messages are lost
along the way.
So with the caller() function I transform a module into an executable.
With example #1 my $x seems to have lost it's scope.

What I'm worried about, is what is goinf to happen when in the big system it
does a :
use foo;
require "foo.pm";

example #1
use strict;
use warnings;
if ( !defined caller ) { foo::bar();}
package foo;
my $x = 'foo.bar';
sub bar { print "$x\n"; }  <<<<------ line 13  blank lines removed

executing gives this :
Use of uninitialized value in concatenation (.) or string at z line 13.

example #2  works fine
package foo;
use strict;
use warnings;
my $x = 'foo.bar';
sub bar { print "$x\n"; }
if ( !defined caller ) {
  # enter package main
  package main;
  use strict;
  use warnings;

} # leave package main

On 06/06/2007 12:40 PM, Billy Patton wrote:

Move the line that tests caller() and calls foo::bar() down below the
line that sets $x. Right now, when foo::bar() is invoked, $x has not
been given any value, so it's undefined.
Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc