Odd DBM::Deep behavior "cannot store tied value" using literal key name


Hi all,

I am trying to create a test script for some work I'm trying to do
with Data::Compare using DBM:eep, but the test code is acting flaky
and I'm not sure why.

In a previous (and working) script, I have a DBM:eep hash keyed
using IP addresses. Inside the hash is an array that contains several
values including an array reference and a hash reference. This works
fine.

The test script is a different story. Here's the code:
-------------------------------
#!/perl/bin/perl
use strict;
use warnings;

use Data::Compare;
use DBM:eep;

my $database = &OpenDB("test.db");

my %testhash = ( 'bob' => 23, 'alice' => 20 );
my @old = ("00-99-48-AF-46-43", "W117", 1, 1197390385, \%testhash);
my @same = ("00-99-48-AF-46-43", "W117", 1, 1197390385, \%testhash);

my %newhash = ( 'bob' => 23, 'alice' => 24 );
my @new = ("00-99-48-AF-46-43", "W117", 1, 1197390385, \%newhash);

my $ip1 = "144.1";
my $ip2 = "145.2";
my $ip3 = "146.3";

$database->{$ip1} = \@old;
# Uncomment the line directly below to generate error
# $database->{$ip2} = \@same;
# $database->{$ip3} = \@new;

my @test_old = @{$database->{$ip1}};
# my @test_same = @{$database->{$ip2}};
# my @test_new = @{$database->{$ip3}};

sub OpenDB
{
# Argument(s): A string containing the database filename to be used.
# Returned: A scalar reference holding the database object.
# Globals: None.
my ($filename) = @_;
my $db = DBM:eep->new(
file => $filename,
locking => 1,
autoflush => 1 ); # Test: see if removing this increases speed
return($db);
}
-------------------------------

The above code works as-is, but if I uncomment the line(s) above
(marked with a comment), I get the error: DBM:eep: Cannot store a
tied value.

Why is that
Posted On: Wednesday 7th of November 2012 01:59:14 PM Total Views:  129
View Complete with Replies

RELATED TOPICS OF Perl PROGRAMMING LANGUAGE




Perl Sockets oddity..

, I may be being a bit dim, but I wrote this: #!/usr/bin/perl -w use IO::Socket::INET; print "ISONAS Logger (perl) v1\n"; my $socket = IO::Socket::INET->new( PeerAddr => "10.9.1.100", PeerPort => "5321" ) or die $!; print "Connected.\n"; $socket->print("|"); while (true) { $socket->recv($text,128); print $text; } The data gets sent to the server, and data comes back, but does not get displayed on the screen. However, if I change the while() to while($text==$text), I get the following error: Use of uninitialized value in numeric eq (==) at ilog.pl line 13. Use of uninitialized value in numeric eq (==) at ilog.pl line 13. Use of uninitialized value in print at ilog.pl line 14. Argument "< 9/24/2008>|" isn't numeric in numeric eq (==) at ilog.pl line 16. Argument "< 9/24/2008>||" isn't numeric in numeric eq (==) at ilog.pl line 16. So, $text does contain the result, but for some reason it will not print to the screen. I'm stuck!!! Help!
VIEWS ON THIS POST

145

Posted on:

Tuesday 16th October 2012
View Replies!

Using module whith name stored in variable

all! Can anybody tell how can I use modele which name stored in variable For example, I have this code: ######################################## package MyModule; use strict; use Exporter; use vars qw(@ISA @EXPORT $DEBUG); @ISA = qw/Exporter/; @EXPORT = qw(foo); sub foo($) { my $arg = shift; print "MyModule foo: my arg: '$arg'\n"; return undef; } 1; ######################################## Here are the code of main programm ######################################## #!/usr/local/bin/perl use strict; my $module = 'MyModule.pm'; require $module; # load module my $arg = 'MyArg'; # I want call procedure by full name. How I can do this my $mname = 'MyModule'; $mname::foo($arg); # This doesn't work!!! exit 0; ########################################
VIEWS ON THIS POST

67

Posted on:

Tuesday 16th October 2012
View Replies!

Is it possible to store an SV in C pointer

Suppose I have two functions in my XS code, say funcA and funcB, after I store an SV in a global pointer in funcA, is it possible for me to access it in funcB Here is my pseudo code void *p; void funcA() { p = (void*)ST(0); //suppose ST(0) is a reference } void funcB() { SV *sv = (SV*)p; if (SvROK(sv)) ... //actually I cannot get the original SV in funcA } What is the correct way
VIEWS ON THIS POST

70

Posted on:

Tuesday 16th October 2012
View Replies!

Re: store first key of a hash to scalar

Noah wrote: > John W. Krahn wrote: >> Noah wrote: >>> >>> What is the easiest way to store the first key of a hash to a scalar >>> variable >> >> A hash doesn't have a "first" key. Which key do you really want > > okay that basically answers my question. I will have to figure out to > define a key that is the root key. Describe your data Noah. What are you trying to do Rob
VIEWS ON THIS POST

221

Posted on:

Tuesday 16th October 2012
View Replies!

FAQ 4.66 How can I store a multidimensional array in a DBM file?

This is an excerpt from the latest version perlfaq4.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest version of the complete perlfaq is at http://faq.perl.org . -------------------------------------------------------------------- 4.66: How can I store a multidimensional array in a DBM file Either stringify the structure yourself (no fun), or else get the MLDBM (which uses Data:umper) module from CPAN and layer it on top of either DB_File or GDBM_File. -------------------------------------------------------------------- The perlfaq-workers, a group of volunteers, maintain the perlfaq. They are not necessarily experts in every domain where Perl might show up, so please include as much information as possible and relevant in any corrections. The perlfaq-workers also don't have access to every operating system or platform, so please include relevant details for corrections to examples that do not work on particular platforms. Working code is greatly appreciated. If you'd like to help maintain the perlfaq, see the details in perlfaq.pod.
VIEWS ON THIS POST

115

Posted on:

Tuesday 16th October 2012
View Replies!

cannot post message to perl beginners

This is odd. I can post to this newsgroup but not to perl.beginners. Anyone any idea why this is so
VIEWS ON THIS POST

105

Posted on:

Wednesday 17th October 2012
View Replies!

best way to store binary image data in a variable using image magick

Hi all, Just wanted to know the code for doin this, such that I can use the variable for doing other kinds of methods against it.. I tried this, and I can printout the binary data, but I am finding you can assign the image data to a variable for further processing.. any ideas I noticed that this line: $img->Write('jpg:-'); actually displayed the image data, but how do I assign that binary data to a variable \t use Image::Magick; my $img = new Image::Magick; $x= $img->Read("c:\\tmp\\ean81.bmp"); ## doesnt work: $img->Write('$temp');
VIEWS ON THIS POST

98

Posted on:

Wednesday 17th October 2012
View Replies!

is this expected behavior? perl '' test.pl

I attempting to debug an odd open3 call that was passed something like this: open3( ...,...,..., @args); The @args is where things get interesting the invocation is: perl '' test.pl Where the '' is 2 single quotes representing an empty entity, and test.pl can be any script. When perl 5.8.8 & perl 5.9.5 see the "empty" argument they read source code from STDIN and then execute the code from STDIN. It halts, waiting for code from the keyboard. This bug originally came about when someone tried to do this: @args = ( 'perl',$extralibs,'etc...'); problem was $extralibs was empty. On one side of the coin, I don't see any documentation regarding this situation in "perldoc perl". On the other side of the coin, empty arguments should probably be annoyed. And on yet the another side of the coin, I should check $extralibs for being empty before stuffing it into an array! I didn't think a perlbug report was proper, so following the INSTALL instructions ... here it is. -daniel
VIEWS ON THIS POST

65

Posted on:

Wednesday 17th October 2012
View Replies!

Odd regex behavior

On Sun, 30 Sep 2007 20:37:13 -0700, Mintcake wrote: > I wouldd be grateful to anyone who can shed some light on the > unexpected > results from the regex in the following program. > > #!/usr/local/bin/perl -l > > use strict; Adding the line use warnings; to your script gives the answer to your problem. , Looks like you've found a bug. Please file a report! Greg -- When man attempts to rise above Nature, he usually falls below it. -- Sherlock Holmes , On Oct 2, 5:51 pm, Brian McCauley wrote: > On Oct 1, 4:37 am, Mintcake wrote: > > > I wouldd be grateful to anyone who can shed some light on the > > unexpected > > results from the regex in the following program. > > I suspect that this is pretty much the same issue as was discussed > here recently Correction - if it wasn't for that issue you probably would not have been able to observe the bug. There is, of course, as Yves points out a much more serious bug here too.
VIEWS ON THIS POST

65

Posted on:

Wednesday 17th October 2012
View Replies!

FAQ 4.65 How can I store a multidimensional array in a DBM file?

This is an excerpt from the latest version perlfaq4.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest version of the complete perlfaq is at http://faq.perl.org . -------------------------------------------------------------------- 4.65: How can I store a multidimensional array in a DBM file Either stringify the structure yourself (no fun), or else get the MLDBM (which uses Data:umper) module from CPAN and layer it on top of either DB_File or GDBM_File. -------------------------------------------------------------------- The perlfaq-workers, a group of volunteers, maintain the perlfaq. They are not necessarily experts in every domain where Perl might show up, so please include as much information as possible and relevant in any corrections. The perlfaq-workers also don't have access to every operating system or platform, so please include relevant details for corrections to examples that do not work on particular platforms. Working code is greatly appreciated. If you'd like to help maintain the perlfaq, see the details in perlfaq.pod.
VIEWS ON THIS POST

178

Posted on:

Saturday 20th October 2012
View Replies!

Looping through lines stored in a scalar

I wonder what idioms are available to loop through the lines stored in a scalar variable. I guess I'm looking for something ****ogous to these idioms for files and arrays respectively: while() { # do stuff } foreach (@array) { # do stuff } When I had to do this I split the scalar in an array: @array = split "\n", $scalar; foreach (@array) { # do stuff } What would be some other ways to do this (This is purely curiosity.)
VIEWS ON THIS POST

57

Posted on:

Saturday 20th October 2012
View Replies!

[newbie]How to call stored procedure using DBIx?

all! I've stored procedures defined in my database schema, and I need to call them in my code. The arbitrary-sql approach won't help since it writes sql statements in source code to act as stored procedures. So could I do that in DBIx Thank you! , On Fri, 28 Dec 2007 22:58:25 +0800, Tony Winslow wrote: > The env: Catalyst, DBIx::Class, MySQL > If I can get a $dbh from what I already have from DBIx::Class, the > problem can be solved. Yet I can figure out a way to get it. See DBIx::Class::Storage:BI: $schema->storage->dbh -- Peter Scott http://www.perlmedic.com/ http://www.perldebugged.com/
VIEWS ON THIS POST

89

Posted on:

Saturday 20th October 2012
View Replies!

FAQ 4.65 How can I store a multidimensional array in a DBM file?

This is an excerpt from the latest version perlfaq4.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest version of the complete perlfaq is at http://faq.perl.org . -------------------------------------------------------------------- 4.65: How can I store a multidimensional array in a DBM file Either stringify the structure yourself (no fun), or else get the MLDBM (which uses Data:umper) module from CPAN and layer it on top of either DB_File or GDBM_File. -------------------------------------------------------------------- The perlfaq-workers, a group of volunteers, maintain the perlfaq. They are not necessarily experts in every domain where Perl might show up, so please include as much information as possible and relevant in any corrections. The perlfaq-workers also don't have access to every operating system or platform, so please include relevant details for corrections to examples that do not work on particular platforms. Working code is greatly appreciated. If you'd like to help maintain the perlfaq, see the details in perlfaq.pod.
VIEWS ON THIS POST

76

Posted on:

Saturday 20th October 2012
View Replies!

Win32::OLE and CAPICOM to find a certificate in certificate store will raise exception

I am trying to use win32::OLE to access certificate store via CAPICOM. If certificates in the store meet the searching criteria, the certificates object method "find" works, but if no certificate meets the searching criteria, it will raise an error message: OLE exception from "": The Data is invalid. How to solve the problem or catch the exception in Perl script
VIEWS ON THIS POST

60

Posted on:

Monday 22nd October 2012
View Replies!

Perl & DBI cannot locate

I just installed: perl 5.8.7 + defined-or + DBI 1.48 + Tk 804.027 built with gcc-4.0.0 From: http://mirrors.develooper.com/hpux/downloads.html I was under the assumption that the DBI module was installed. When I do: perldoc DBI I get the docs for DBI But when I try to use DBI I get an error... Can't locate DBI.pm in @INC (@INC contains: /opt/perl64/lib/5.8.8/PA-RISC2.0-LP64 /opt/perl64/lib/5.8.8 /opt/perl64/lib/site_perl/5.8.8/PA-RISC2.0-LP64 /opt/perl64/lib/site_perl/5.8.8 /opt/perl64/lib/site_perl .) at test2 line 27. BEGIN failed--compilation aborted at test2 line 27. My path points to /usr/bin/perl. lrwxr-xr-x 1 root sys 20 Nov 20 11:56 /usr/bin/perl -> /opt/perl64/bin/perl How can I tell if it is installed, or do I still need to install this. Do I also need the oracle driver
VIEWS ON THIS POST

76

Posted on:

Friday 26th October 2012
View Replies!

odd chars in perldoc prior to 5.10.0 (was: Re: How to print question)

Steven M. O'Neill wrote: > mmccaws2 wrote: >> Your code is almost exactly what I had. But what is the "$| = 1;" >> for > > perldoc perlvar | grep '$|' After reading, I threw this into my linux console (where perldoc defaults to my 5.8.8 installation compiled from the tarball.) I noticed the grep didn't return any output. I then attempted using perldoc from perl 5.10.0 (also compiled from tarball, using the same options as I did for 5.8.8 if that means anything here) and it did return the correct text: $ perldoc5.8.8 perlvar | grep '$|' $ perldoc5.10.0 perlvar | grep '$|' $| If set to nonzero, forces a flush right away and after every buffered by the system or not; $| tells you only whether you\tTve ---------1---------2---------3---------4---------5---------6---------7---------8 I greped a part of that text in perldoc 5.8.8: $ perldoc5.8.8 perlvar | egrep 'If set to nonzero|buffered by the system' $", If set to nonzero, forces a flush right away and after every buffered by the system or not; $", tells you only whether you\tTve Same thing happens for 5.8.2, 5.8.0, and 5.6.1. Also notice how the line beginning with "buffered" is offset by two characters, since there seems to be two extra characters in the first line (where it should be just $|) Also, in any version, the "you've" at the end has extra characters as well. I've tried using different $TERM's (it's normally xterm) and different fonts to no avail. In fact the only place it works right is to sit in from the machine itself and log into a local console. Normally I ssh into this machine from my main machine. I ssh using Secure CRT 5.5.3. Yes, I realize this is may be a bit out of the scope of this news group, but I would like to know if anyone else encountered this problem. I suspect it is a term/font issue. (and I don't have this problem using ActiveState 5.8.7 and 5.6.1 in XP PS2.) Thank you. -- szr
VIEWS ON THIS POST

77

Posted on:

Sunday 4th November 2012
View Replies!

How to read a variable and store it

I am looking to see how to acheive this, but cannot figure out a way:1. open a file from a remote location2. look for a specific string (ex "byte size is 6678KB", but the "KB" value changes everyday)3. store this value for future comparisionCan someone guide me please
VIEWS ON THIS POST

49

Posted on:

Wednesday 7th November 2012
View Replies!

mysql data store in to a FILE

Hi , I just tried to store some mysql-queried data in to a file. but it wont work. Actually i wanted to do not just writing , it should be APPEND at each time when that perl scripts runs. Can some body help me , ifyou all can provide me a sample or a example would be a great help Many
VIEWS ON THIS POST

59

Posted on:

Wednesday 7th November 2012
View Replies!

extract all hotmail email addresses in a file and store in separatefile

I have a text file that contents a list of email addresses like this: "foo@yahoo.com" "tom@hotmail.com" "jerry@gmail.com" "tommy@apple.com" I like to 1. Strip out the " characters and just leave the email addresses on each line. 2. extract out the hotmail addresses and store it into another file. The hotmail addresses in the original file would be deleted.
VIEWS ON THIS POST

62

Posted on:

Wednesday 7th November 2012
View Replies!

How do I follow links stored in an array?

BirgitteRand@gmail.com wrote: > I don't know how to follow links in an array (@links) at the bottom of > this script. First you'd better make sure that there are some links in @links to follow. > #jump through tags until you get 'h1' > while( my $title = $p->get_tag( 'h1' )) { > last if $title->[1]->{class} eq 'h1'; > } Since there are no elements in the document, that code jumps to the end of string. You can simply do: $p->get_tag('/h2'); to get to the section of the document you are interested in. No loop needed. > # look through the tokens until you hit the end of 'h1' > my @links; > while ( my $token = $p->get_token ) { > last if $token->[0] eq 'E' && $token->[1] eq 'h1'; -----------------------------------------------------^^^^ Suppose you mean 'div' ... > # now follow the links Yes, but first make sure that @links contains what you expect. print "$_\n" for @links; If it does, you can start working with the last section of your script. -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl
VIEWS ON THIS POST

64

Posted on:

Wednesday 7th November 2012
View Replies!