[19531] in Perl-Users-Digest
Perl-Users Digest, Issue: 1726 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 10 14:10:30 2001
Date: Mon, 10 Sep 2001 11:10:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1000145414-v10-i1726@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 10 Sep 2001 Volume: 10 Number: 1726
Today's topics:
Re: Perl Version <demetros@vnet.ibm.com>
Re: Perl Version (Anno Siegel)
Possible in Perl, download via FTP a variable filename <edevries@footlocker.com>
Probelm with undefined atgumnets (Stan Brown)
Problem with expect <ludmilla.markowska@gmx.net>
Re: Problem with parsing more than one line ( Please HE (Ken Laird)
Re: Problem with parsing more than one line ( Please HE (Ken Laird)
Re: Problem with parsing more than one line ( Please HE (Randal L. Schwartz)
Re: Problem with parsing more than one line ( Please HE (Laird)
Problem with quote in SQL Query (Pott)
Re: Problem with quote in SQL Query (John J. Trammell)
Re: Problem with quote in SQL Query <philip@zaynar.demon.co.uk>
Re: Recommendations for a PERL editor (Jan Goyvaerts)
Re: Redirect eval output to socket problem (Anno Siegel)
Re: terminal Emulator (Doyle Rivers)
Re: terminal Emulator (Doyle Rivers)
Re: terminal Emulator (Doyle Rivers)
Warning on adding hash element (so)
Re: Warning on adding hash element (Tad McClellan)
Re: Warning on adding hash element (Mark Jason Dominus)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 10 Sep 2001 13:29:55 -0400
From: "George C. Demetros" <demetros@vnet.ibm.com>
Subject: Re: Perl Version
Message-Id: <3B9CF893.940C47AC@vnet.ibm.com>
The real reason why I need to determine the version of perl is I need to know within a C++ program the current version of /bin/perl. I'd
rather not start a separate process (unix platform) by doing a perl -v. So I figure if I can read a file within my program that would be
fairly fast. Along these lines, I wasn't sure if I embedded perl code within my c++ program whether that would start a separate process.
If it didn't, then that would also be a good way to do it.
Thanks again.
Bart Lateur wrote:
>
> George C. Demetros wrote:
>
> >Is there anyway to determine the version of perl without running the binary?
> >I know within a perl script you can look at the setting of $]. But I need to know
> >a fast way of determining this version without running perl.
>
> Eh, why? "perl -v" will tell you what it is. In addition, "perl -V" can
> tell you far more than you ever wanted to know (tm).
>
> --
> Bart.
------------------------------
Date: 10 Sep 2001 18:01:46 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Perl Version
Message-Id: <9niv6a$b0b$1@mamenchi.zrz.TU-Berlin.DE>
According to George C. Demetros <demetros@vnet.ibm.com>:
[Rearranged. Please place your reply below the quoted material.]
> Bart Lateur wrote:
> >
> > George C. Demetros wrote:
> >
> > >Is there anyway to determine the version of perl without running the binary?
> > >I know within a perl script you can look at the setting of $]. But I
> need to know
> > >a fast way of determining this version without running perl.
> >
> > Eh, why? "perl -v" will tell you what it is. In addition, "perl -V" can
> > tell you far more than you ever wanted to know (tm).
> >
> > --
> > Bart.
> The real reason why I need to determine the version of perl is I need to
> know within a C++ program the current version of /bin/perl. I'd
> rather not start a separate process (unix platform) by doing a perl -v.
> So I figure if I can read a file within my program that would be
> fairly fast. Along these lines, I wasn't sure if I embedded perl code
> within my c++ program whether that would start a separate process.
> If it didn't, then that would also be a good way to do it.
The only reliable way to find the version of /bin/perl is to run it.
If you go to the trouble (I don't really know how much trouble it is)
of embedding perl, you can run it in your own process space, but I
wouldn't worry too much about an extra call to perl. If you don't want
to parse the output of "perl -v", run "perl -e 'print $]'". See perldoc
perlvar for the format of $] and its possible alternative $^V.
Anno
------------------------------
Date: Mon, 10 Sep 2001 17:50:19 +0200
From: "Eduard de Vries" <edevries@footlocker.com>
Subject: Possible in Perl, download via FTP a variable filename based on date?
Message-Id: <tppo3tbpl053ed@news.demon.nl>
Hi,
I need to do the following, I need to download a file from an FTP server, I
can automatically dial in to the server and start the ftp connection.
But then I need to enter test20010910.csv as a file name, and tomorrow it is
the filename of tomorrow, obviously the date is made 1 higher.
Is this possible with Perl?
If yes, I will try and learn Perl.
Thanks in advance,
Eduard de Vries
info@edrox.demon.nl
------------------------------
Date: 10 Sep 2001 13:25:21 -0400
From: stanb@panix.com (Stan Brown)
Subject: Probelm with undefined atgumnets
Message-Id: <9nit21$8kn$1@panix2.panix.com>
A kind member of this group showed me a neat trick to print out the
arguments to a given function. It goes like this:
join ', ', map { "Arg$_ ->$_[$_]<-" } 0 .. $#_;
This works great _except_ when I pass in undef for an argumentm then I get
a warning about concatenating an unitliazed variable.
How can I improve thsi to allow for this case?
------------------------------
Date: Mon, 10 Sep 2001 19:08:20 +0200
From: "Ludmilla Markowska" <ludmilla.markowska@gmx.net>
Subject: Problem with expect
Message-Id: <9nis27$h6u$01$1@news.t-online.com>
Hi all,
i have to write a perl script to add users to the IMAP-Server Cyrus. So i
was told to use Expect.pm. After searching the web and deja for hours i
can´t find a howto or explanation how to use it. Somebody can give me a
hint/link where to learn a bit about using Perl and Expect.
thanks in advance
ludmilla
------------------------------
Date: Mon, 10 Sep 2001 15:50:11 GMT
From: kenlaird@yahoo.com (Ken Laird)
Subject: Re: Problem with parsing more than one line ( Please HELP )
Message-Id: <Ti5n7.84743$ju1.2603775@amsnews02.chello.com>
In article <m1n143ksx4.fsf@halfdome.holdit.com>, merlyn@stonehenge.com says...
>
>>>>>> "Laird" == Laird <kenlaird@yahoo.com> writes:
>
>Laird> I've got this file:
>Laird> ...
>Laird> # name -a
>Laird> service number1234 comments
>
>Laird> # name-b
>Laird> service numberxxxx comments
>
>Laird> # name-c
>Laird> service numberyyyy
>
>Laird> # name-d name-e comments
>Laird> service numberzzzz
>Laird> service numbernnnn
>
>Laird> # name-other comments
>Laird> service number4321
>Laird> ...
>Laird> Every name line is followed by a service with a number.
>Laird> Service is always the same.
>Laird> For example numberxxxx belongs with name-b,
>Laird> number4321 belongs with name-other.
>Laird> But there are lines with more than 1 name ,
>Laird> like the this with name-d and name-e
>Laird> followed by 2 lines with the respective numbers.
>Laird> So numberzzzz belongs with name-d and
>Laird> numbernnnn belongs with name-e.
>
>Laird> So my problem is how to parse a line with more name 1 name in it,
>Laird> followed by the line with the respective numbers.
>
>Can you distinguish "comments" somehow, before knowing how many
>"service" line there are?
>
>That is, on the line
>
> # name-d name-e comments
>
>how do you know "comments" is a comment? Is there a pattern that
>matches the name but not the comments?
>
>--
>Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
><merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
>Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
>See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
Hi Randal,
I know comments are comments because they dont begin with "name" and because
they are in uppercase.
In fact I would like to transform this
...
# name-d name-e comments
service numberzzzz
service numbernnnn
...
into that
...
# name-d comments
service numberzzzz
# name-e comments
service numbernnnn
...
By the way , I have Learning Perl&Effective Perl Programming
but still it doesnt make me a whizz at Perl.
Best Regards
Ken Laird
------------------------------
Date: Mon, 10 Sep 2001 15:58:20 GMT
From: kenlaird@yahoo.com (Ken Laird)
Subject: Re: Problem with parsing more than one line ( Please HELP )
Message-Id: <wq5n7.84788$ju1.2605131@amsnews02.chello.com>
In article <7gjpptc2tb69k38v4c1ssvb6948u3hr2br@4ax.com>, Thomas@Baetzler.de
says...
>
>On 10 Sep 2001 07:02:57 -0700, kenlaird@yahoo.com (Laird) wrote:
>>I've got this file:^
>[...]
>>So my problem is how to parse a line with more name 1 name in it,
>>followed by the line with the respective numbers.
>
>more than one?
>
>You might consider keeping state while reading. This should work fine
>for well-formed input:
>
>open( IN, $yourdatafile )
> or die "Can't open input $yourdatafile: $!\n";
>
>my $curr_name;
>
>while( defined( my $line = <IN> ) ){
> if( $line =~ m/name/ ){
> # do something with a name line
> $curr_name = 'whatever';
> } elsif( $line =~ m/service/ ) {
> # do something with service data based on
> # the fact that you know $curr_name
> }
>}
>
>Can' t really say more (except use Parse::RecDescent :-)) unless we
>know more about your data.
>
>HTH,
>use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
>split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
>'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
>$_--;$i++}@r;print"$t\n";
In fact I would like this
...
# name-d name-e comments
service numberzzzz
service numbernnnn
to become this
...
# name-d comments
service numberzzzz
# name-e comments
service numbernnnn
--
Best regards
Ken Laird
------------------------------
Date: 10 Sep 2001 09:00:05 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Problem with parsing more than one line ( Please HELP )
Message-Id: <m1r8tfjat6.fsf@halfdome.holdit.com>
>>>>> "Ken" == Ken Laird <kenlaird@yahoo.com> writes:
Ken> I know comments are comments because they dont begin with "name"
Ken> and because they are in uppercase.
Hmm. How about providing a *real* example, and then a *description*
of how it could vary then, instead of providing a *fake* example with
*no* specification? I'm not sure how psychic you expect us to be, but
I would NEVER have predicted the comments were "uppercase", and that's
how you'd know it was a comment!
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: 10 Sep 2001 10:58:39 -0700
From: kenlaird@yahoo.com (Laird)
Subject: Re: Problem with parsing more than one line ( Please HELP )
Message-Id: <94a02505.0109100958.641cb522@posting.google.com>
Thomas Bätzler <Thomas@Baetzler.de> wrote in message news:<7gjpptc2tb69k38v4c1ssvb6948u3hr2br@4ax.com>...
> On 10 Sep 2001 07:02:57 -0700, kenlaird@yahoo.com (Laird) wrote:
> >I've got this file:^
> [...]
> >So my problem is how to parse a line with more name 1 name in it,
> >followed by the line with the respective numbers.
>
> more than one?
>
> You might consider keeping state while reading. This should work fine
> for well-formed input:
>
> open( IN, $yourdatafile )
> or die "Can't open input $yourdatafile: $!\n";
>
> my $curr_name;
>
> while( defined( my $line = <IN> ) ){
> if( $line =~ m/name/ ){
> # do something with a name line
> $curr_name = 'whatever';
> } elsif( $line =~ m/service/ ) {
> # do something with service data based on
> # the fact that you know $curr_name
> }
> }
>
> Can' t really say more (except use Parse::RecDescent :-)) unless we
> know more about your data.
>
> HTH,
> use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
> split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
> '"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
> $_--;$i++}@r;print"$t\n";
In fact I would like to change this
...
# name-d name-e comments
service numberzzzz
service numbernnnn
into this
...
# name-d comments
service numberzzzz
# name-e comments
service numbernnnn
Best Regards,
Ken Laird
------------------------------
Date: 10 Sep 2001 10:47:59 -0700
From: pottr@san.rr.com (Pott)
Subject: Problem with quote in SQL Query
Message-Id: <900bed6e.0109100947.495ffebf@posting.google.com>
I'm trying to run a query that works just fine in ISQL/w, but when I
run it I'm having some problems witht the quotes that I've entered in.
These are titles that I'm not sure how to enter into a perl script. I
know it has to do with my quotes around TOTAL and DAY, but my attempts
to fix it are in vain. Hope this isn't too little info.
Much appreciated.
$sql = "select count(id)"Total", category, datepart(day,occured)"Day"
from asset..eventlog ";
------------------------------
Date: 10 Sep 2001 17:57:03 GMT
From: trammell@haqq.hypersloth.invalid (John J. Trammell)
Subject: Re: Problem with quote in SQL Query
Message-Id: <slrn9ppvnf.o84.trammell@haqq.hypersloth.net>
On 10 Sep 2001 10:47:59 -0700, Pott <pottr@san.rr.com> wrote:
> I'm trying to run a query that works just fine in ISQL/w, but when I
> run it I'm having some problems witht the quotes that I've entered in.
> These are titles that I'm not sure how to enter into a perl script. I
> know it has to do with my quotes around TOTAL and DAY, but my attempts
> to fix it are in vain. Hope this isn't too little info.
> Much appreciated.
>
> $sql = "select count(id)"Total", category, datepart(day,occured)"Day"
> from asset..eventlog ";
Use single quotes:
$sql = 'select count(id)"Total", category, datepart(day,occured)"Day"
from asset..eventlog ';
--
IAAMOAC.
------------------------------
Date: Mon, 10 Sep 2001 19:02:19 +0100
From: Philip Taylor <philip@zaynar.demon.co.uk>
Subject: Re: Problem with quote in SQL Query
Message-Id: <yiJySCArAQn7Ewow@zaynar.demon.co.uk>
In article <900bed6e.0109100947.495ffebf@posting.google.com>, Pott
<pottr@san.rr.com> writes
>I'm trying to run a query that works just fine in ISQL/w, but when I
>run it I'm having some problems witht the quotes that I've entered in.
>These are titles that I'm not sure how to enter into a perl script. I
>know it has to do with my quotes around TOTAL and DAY, but my attempts
>to fix it are in vain. Hope this isn't too little info.
>Much appreciated.
>
>$sql = "select count(id)"Total", category, datepart(day,occured)"Day"
>from asset..eventlog ";
Either escape the "s inside the string:
$sql = "select count(id)\"Total\", category, datepart(day,occured)
\"Day\" from asset..eventlog ";
or use single quotes around the string:
$sql = 'select count(id)"Total", category, datepart(day,occured)"Day"
from asset..eventlog ';
or use qq:
$sql = qq{select count(id)"Total", category, datepart(day,occured)"Day"
from asset..eventlog };
--
Philip Taylor
philip @ zaynar . demon . co . uk
http://robowarriors.ultrastore.com/legoworld.shtml
-- If the Earth was made of Lego...
------------------------------
Date: 10 Sep 2001 09:49:02 -0700
From: jg@jgsoft.com (Jan Goyvaerts)
Subject: Re: Recommendations for a PERL editor
Message-Id: <305aa4dd.0109100849.796e8105@posting.google.com>
"sabin" <sabin@cornhusker.net> wrote in message news:<3b92703a_1@Usenet.com>...
> > Can someone recommend to me a reliable Windows-based editor that WON'T
> > create these problems for me ?
>
> Yep.
> http://www.jgsoft.com
EditPad Pro now has support for custom syntax coloring schemes.
A Perl scheme can be downloaded from http://www.editpadpro.com/cscs.html
Kind regards,
Jan Goyvaerts.
--
EditPad Pro 4.3: The text editor you will want to carry with you
on a floppy disk wherever you go! -- http://www.editpadpro.com
DeployMaster 2.1: Deliver your software with a favorable
first impression -- http://www.deploymaster.com
HelpScribble 6.0: The complete help authoring tool that makes
your job easy -- http://www.jgsoft.com/helpscr.html
------------------------------
Date: 10 Sep 2001 15:53:21 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Redirect eval output to socket problem
Message-Id: <9ninlh$3nu$2@mamenchi.zrz.TU-Berlin.DE>
According to Bart Lateur <bart.lateur@skynet.be>:
> Daniel wrote:
>
> >$command = "print \"this text wants to be printed on the socket NS\"";
> >print NS "line one\n";
> >eval($command); # I want to redirect the output from eval to NS...
> >print NS "line two\n";
> >
> >the example prints "line one" and "line two" to the socket NS but the
> >output from eval comes to STDOUT.
>
> Does
>
> select NS;
>
> do any good?
That is a good idea, and it should help if Perl does the printing.
However, seeing a string eval in what is probably a server application
makes me wonder what $command contains, where it comes from, the taint
status, and things...
Also, why does whatever $command evals to have to print to STDOUT?
Isn't there a better way to organize things?
Anno
------------------------------
Date: 10 Sep 2001 09:07:13 -0700
From: dwrivers@micron.com (Doyle Rivers)
Subject: Re: terminal Emulator
Message-Id: <e44d6d83.0109100807.4521f968@posting.google.com>
Philip Newton <pne-news-20010910@newton.digitalspace.net> wrote in message news:<nuhoptccek3rqn3ckq98g1h7nl05uqkmbm@4ax.com>...
> [Newsgroups trimmed to comp.lang.perl.misc; please include a
> Followup-To: header in crossposted messages]
>
> On Mon, 10 Sep 2001 04:38:47 GMT, doylerivers@home.com (Doyle Rivers)
> wrote:
>
> > Does anyone know of an existing perl terminal emulator program?
> > I would like to be able to connect to a server via telnet and run
> > various scripts, however the Net::Telnet module is not sufficient for
> > my needs.
>
> You know, it would help if you said what your needs were and how they
> are not covered by Net::Telnet. Your message was about as informative as
> "it doesn't work".
>
> Cheers,
> Philip
Forgive the incomplete description of my problem. Here is a bit more
detail:
I would like to be able to connect to a telnet server with full
interaction (as if I were running a unix/dos telnet session), having
all data from the server printed to the screen as I recieve it, and
sending all data I input (via STDIN)to the server. Further more I
would like to be able to invoke scripts to automate various task while
connected. These scripts would basically be expect code.
If such an emulator is not already in existance Would using pipes
to/from the telnet command (win32 or unix) be effective for this?
Below is a portion of code I tried to use as a terminal
emulator(adapted from O'Reilly's Perl Cookbook):
#! /usr/local/bin/perl -w
use IO::Socket::INET;
my $host="some_host";
my $port="23";
$socket=IO::Socket::INET->new(PeerAddr => $host,
PeerPort => $port,
Proto => "tcp",
Type => SOCK_STREAM)
or die "Couldn't Connect to $host:$port : $!\n";
$socket->autoflush(1);
$childPID = fork();
if ($childPID)
{
while ($line = defined($socket))
{
print STDOUT $line;
}
kill("TERM" => $childPID);
}
else
{
while (defined($line=<STDIN>))
{
print $socket $line;
}
}
------------------------------
Date: Mon, 10 Sep 2001 18:00:29 GMT
From: doylerivers@home.com (Doyle Rivers)
Subject: Re: terminal Emulator
Message-Id: <3b9cff8b.302725@news.cableone.net>
On Mon, 10 Sep 2001 04:38:47 GMT, doylerivers@home.com (Doyle Rivers)
wrote:
>Does anyone know of an existing perl terminal emulator program?
>I would like to be able to connect to a server via telnet and run
>various scripts, however the Net::Telnet module is not sufficient for
>my needs.
>
>Anyway, if you know of a perl terminal emulator out there please let
>me know, it will save me a lot of time having to figure out how to
>write one myself.
>
>Thanks,
>Doyle Rivers
>
>Doyle Rivers
>
>*********************************************************************
>"But God did not send the Son into the world to judge the world,
>but that the world should be saved through Him." John 3:17
Forgive the incomplete description of my problem. Here is a bit more
detail:
I would like to be able to connect to a telnet server with full
interaction (as if I were running a unix/dos telnet session), having
all data from the server printed to the screen as I receive it, and
sending all data I input (via STDIN)to the server. Further more I
would like to be able to invoke scripts to automate various task while
connected. These scripts would basically be expect code.
If such an emulator is not already in existence Would using pipes
to/from the telnet command (win32 or unix) be effective for this?
Below is a portion of code I tried to use as a terminal
emulator(adapted from O'Reilly's Perl Cookbook):
#! /usr/local/bin/perl -w
use IO::Socket::INET;
my $host="some_host";
my $port="23";
$socket=IO::Socket::INET->new(PeerAddr => $host,
PeerPort => $port,
Proto => "tcp",
Type => SOCK_STREAM)
or die "Couldn't Connect to $host:$port : $!\n";
$socket->autoflush(1);
$childPID = fork();
if ($childPID)
{
while ($line = defined($socket))
{
print STDOUT $line;
}
kill("TERM" => $childPID);
}
else
{
while (defined($line=<STDIN>))
{
print $socket $line;
}
}
Doyle Rivers
*********************************************************************
"But God did not send the Son into the world to judge the world,
but that the world should be saved through Him." John 3:17
------------------------------
Date: Mon, 10 Sep 2001 18:02:27 GMT
From: doylerivers@home.com (Doyle Rivers)
Subject: Re: terminal Emulator
Message-Id: <3b9dfffc.415807@news.cableone.net>
On 10 Sep 2001 07:45:33 -0500, claird@starbase.neosoft.com (Cameron
Laird) wrote:
>In article <3B9C6AA5.D583FFAD@earthlink.net>,
>Benjamin Goldberg <goldbb2@earthlink.net> wrote:
>>Doyle Rivers wrote:
>>>
>>> Does anyone know of an existing perl terminal emulator program?
>>> I would like to be able to connect to a server via telnet and run
>>> various scripts, however the Net::Telnet module is not sufficient for
>>> my needs.
>>>
>>> Anyway, if you know of a perl terminal emulator out there please let
>>> me know, it will save me a lot of time having to figure out how to
>>> write one myself.
>>
>>Look into the following modules, available from CPAN:
>>Ptty
>>IO::Pty, IO::Tty
>>
>>And things which use these:
>>Expect
>>IPC::Run
>>
>>I'm sure one of these will do what you want.
>>Probably you'll want to use Expect and spawn the "telnet" program.
> .
> .
> .
>Expect is indeed wonderful.
>
>How does Net::Telnet fail you?
>
>The Jeffs write on exactly this question in their columns on
>Expect for Perl at <URL:
>http://search.cpg.com/query.html?col=&ht=0&qp=&qs=&qc=&pw=100%25&ws=0&la=&qm=1&si=0&rf=1&qm=1&ct=1914607132 >
For a more complete description of my issue please see my response to
Phillip above.
thanks
Doyle Rivers
*********************************************************************
"But God did not send the Son into the world to judge the world,
but that the world should be saved through Him." John 3:17
------------------------------
Date: 10 Sep 2001 08:37:38 -0700
From: soosterh@my-deja.com (so)
Subject: Warning on adding hash element
Message-Id: <db6cb1f3.0109100737.3f0726e1@posting.google.com>
Hello all:
I have a subroutine that accepts a reference to a hash.
Now I want to add an element to that hash.
The following line does actually work, but with
use strict enabled I get a warning...
$hash_ref->{ 'subHash' } = { -option1=>'val1', -option2=>'val2' };
produces...
Use of uninitialized value at (eval 11) line 17.
Being as this is in a CGI script I want to be rather careful when
I get warning like this -- even though the options are getting set.
Note that:
$hash_ref->{ 'subHash' } = 'value';
Does not produce any warnings...
Thanks
SammyO
------------------------------
Date: Mon, 10 Sep 2001 16:03:15 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Warning on adding hash element
Message-Id: <slrn9ppmbd.uji.tadmc@tadmc26.august.net>
so <soosterh@my-deja.com> wrote:
>
>The following line does actually work, but with
>use strict enabled I get a warning...
>
>$hash_ref->{ 'subHash' } = { -option1=>'val1', -option2=>'val2' };
I cannot duplicate your problem. There is something you are not
telling us...
----------------------------
#!/usr/bin/perl -w
use strict;
my $hash_ref;
$hash_ref->{ 'subHash' } = { -option1=>'val1', -option2=>'val2' };
----------------------------
Produces no messages.
>produces...
>Use of uninitialized value at (eval 11) line 17.
^^^^^^^^
What's that? There is for sure something going on that you
are not telling us...
>Note that:
>$hash_ref->{ 'subHash' } = 'value';
>Does not produce any warnings...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Neither does the code you provide above, so we cannot help you.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 10 Sep 2001 17:08:45 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Warning on adding hash element
Message-Id: <3b9cf39b.c66$2a0@news.op.net>
In article <db6cb1f3.0109100737.3f0726e1@posting.google.com>,
so <soosterh@my-deja.com> wrote:
>Hello all:
>
>I have a subroutine that accepts a reference to a hash.
>Now I want to add an element to that hash.
>The following line does actually work, but with
>use strict enabled I get a warning...
>
>$hash_ref->{ 'subHash' } = { -option1=>'val1', -option2=>'val2' };
>
>produces...
>Use of uninitialized value at (eval 11) line 17.
This does not mean line 17 of the file your program is in. It means
line 17 of the string that is being passed to 'eval'.
If the line you showed above is line 17 of your program, you are
looking in the wrong place.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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.
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 V10 Issue 1726
***************************************