| Woosta | Maybe you *should* care or you should set no warnings 'foo', when you REALLY intend to break the law |
| SeveredCross | Thank you gentlemen for your help, I got it to work. |
| seekwill | mauke: Sorry, that was becase of copying and pasting, trying new examples. That part fixed, but same error :( |
| crunge | Woosta: perhaps. And when I'm having a problem with something, I do -w and disregard the warnings for modules |
| seekwill | Name "main::dispatch" used only once: possible typo at <-- not sure what this means then... Line53 is $dispatch{$function}->($yes); |
| crunge | to put things in context, I'm almost always writing systems automation scripts, not modules that lots of apps will depend on were I writing things more significant, I might use warnings |
| mauke | seekwill: that means you used a variable only once seekwill: that's probably wrong because you want to set it first, then read from it |
| seekwill | mauke: But didn't I create it a few lines up? (after it was corrected. |
| mauke | apparently not; I can't see your code |
| seekwill | I'm trying to create a dispatch table. Where do I "create" it? In the beginning? |
| mauke | somewhere before you use it |
| crunge | seekwill: I tend to get "used only once" warnings when I 'my' a var and never do anything with it |
| mauke | eval: use warnings; use strict; my $x = 2; |
| buubot | mauke: 2 |
| mauke | crunge: no, you don't |
| crunge | mauke: that's where I remember getting them |
| mauke | that warning is for package variables |
| crunge | mauke: but I usually assign when I my |
| mauke | irrelevant |
| seekwill | Maybe I should start over. Is there an easy tutorial on using dispatch tables? |
| crunge | mauke: overruled |
| mauke | seekwill: does your program use "our"? |
| crunge | mauke: move to strike from the record |
| seekwill | Not that I'm aware of. I don't know what it does :) |
| mauke | seekwill: then it looks like 'use strict' is not active |
| seekwill | mauke: Ah :) Oh wow. I found some other problems. Looks like that might have fixed it. All because I had "use strict();" :) |
| mauke | use strict(); doesn't do anything you want use strict; |
| seekwill | Yeah, that's what I found out. So I created my dispatch table like this: my $dispatch = {}; $dispatch->{a} = sub { print( "AAAA" ); }; How do I "access" it? $dispatch{$function}->($yes); says Global symbol "%dispatch" requires explicit package name |
| mauke | yeah, because you defined $dispatch but used %dispatch |
| dec | $dispatch->{ $foo }-( @args ); whoops $dispatch->{ $foo }->( @args ); that's important :) |