Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: accessing values

by choroba (Cardinal)
on Oct 14, 2020 at 21:12 UTC ( [id://11122843]=note: print w/replies, xml ) Need Help??


in reply to accessing values

Variables declared with my in 1.pl are defined at file scope: once the file ends, they're out of scope. Neither require nor do can see them.

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^2: accessing values
by frank1 (Beadle) on Oct 14, 2020 at 21:26 UTC

    so there is no way i can access variables outside the file

      > so there is no way i can access variables outside the file

      sure, but they need to be package variables declared with our

      The cleanest way is to define an own package "File1".

      Then you can either export them or reference them via $File1::var1

      If you rally want both files to be in the same package ("main" is default), then you won't need to fully qualify them by a leading package name.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11122843]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2024-04-25 16:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found