#perl - Tue 1 May 2007 between 04:15 and 04:29



WoostaMaybe you *should* care
or you should set no warnings 'foo', when you REALLY intend to break the law
SeveredCrossThank you gentlemen for your help, I got it to work.
seekwillmauke: Sorry, that was becase of copying and pasting, trying new examples. That part fixed, but same error :(
crungeWoosta: perhaps. And when I'm having a problem with something, I do -w and disregard the warnings for modules
seekwillName "main::dispatch" used only once: possible typo at <-- not sure what this means then... Line53 is $dispatch{$function}->($yes);
crungeto 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
maukeseekwill: that means you used a variable only once
seekwill: that's probably wrong because you want to set it first, then read from it
seekwillmauke: But didn't I create it a few lines up? (after it was corrected.
maukeapparently not; I can't see your code
seekwillI'm trying to create a dispatch table. Where do I "create" it? In the beginning?
maukesomewhere before you use it
crungeseekwill: I tend to get "used only once" warnings when I 'my' a var and never do anything with it
maukeeval: use warnings; use strict; my $x = 2;
buubotmauke: 2
maukecrunge: no, you don't
crungemauke: that's where I remember getting them
maukethat warning is for package variables
crungemauke: but I usually assign when I my
maukeirrelevant
seekwillMaybe I should start over. Is there an easy tutorial on using dispatch tables?
crungemauke: overruled
maukeseekwill: does your program use "our"?
crungemauke: move to strike from the record
seekwillNot that I'm aware of.
I don't know what it does :)
maukeseekwill: then it looks like 'use strict' is not active
seekwillmauke: Ah :)
Oh wow. I found some other problems. Looks like that might have fixed it. All because I had "use strict();" :)
maukeuse strict(); doesn't do anything
you want use strict;
seekwillYeah, 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
maukeyeah, because you defined $dispatch but used %dispatch
dec$dispatch->{ $foo }-( @args );
whoops
$dispatch->{ $foo }->( @args );
that's important :)

Page: 1 8 15 22 29 36 43 50 57 64 71 78 85 92 99 

IrcArchive