[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] tie



At 04.55 -0500 1999.03.06, Bart Lateur wrote:
>The barewords O_RDWR and O_CREAT are in fact intended as functions that
>are defined in Fcntl.pm . So, if Fcntl is used, you'll get the correct
>(numeric) value for "O_RDWR|O_CREAT".

DB_File exports those automatically.  So if DB_FILE becomes DB_File,
Exporter can work properly, and they are no longer barewords, but function
calls.

But yes, I don't know why there was not a warning about barewords.  use
strict would have helped, though:

#!perl -w
use strict;
use DB_FILE;

tie (my %admin, 'DB_File', 'admin.info', O_RDWR|O_CREAT, 0644) or die
"couldn't tie it: $!";

$admin{'jason'} = 'name';
$admin{'blue'} = 'eyecolor';
$admin{'sixfoot'} = 'height';

untie (%admin);
__END__

# Bareword "O_RDWR" not allowed while "strict subs" in use.
File 'Untitled #5'; Line 5
# Bareword "O_CREAT" not allowed while "strict subs" in use.
File 'Untitled #5'; Line 5
# Execution of Untitled #5 aborted due to compilation errors.


Although, the interesting thing is that wrong case on a use statement
pretty much affects importing/exporting symbols.  So this works properly:

#!perl -w
use strict;
use Fcntl;
use DB_FILE;

tie (my %admin, 'DB_File', 'admin.info', O_RDWR|O_CREAT, 0644) or die
"couldn't tie it: $!";

$admin{'jason'} = 'name';
$admin{'blue'} = 'eyecolor';
$admin{'sixfoot'} = 'height';

untie (%admin);
__END__

Even though the case on DB_File is wrong, the only symbols needed are
gotten from Fcntl, and the proper case is passed via the tie() statement.

--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org