Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re^2: Writing Modules

by perl.j (Pilgrim)
on Aug 23, 2011 at 14:07 UTC ( #921908=note: print w/replies, xml ) Need Help??

in reply to Re: Writing Modules
in thread Writing Modules

I seem to still be stuck. Hear is my "module" now:

package pack; use Exporter; @EXPORT = "$thing"; our $thing = "thing"; 1;

And here is my program:

use mine::package qw($thing); print "hello $thing";

My output ends up being hello instead of hello thing. Thanks for the help.


Replies are listed 'Best First'.
Re^3: Writing Modules
by armstd (Friar) on Aug 23, 2011 at 15:12 UTC

    If you turn on strict in your calling script, you'll get more information on what's going on. Basically though, you still haven't addressed this issue:

    Which module name? Your package is named here:
    package pack;
    You're invoking it with:
    use mine::package;

    The others have already gone into what needs to be resolved to fix that. I'd recommend re-reading their replies and follow their suggested references and read those too. It's all there, it's just not necessarily spelled out for you directly.

    EDIT: On second look, you've introduced a couple more issues as well with your changes. You should definitely turn strict back on in your package, as well as adding it to your test program. Turn on warnings everywhere as well. They will point out very clear issues, but the perl errors and warnings won't necessarily make perfect sense unless you know what exactly they're talking about. For that you definitely need to read those references.


      I turned on strict and warnings. It is saying (in my test program)
      Global symbol "$thing" requires explicit package name at C:\myperl\Per +lJunk\mo.p l line 3.
      . I know what that means but I already said our $thing in my "module". I am really confused...

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://921908]
[stevieb]: ...down to implement now. Here's the sketch as it currently sits
[shmem]: well I use I2C and SPI and stuff, but creating a pseudo chip looks to me like lot of indirection and memory clutter... not?
[choroba]: Are you going to use the device soon? Related to your comment about "not having much time to do a lot of coding"...
[stevieb]: sure, but I'm just learning ;) I consider it practice to get a good understanding of what goes on *after* an I2C/SPI request is made
[shmem]: ah ok. Gonna read that. but now....
shmem compiles himself into his template
[stevieb]: this is my RPi:: distribution overall automation build system physical layout. It doesn't encompass all of my RPi dists yet, ...
[stevieb]: ...but I'm getting close. I've been soldering my own PCBs to gain that experience as well, before I have my own manufactured.
[stevieb]: heh, nice *template* ;) 'night shmem!

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2017-06-25 22:50 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (572 votes). Check out past polls.