Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Question regarding exact regexp matching

by jethro (Monsignor)
on Jun 28, 2012 at 22:15 UTC ( #979013=note: print w/replies, xml ) Need Help??


in reply to Question regarding exact regexp matching

$players{$1} = %skeleton_player;

You try to assign a hash to a scalar. A hash in scalar context will return a string that tells you something about the fill ratio of your hash. Try it out:

perl -e ' %h=(1,5,2,8); $d=%h; print $d;' #prints "2/8"

You want this instead:

%{$players{$1}} = %skeleton_player;

As you can see, now you are assigning a hash to a hash.

PS: It helps with debugging to print out values of variables even when you think you know what is in there. Very helpful for this is Data::Dumper. Try the following before and after your logging loop and see what your data looks like (you also have to add "use Data::Dumper" at the start of your script):

print Dumper(\%players),"\n";

Also very helpful to print out whatever gets matched in your logging loop, i.e. put this inside the match-success if-case:

print "I matched $1 and $2\n";

Replies are listed 'Best First'.
Re^2: Question regarding exact regexp matching
by Ekimino (Novice) on Jun 28, 2012 at 22:29 UTC
    Assigning the hash correctly has solved the problem, Thank you.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://979013]
help
Chatterbox?
[Corion]: I think I saw virtualsue more recently in person than online :-D
[virtualsue]: It's true that there was a bigger gap between the 2 yr old post and the one before it
[ambrus]: yes, I probably just didn't see you two years ago, because I'm not in perlmonks much
[virtualsue]: Nor am I :-)
[talexb]: virtualsue Heh .. long time no see! :)
[virtualsue]: I have a quiet Perl themed slack workspace
[virtualsue]: The person who talks to me on it the most *hates* Perl but she hates everything
[virtualsue]: If anyone is interested, ping me an email address for an invitation.

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (11)
As of 2017-09-26 13:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (295 votes). Check out past polls.

    Notices?