[13284] in Perl-Users-Digest
Perl-Users Digest, Issue: 694 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 1 09:07:16 1999
Date: Wed, 1 Sep 1999 06:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 1 Sep 1999 Volume: 9 Number: 694
Today's topics:
Re: Can't use telnet with telnetd server <scarlzong@hotmail.com>
Re: cgi error on apache <p.meidl@klivv.oeaw.ac.at>
Re: cgi error on apache <gellyfish@gellyfish.com>
Re: Creating runtime variables. <tchrist@mox.perl.com>
different compiler for perl and module (SGI-cc and gcc) <mkreutzer@my-deja.com>
Doing a reverse lookup with ping? <orange_nurf@hotmail.com>
Re: Doing a reverse lookup with ping? <gellyfish@gellyfish.com>
Re: editors?? (Gabor)
Re: EMPLOYMENT OPPORTUNITY:Perl/Web Developer (Malcolm Ray)
Fork mbarieux2225@my-deja.com
RE: I am new to perl <flavell@mail.cern.ch>
perl Ad <One.Bored.Guru........@p0.f1.n30.z30.fidonet.org>
Re: Redirecting STDERR to STDOUT (on NT) (Larry Rosler)
Rename problem with FTP in Win32::Internet frederic.lemoine@manpower.be
standalone perl apps on win/mac? but86@my-deja.com
Re: tied hash <tchrist@mox.perl.com>
Uninstall Net::FTP ?? <rohan_talip@my-deja.com>
Re: Using grep to match complete words <santhony@ea.com>
What is DBI? but86@my-deja.com
XML::Parser help needed <chris@inta.net.uk>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 1 Sep 1999 14:42:42 +0200
From: "Sune Carlzon" <scarlzong@hotmail.com>
Subject: Re: Can't use telnet with telnetd server
Message-Id: <7b9z3.9$qd1.16967@uab.ericsson.se>
Hi,
well I had already tried that. From that I can understand the win32 telnet
server is sending data with ansi code which makes my script not
understanding the buffer it receives. This is not the case with the unix
telnet server. Is there any way from inside the script change this (haven't
found anything in the telnet documentation), or am I, as I start to suspect,
required to change the settings of the telnetd server.
/Sune
Lars Thegler <lars@thegler.dk> wrote in message
news:37CCED19.ACF41F2E@thegler.dk...
> Sune Carlzon wrote:
> >
> > I am trying to setup a script that via telnet issues a couple of
commands
> > and stores the result for evaluation.
> >
> > Anyone that has any idea what's going wrong ?
> >
> > use Net::Telnet ();
>
> For debugging Net::Telnet scripts, use dump_log:
>
> [From perldoc Net::Telnet]
>
> dump_log - log all I/O in dump format
>
> $fh = $obj->dump_log;
>
> $fh = $obj->dump_log($fh);
>
> $fh = $obj->dump_log($filename);
>
> This method starts or stops dump format logging of all
> the object's input and output. The dump format shows
> the blocks read and written in a hexadecimal and
> printable character format. This method is useful
> when debugging, however you might want to first try
> input_log() as it's more readable.
>
> [end of quote]
>
> /Lars
------------------------------
Date: Wed, 01 Sep 1999 10:41:14 GMT
From: Patrick Meidl <p.meidl@klivv.oeaw.ac.at>
Subject: Re: cgi error on apache
Message-Id: <37CD038D.E3D5E1@klivv.oeaw.ac.at>
first of all: I solved the problem (see below). thanx, david, for your
help!
David Efflandt wrote:
> 1. If you are going to post to different newsgroups, post to all at the
> same time, not individually (ie: comma separated list of newsgroups).
sorry for the crossposting, but I needed the script very urgently. BTW:
what's the difference when I post to several groups at the same time and
not one after the other?
> 2. Your script has correct syntax (and runs on my Linux system), so this
> is not a Perl problem, and it should NOT be posted to a perl newsgroup.
since the script didn't work on my system (neither as cgi nor stand
alone), it _was_ a perl problem, IMHO.
> 3. Do you get any error when you test it in the shell as ./cgitest.pl? If
> it runs as 'perl cgitest.pl', but does not run as './cgitest.pl', you need
> to learn how to use a Unix text editor instead of Windows notepad (try
> pico from the pine package if you have not learned vi or emacs). The
> problem in that case is that bash cannot find 'perl^M' (Unix does not use
> carriage returns like DOS does).
this was it! the strange thing is that I never edited the file on a
windows machine, I just downloaded it from a web site. dos2unix fixed
the problem.
bye *patrick*
--
Patrick Meidl
Witzelsbergerg. 20/6
A-1150 Vienna
Austria
!!!NEW +43-699-10460516 NEW!!!
p.meidl@klivv.oeaw.ac.at
http://unet.univie.ac.at/~a8903821
--
------------------------------
Date: 1 Sep 1999 12:13:02 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: cgi error on apache
Message-Id: <37cd0a3e_2@newsread3.dircon.co.uk>
Patrick Meidl <p.meidl@klivv.oeaw.ac.at> wrote:
>
> sorry for the crossposting, but I needed the script very urgently. BTW:
> what's the difference when I post to several groups at the same time and
> not one after the other?
>
You didnt crosspost thats the point - you posted to a bunch of groups
individually rather than all at once. I would read some of the articles
in news.announce.newusers .
/J\
--
"Is there no demand for mechanical pussies?" - Mrs Slocombe
------------------------------
Date: 1 Sep 1999 05:10:23 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Creating runtime variables.
Message-Id: <37cd099f@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
baris sertkaya <e109775@orca.cc.metu.edu.tr> writes:
:Hi folks..
:I am trying to create runtime variables like that:
:-----------------------------------
:for $n (0..2) {
: $a="var$n";
: $$a=$n;
: print "\$$a:$$a\n";
:}
:-----------------------------------
:that works...
:My question is : Is it possible to do the same operation without
:using that $a variable as a helper..
:I want to do this assignments(below) at one expression...
: $a="var$n";
: $$a=$n;
=head2 How can I use a variable as a variable name?
Beginners often think they want to have a variable contain the name
of a variable.
$fred = 23;
$varname = "fred";
++$$varname; # $fred now 24
This works I<sometimes>, but it is a very bad idea for two reasons.
The first reason is that they I<only work on global variables>.
That means above that if $fred is a lexical variable created with my(),
that the code won't work at all: you'll accidentally access the global
and skip right over the private lexical altogether. Global variables
are bad because they can easily collide accidentally and in general make
for non-scalable and confusing code.
Symbolic references are forbidden under the C<use strict> pragma.
They are not true references and consequently are not reference counted
or garbage collected.
The other reason why using a variable to hold the name of another
variable a bad idea is that the question often stems from a lack of
understanding of Perl data structures, particularly hashes. By using
symbolic references, you are just using the package's symbol-table hash
(like C<%main::>) instead of a user-defined hash. The solution is to
use your own hash or a real reference instead.
$fred = 23;
$varname = "fred";
$USER_VARS{$varname}++; # not $$varname++
There we're using the %USER_VARS hash instead of symbolic references.
Sometimes this comes up in reading strings from the user with variable
references and wanting to expand them to the values of your perl
program's variables. This is also a bad idea because it conflates the
program-addressable namespace and the user-addressable one. Instead of
reading a string and expanding it to the actual contents of your program's
own variables:
$str = 'this has a $fred and $barney in it';
$str =~ s/(\$\w+)/$1/eeg; # need double eval
Instead, it would be better to keep a hash around like %USER_VARS and have
variable references actually refer to entries in that hash:
$str =~ s/\$(\w+)/$USER_VARS{$1}/g; # no /e here at all
That's faster, cleaner, and safer than the previous approach. Of course,
you don't need to use a dollar sign. You could use your own scheme to
make it less confusing, like bracketed percent symbols, etc.
$str = 'this has a %fred% and %barney% in it';
$str =~ s/%(\w+)%/$USER_VARS{$1}/g; # no /e here at all
Another reason that folks sometimes think they want a variable to contain
the name of a variable is because they don't know how to build proper
data structures using hashes. For example, let's say they wanted two
hashes in their program: %fred and %barney, and to use another scalar
variable to refer to those by name.
$name = "fred";
$$name{WIFE} = "wilma"; # set %fred
$name = "barney";
$$name{WIFE} = "betty"; # set %barney
This is still a symbolic reference, and is still saddled with the
problems enumerated above. It would be far better to write:
$folks{"fred"}{WIFE} = "wilma";
$folks{"barney"}{WIFE} = "betty";
And just use a multilevel hash to start with.
The only times that you absolutely I<must> use symbolic references are
when you really must refer to the symbol table. This may be because it's
something that can't take a real reference to, such as a format name.
Doing so may also be important for method calls, since these always go
through the symbol table for resolution.
In those cases, you would turn off C<strict 'refs'> temporarily so you
can play around with the symbol table. For example:
@colors = qw(red blue green yellow orange purple violet);
for my $name (@colors) {
no strict 'refs'; # renege for the block
*$name = sub { "<FONT COLOR='$name'>@_</FONT>" };
}
All those functions (red(), blue(), green(), etc.) appear to be separate,
but the real code in the closure actually was compiled only once.
So, sometimes you might want to use symbolic references to directly
manipulate the symbol table. This doesn't matter for formats, handles, and
subroutines, because they are always global -- you can't use my() on them.
But for scalars, arrays, and hashes -- and usually for subroutines --
you probably want to use hard references only.
--
str->str_pok |= SP_FBM; /* deep magic */
s = (unsigned char*)(str->str_ptr); /* deeper magic */
--Larry Wall in util.c from the perl source code
------------------------------
Date: Wed, 01 Sep 1999 12:02:11 GMT
From: Michiel Kreutzer <mkreutzer@my-deja.com>
Subject: different compiler for perl and module (SGI-cc and gcc)
Message-Id: <7qj4jt$ddq$1@nnrp1.deja.com>
I am trying to compile the DBI perl module on SGI IRIX 6.5.4m. I have
the perl software that came with irix (eoe.sw.gifts-perl or something)
and gcc 2.8.1. from the freeware.sgi.com site. This is the first perl
module I ever tried.
I did 'perl Makefile.PL', which creates a Makefile. This makefile get
information about the system from Config.pm, which in turn hold the
information used to build perl. Perl on my system was build with the
MIPSPro compiler, which I don't have. I use gcc.
I edited the makefile by hand, see below for details. This way I managed
to build with some warnings (below), but the subsequent 'make test'
fails (again, below).
Searching dejanews, I did not find the answer. Some suggest to build
perl with the compiler, etc, that will be used for modules. Do perl and
perl-modules have to be compiled with same compiler, or can config.pm
safely be edited to hold _current_ information about the system? Has
anybody ever done this for the Irix-gcc combination?
Building perl with gcc on Irix is troublesome, I have to patch gcc to do
that (has to do with integer sizes in n32), as someone suggested.
Or am I missing the point here?
Thanks in advance for any input!
At the real bottom some system info is given:
### Changes to Makefile
CC = gcc -fno-builtin -mips3
CCFLAGS = -D_BSD_SIGNALS -D_BSD_TYPES -D_BSD_TIME
-DLANGUAGE_C -DEMBEDMYMALLOC
LD = ld
LDDLFLAGS = -n32 -mips3 -shared
LDFLAGS = -n32
# --- MakeMaker cflags section:
CCFLAGS = -D_BSD_SIGNALS -D_BSD_TYPES -D_BSD_TIME
OPTIMIZE = -O
### gmake warnings
/usr/share/lib/perl5/irix-n32/5.00404/CORE/perlsdio.h:268: warning:
`getc_unlocked' redefined
/usr/include/stdio.h:394: warning: this is the location of the previous
definition
/usr/share/lib/perl5/irix-n32/5.00404/CORE/perlsdio.h:270: warning:
`putc_unlocked' redefined
/usr/include/stdio.h:396: warning: this is the location of the previous
definition
DBI.xs: In function `set_trace_file':
DBI.xs:406: warning: passing arg 1 of `setlinebuf' from incompatible
pointer type
### 'gmake test' output
[michiel@Indigo2 /disk4/src/DBI-1.11] > gmake test
PERL_DL_NONLAZY=1 /usr/sbin/perl -I./blib/arch
-I./blib/lib -I/usr/share/lib/perl5/irix-n32/5.00404
-I/usr/share/lib/perl5 -e 'u est::Harness
qw(&runtests $verbose); $verbose=0; runtests @ARGV;' t/*.t
t/basics............dubious
Test returned status 0 (wstat 138, 0x8a)
Number found where operator expected at (eval 103) line 1, near "*(138"
(Missing operator before 138?)
t/dbidrv............dubious
Test returned status 0 (wstat 138, 0x8a)
Number found where operator expected at (eval 105) line 1, near "*(138"
(Missing operator before 138?)
t/examp.............dubious
Test returned status 0 (wstat 138, 0x8a)
Number found where operator expected at (eval 107) line 1, near "*(138"
(Missing operator before 138?)
t/meta..............dubious
Test returned status 0 (wstat 138, 0x8a)
Number found where operator expected at (eval 109) line 1, near "*(138"
(Missing operator before 138?)
t/proxy.............dubious
Test returned status 0 (wstat 138, 0x8a)
Number found where operator expected at (eval 111) line 1, near "*(138"
(Missing operator before 138?)
t/shell.............skipping test on this platform
t/subclass..........dubious
Test returned status 0 (wstat 138, 0x8a)
Number found where operator expected at (eval 113) line 1, near "*(138"
(Missing operator before 138?)
FAILED--7 test scripts could be run, alas--no output ever seen
gmake: *** [test_dynamic] Error 138
### system info
[Indigo2 /disk4/src/DBI-1.11] > gcc -v
Reading specs from
/usr/freeware/lib/gcc-lib/mips-sgi-irix6.2/2.8.1/specs
gcc version 2.8.1
[Indigo2 /disk4/src/DBI-1.11] > uname -aR
IRIX Indigo2 6.5 6.5.4m
[Indigo2 /disk4/src/DBI-1.11] > perl -V
Summary of my perl5 (5.0 patchlevel 4 subversion 4) configuration:
Platform:
osname=irix, osvers=6.5, archname=irix-n32
uname='irix hoshi 6.5 11251326 ip22 '
hint=recommended, useposix=true, d_sigaction=define
bincompat3=y useperlio=define d_sfio=undef
Compiler:
cc='cc -n32 -mips3', optimize='-O3 -mips3', gccversion=
cppflags='-D_BSD_SIGNALS -D_BSD_TYPES -D_BSD_TIME
-OPT:Olimit=0:space=ON -DLANGUAGE_C -DEMBEDMYMALLOC'
ccflags ='-D_BSD_SIGNALS -D_BSD_TYPES -D_BSD_TIME -woff
1009,1110,1184 -OPT:Olimit=0:space=ON -DLANGUAGE_C
-DEMBEDMYMALLOC' stdchar='unsigned char', d_stdstdio=define,
usevfork=false
voidflags=15, castflags=0, d_casti32=define, d_castneg=define
intsize=4, alignbytes=8, usemymalloc=y, prototype=define
Linker and Libraries:
ld='cc', ldflags ='-n32'
libpth=/usr/lib32 /lib32
libs=-lm
libc=/usr/lib32/libc.so, so=so
useshrplib=true, libperl=libperl.so.4.4
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=''
cccdlflags=' ', lddlflags='-n32 -mips3 -shared'
Characteristics of this binary (from libperl):
Built under irix
Compiled at Apr 30 1998 00:54:41
@INC:
/usr/share/lib/perl5/irix-n32/5.00404
/usr/share/lib/perl5
/usr/share/lib/perl5/site_perl/irix-n32
/usr/share/lib/perl5/site_perl
/usr/share/lib/perl5/sgi_perl
.
--
M.T. Kreutzer
m.t.kreutzer@nospam.chem.rug.nl
m.t.kreutzer@nospam.stm.tudelft.nl
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Wed, 1 Sep 1999 05:13:01 -0400
From: "Tim" <orange_nurf@hotmail.com>
Subject: Doing a reverse lookup with ping?
Message-Id: <7qiqda$cem$1@nntp6.atl.mindspring.net>
I would like to use something to do a reverse lookup on an ip. I found a
script that does a ping, but can't seem to get it to use 'ping -a' to give
me the domain name associated with the IP.
How can it be done?
Thanks.
------------------------------
Date: 1 Sep 1999 12:17:55 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Doing a reverse lookup with ping?
Message-Id: <37cd0b63_2@newsread3.dircon.co.uk>
Tim <orange_nurf@hotmail.com> wrote:
> I would like to use something to do a reverse lookup on an ip. I found a
> script that does a ping, but can't seem to get it to use 'ping -a' to give
> me the domain name associated with the IP.
>
You dont need to do that -
use Socket;
$name = gethostbyaddr(inet_ntoa($ip));
/J\
--
"I'm about to say a naughty word so if you're easily offended you can
fuck off now" - Daisy Donovan, The 11 O'Clock Show
------------------------------
Date: 1 Sep 1999 08:18:35 -0400
From: gabor@vmunix.com (Gabor)
Subject: Re: editors??
Message-Id: <slrn7sq6cr.k2h.gabor@vnode.vmunix.com>
In comp.lang.perl.misc, Caper <stevencNOSPAM@nbnet.nb.ca> wrote :
# Any good Perl debuggers or editors to suggest?
Perl has a builtin debugger. As far as editors, whatever you're
comfortable with and can edit ascii text with.
------------------------------
Date: 1 Sep 1999 11:41:15 GMT
From: M.Ray@ulcc.ac.uk (Malcolm Ray)
Subject: Re: EMPLOYMENT OPPORTUNITY:Perl/Web Developer
Message-Id: <slrn7sq46r.eah.M.Ray@carlova.ulcc.ac.uk>
On Tue, 31 Aug 1999 21:18:27 GMT, hrdept@tucows.com <hrdept@tucows.com> wrote:
>open(REQUIRED, "$knowledge");
open(REQUIRED, $knowledge) or die "Catbert will dance on your head: $!";
--
Malcolm Ray University of London Computer Centre
------------------------------
Date: Wed, 01 Sep 1999 10:53:56 GMT
From: mbarieux2225@my-deja.com
Subject: Fork
Message-Id: <7qj0k0$atc$1@nnrp1.deja.com>
Hi,
I have two perl functions in two separate file
that I'd like to run in two different processes.
I did the following :
$return_val = fork;
if ($return_val == 0)
{
die "cannot fork : $!" unless defined ($process1
= open(PROCESS1, "/usr/bin/perl file1.pl | "));
while (<PROCESS1>)
{ # I put the result of the function in a record }
}
close (PROCESS1)
else
{
$return_val1 = fork ;
if ($return_val1 == 0)
{die "cannot fork : $!" unless defined
($process2 = open(PROCESS2, "/usr/bin/perl
file2.pl | "));
while (<PROCESS2>)
{I put the result of the function in the same
record }
}
close (PROCESS2)
}
# I then go through the entire record, and try to
display the results in a table
Problem : I have 3 processes : the main file
process and the two files. The main file is
displayed three times, and I then have two
separate tables with the datas in it. I guess
that it is displayed 1 time when it is executed,
and one time it exits from the child's process.
I'm very new to this, and would like to have a
clue on how to achieve that...
Regards.
Marc
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Wed, 1 Sep 1999 11:56:37 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: RE: I am new to perl
Message-Id: <Pine.HPP.3.95a.990901114740.22020B-100000@hpplus03.cern.ch>
On Tue, 31 Aug 1999, Larry Rosler wrote:
> In article <7qgpkp$alg$1@vnews.prima.com.ar> on Tue, 31 Aug 1999
> 17:41:13 -0300, Webmaster <webmaster@compre-ya.com> says...
>
> WHY do you quote the entire post after your one-line response???
That's an easy one: it's to signal to perceptive readers that the answer
will be bogus.
--
"Level playing field" is not a phrase we use much now
- Peter Walker, OFTEL, on uk.telecom
------------------------------
Date: Wed, 01 Sep 1999 00:03:41
From: "One Bored Guru " <One.Bored.Guru........@p0.f1.n30.z30.fidonet.org>
Subject: perl Ad
Message-Id: <00002811@madnet.net>
Attention Perl-5/Linux Programmers.
The Sync3 Developement Team is looking for Perl-5/Linux programmers
to help on an open source project writing a new type of bbs designed
for Linux and The Internet. If you think you have the skill and are
interested, please send email to devteam[at]sync3.com indicating your
interest and providing us with the relevant details pertaining to
your skill level and previous experience. Thank you for your time
and interest.
Steve Byers,
Project Administrator,
The Sync3 Project.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ The Talamasca Internet Newsgroup Gateway +
telnet://talamasca-bbs.com
------------------------------
Date: Wed, 1 Sep 1999 05:42:45 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Redirecting STDERR to STDOUT (on NT)
Message-Id: <MPG.1236bf14eb75675d989eff@nntp.hpl.hp.com>
In article <37cd4a05.164028843@news.netvision.net.il> on Wed, 01 Sep
1999 15:45:45 GMT, hoz <hoz@rocketmail.com> says...
> >how can I redirect STDERR to STDOUT so die "string" would work
> >correctly?
>
> try using eval
Ah, that's the ticket! 'eval'. Hmmm, nothing happened.
What on earth are you talking about?
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 01 Sep 1999 11:40:10 GMT
From: frederic.lemoine@manpower.be
Subject: Rename problem with FTP in Win32::Internet
Message-Id: <7qj3ao$cil$1@nnrp1.deja.com>
I wrote this
use Win32::Internet;
$INET = new Win32::Internet();
$INET->FTP($FTP, "Devweb3", "flemoine", "lala");
print $INET->GetResponse();
$FTP->Rename("art.txt", "art.new") or die $INET->Error(), qq(\n);
$FTP->Close();
and I get this
220 devweb3 Microsoft FTP Service (Version 4.0).
331 Password required for flemoine.
230 User flemoine logged in.
12003550 art.txt: Access is denied.
However, I can delete using $FTP->Delete("art.txt");
The file has no special attribute, and the directory has Everyone Full
Control permission.
What's wrong ?
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Wed, 01 Sep 1999 12:08:11 GMT
From: but86@my-deja.com
Subject: standalone perl apps on win/mac?
Message-Id: <7qj4v4$do6$1@nnrp1.deja.com>
hello
how can i make standalone perl programs for windows that support tk?
and what about my mac? is it possible to create perl standalones for
mac, too?
unitl now i used perl just as a scripting language for cgis, but perl is
really cool, and if it would be possible, i would love to create some
little desktop applications with it. they had to be GUI based and should
work on win and mac standalone. their goal would be text
manipulating/file operations (basically to update or configure other
perl scripts).
best regards,
werner butscher
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 1 Sep 1999 05:39:44 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: tied hash
Message-Id: <37cd1080@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
Peter Ziatek <pziatek@sgi.com> writes:
:How do I delete a record in a tied hash?
:When I try delete "$DB->{$key}{$field};" it doesn't delete it. I don't
:even get an error. I read in the camel book and it says it can't
:guarantee that it the delete function will work on a tied hash.
It's hard to say, because you're doing something wrong. My guess
is it should be
delete $db{$key};
All that isn't guaranteed is that the return value from delete
is the old value. Delete works fine:
DB<1> dbmopen(%H, "/tmp/htest", 0666)
DB<2> $H{fred} = "testing"
DB<3> dbmclose %H
DB<4> dbmopen(%H, "/tmp/htest", 0666)
DB<5> print $H{fred}
testing
DB<6> delete $H{fred}
DB<7> dbmclose %H
DB<8> dbmopen(%H, "/tmp/htest", 0666)
DB<9> print $H{fred}
You still have two bugs. It's hard to see what's going on. You seem
to be used $DB as a hash ref. Did you do this:
use Fcntl;
use DB_File;
$dbobj = tie(%dbhash, 'DB_File', '/tmp/foo.db', O_CREAT|O_RDWR, 0666);
die unless $dbobj;
$dbref = \%dbhash;
which would have worked for
delete $dbref->{"some key"}
beause it's the same as
delete $dbhash{"some key"}
but you can't use $dbobj that way, which is what perhaps you did.
Next, why are you double subscripting? This isn't write
delete $dbhash{$key}{$value}
because you don't need the value. And it makes no sense. But if you
really wanted to do this:
delete $dbhash{$key1}{$key2}
then you have a whole new kettle of fish. You can't access but
the top level directly.
DB<18> use Fcntl
DB<19> use MLDBM
DB<20> tie(%hash, 'MLDBM', "/tmp/db", O_CREAT|O_RDWR, 0666) or warn $!
DB<21> $hash{"key1"} = { "key2" => "val2", "key3" => "val3" }
DB<22> x $hash{"key1"}
0 HASH(0x83a23a0)
'key2' => 'val2'
'key3' => 'val3'
DB<23> $hr = $hash{"key1"}
DB<24> delete $hr->{"key2"}
DB<25> x $hr
0 HASH(0x83b2770)
'key3' => 'val3'
DB<26> $hash{"key1"} = $hr
DB<27> x \%hash
0 HASH(0x82ec218)
'key1' => HASH(0x83dc550)
'key3' => 'val3'
DB<28> dbmclose %hash
DB<29> tie(%hash, 'MLDBM', "/tmp/db", O_CREAT|O_RDWR, 0666) or warn $!
DB<30> x \%hash
0 HASH(0x82ec218)
'key1' => HASH(0x83e08dc)
'key3' => 'val3'
But I somehow doubt that that was your problem.
--tom
--
I'm not writing any more tapes, ever. --Andrew Hume
------------------------------
Date: Wed, 01 Sep 1999 11:09:12 GMT
From: Rohan Talip <rohan_talip@my-deja.com>
Subject: Uninstall Net::FTP ??
Message-Id: <7qj1gi$bbk$1@nnrp1.deja.com>
Hello,
Could someone please tell me how I uninstall Net::FTP as I somehow
installed it by mistake.
Now I can't use our web server for the FTP proxy since Net::FTP
deals with firewall proxies.
Thanks,
Rohan Talip.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Wed, 1 Sep 1999 12:30:59 +0100
From: "Simon Anthony" <santhony@ea.com>
Subject: Re: Using grep to match complete words
Message-Id: <rsq347dmj7147@corp.supernews.com>
Read the various man pages on regular expressions. In particular grep uses
"limited" regular
expressions (in most implementations it uses the exact same library routines
as ed.) In this
case "\<" and "/>" can be used to delimit a word.
For your example:
grep "\<$i\>" ...
Note -q can also be used to grep when one is not interested in the output,
viz:
for i in wordlist
do
grep -q "\<$i\>" uniquewords && {
actions...
}
done
Larry James wrote in message <7qgn0v$a15$1@hera.buffalointer.net>...
> I have a grep script to check for the presents of a word in a list
>of words. My problem is that if the current word is "hello" and the
>list has a word "hello2" because "hello2" has "hello" included, this
>will show up as found.
> My script goes as:
>
>---------------
>for i in wordlist
>do
> if [ ! "`grep $i uniquewords`" ]
> then
> echo adding $i...
> echo $i >>uniquewords
> fi
>done
>---------------
>
> Thanks in advance for any suggestions or comments.
>
> -- L. James
>
>--
>______________________________________________________________________
>Apollo III Communications (Buffalo's First ISP) Larry James
>716_896_0738 Office 716_896_0766 Fax Consultant/Programmer
>http://www.apollo3.com/~ljames ljames@apollo3.com Buffalo, New York
------------------------------
Date: Wed, 01 Sep 1999 11:46:01 GMT
From: but86@my-deja.com
Subject: What is DBI?
Message-Id: <7qj3ln$cst$1@nnrp1.deja.com>
Hello
I am looking for a method to connect to an MS Acces DB. Normally this
works over ODBC.
I ran over this DBI. Just out of interest: What is it, how can it be
used etc?
I am really new to databases an d have no idea about all that stuff
regards,
werner butscher
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Wed, 1 Sep 1999 13:58:02 +0100
From: "Chris Denman" <chris@inta.net.uk>
Subject: XML::Parser help needed
Message-Id: <7qj7p2$29tv$1@news2.vas-net.net>
I wonder if anyone can help me get started with the XML::Parser module.
I need some code to:
take some xml like this-
<people>
<person>
<name>Chris</name>
<age>28</age>
<sex>Male</sex>
<friends>
<friend>
<name>John</name>
<age>22</age>
<sex>Male</sex>
</friend>
<friend>
<name>Bob</name>
<age>21</age>
<sex>Male</sex>
</friend>
<friend>
<name>Sally</name>
<age>18</age>
<sex>Female</sex>
</friend>
</friends>
</person>
<person>
<name>Charlie</name>
<age>29</age>
<sex>Male</sex>
<friends>
<friend>
<name>Cyril</name>
<age>22</age>
<sex>Male</sex>
</friend>
<friend>
<name>Mark</name>
<age>21</age>
<sex>Male</sex>
</friend>
<friend>
<name>Samantha</name>
<age>18</age>
<sex>Female</sex>
</friend>
</friends>
</person>
</people>
and extract the content above into files stored in relevant directories-
directory people would contain subdirectories for each person
directory person.1 would contain a single file containing data for the first
person
directory person.2 woudl contain a single file containing data for the
second person
and so on....
in each person directory there would be a subdirectory for friends
in the friends directory there would be subdirectories for each friend
directory friend.1 would contain a single file containing data for the first
friend
and so on....
each single file would have the format:
field:data like so:
name:Chris\n
age:28\n
sex:Male\n
The actual task I have in mind is quite a bit more complex, but a solution
to the above will open my eyes as to how the module works.
Thanks,
Chris Denman
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. Due to their sizes, neither the Meta-FAQ nor
the FAQ are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq" from
almanac@ruby.oce.orst.edu.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 694
*************************************