Skip Menu |

This queue is for tickets about the DBM-Deep CPAN distribution.

Report information
The Basics
Id: 48031
Status: resolved
Priority: 0/
Queue: DBM-Deep

People
Owner: Nobody in particular
Requestors: #!^!#&!pan.org'
$_
'spro^^*%*^6ut# [...] &$%*c
=
print
y/a-z. [...] //cd
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Bug with $,
I see in DBM::Deep::File::print_at and read_at that the $/ and $\ variables are localised. But $, is forgotten about. In fact, $/ only affects <> and readline, with DBM::Deep doesn’t use, so there’s no need to localise it. Perl’s read function uses no magic vars, so no localisation is necessary at all in read_at. The attached patch addresses these issues. It also includes tests for $\ localisation. Father Chrysostomos
Subject: $,.diff
diff -Nurp DBM-Deep-1.0014/lib/DBM/Deep/File.pm DBM-Deep-1.0014-new2/lib/DBM/Deep/File.pm --- DBM-Deep-1.0014/lib/DBM/Deep/File.pm 2009-06-20 11:12:53.000000000 -0700 +++ DBM-Deep-1.0014-new2/lib/DBM/Deep/File.pm 2009-06-20 11:46:11.000000000 -0700 @@ -110,7 +110,7 @@ sub print_at { my $self = shift; my $loc = shift; - local ($/,$\); + local ($,,$\); my $fh = $self->{fh}; if ( defined $loc ) { @@ -132,8 +132,6 @@ sub read_at { my $self = shift; my ($loc, $size) = @_; - local ($/,$\); - my $fh = $self->{fh}; if ( defined $loc ) { seek( $fh, $loc + $self->{file_offset}, SEEK_SET ); diff -Nurp DBM-Deep-1.0014/t/54_output_punct_vars.t DBM-Deep-1.0014-new2/t/54_output_punct_vars.t --- DBM-Deep-1.0014/t/54_output_punct_vars.t 1969-12-31 16:00:00.000000000 -0800 +++ DBM-Deep-1.0014-new2/t/54_output_punct_vars.t 2009-06-20 11:44:38.000000000 -0700 @@ -0,0 +1,30 @@ + +# This script tests the use of punctuation vars that affect output: $, $\ + +use strict; + +use Test::More tests => 3; +use t::common qw( new_fh ); + +use_ok( 'DBM::Deep' ); +use DBM::Deep; + +my ($fh, $filename) = new_fh(); +ok eval { + local $,="\t"; + my $db = DBM::Deep->new( file => $filename, fh => $fh, ); + $db->{34808} = "BVA/DIVISO"; + $db->{34887} = "PRIMARYVEN"; +}, '$, causes no hiccoughs or 150MB files'; + + +($fh, $filename) = new_fh(); +ok eval { + local $\="\n"; + my $db = DBM::Deep->new( file => $filename, fh => $fh, ); + $db->{foo} = ""; + $db->{baz} = "11111"; + $db->{foo} + = "counterpneumonoultramicroscopicsilicovolcanoconiotically"; + $db->{baz}; +}, '$\ causes no problems';