[22848] in Perl-Users-Digest
Perl-Users Digest, Issue: 5069 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 3 18:05:58 2003
Date: Tue, 3 Jun 2003 15:05:11 -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 Tue, 3 Jun 2003 Volume: 10 Number: 5069
Today's topics:
Accounting File Help <nospam.hciss@yahoo.com>
Re: Accounting File Help <noreply@gunnar.cc>
Re: Accounting File Help (Tad McClellan)
Re: Accounting File Help <nospam.hciss@yahoo.com>
Re: Comparing Arrays (Jday)
Re: Directory Notification in Unix? <bik.mido@tiscalinet.it>
Re: Help: Sort HOH by value? (entropy123)
Re: Help: Sort HOH by value? <nobody@dev.null>
Re: Help: Sort HOH by value? ctcgag@hotmail.com
HTTP digest authentication in perl? (Corey_G)
I Need A Favour From US and Ca Citizens Please !! <motgage@mgage.com>
Re: Is there a bail() function? <wsegrave@mindspring.com>
Re: Is there a bail() function? (Shabble)
Re: move() from File::Copy package fails with cross-dev (Carlton Brown)
n-gram for words (slash)
Re: n-gram for words (Jay Tilton)
Re: n-gram for words <ddunham@redwood.taos.com>
Re: n-gram for words <nobody@dev.null>
Passing Hash To Subroutine Question <mooseshoes@gmx.net>
Re: Passing Hash To Subroutine Question <me@verizon.invalid>
Re: Passing Hash To Subroutine Question <mooseshoes@gmx.net>
Re: Passing Hash To Subroutine Question <noreply@gunnar.cc>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 3 Jun 2003 12:02:23 -0500
From: "Matt" <nospam.hciss@yahoo.com>
Subject: Accounting File Help
Message-Id: <Iw4Da.29$4f4.22440@news.uswest.net>
I need to do some sort of logging with perl. Basically I will have a
username and about 100 numeric accounting entries for that username.
Here's how it works. Every hour I will collect accounting data for users.
Example george and tom.
george 50, 901, 30
tom 47, 250, 1100
Now I need to do a few things. I need to obtain a list of all the users in
the database. If say a user does not exist in the database I need to create
him. If he does exist I need to append the latest accounting entry to him.
If he has over 100 accounting entries I need to remove the oldest ones until
he only has 100 entries. I also need to add up all his entries to get a
total. If the total is zero he is likely not active anymore so I need to
delete him from the database.
Can someone give me shove in the right direction with this? I would like to
stick with simple text files for this if thats possible. If not whatever it
takes.
Thanks
Matt
------------------------------
Date: Tue, 03 Jun 2003 20:33:56 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Accounting File Help
Message-Id: <bbipnl$9u6m3$1@ID-184292.news.dfncis.de>
Matt wrote:
> I need to do some sort of logging with perl.
<snip>
> Can someone give me shove in the right direction with this?
Start studying the parts of the docs and FAQ that deals with reading
and writing to files etc.
Write the program.
If you would encounter one or two _particular_ problems when doing so,
I suppose you may get proper help here. But only when you have
actually given it a try by yourself.
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Tue, 3 Jun 2003 14:38:16 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Accounting File Help
Message-Id: <slrnbdpu98.hue.tadmc@magna.augustmail.com>
Matt <nospam.hciss@yahoo.com> wrote:
> I need to obtain a list of all the users in
> the database.
perldoc -f open
> If say a user does not exist in the database I need to create
> him.
See the "hash" data type in:
perldoc perldata
and also
perldoc -f exists
> If he does exist I need to append the latest accounting entry to him.
The concatenation operator is dot, see
perldoc perlop
> If he has over 100 accounting entries I need to remove the oldest ones until
> he only has 100 entries.
perlop also has operators for comparing numbers.
> I also need to add up all his entries to get a
> total.
perlop also has operators for computing addition.
> If the total is zero he is likely not active anymore so I need to
> delete him from the database.
perldoc -f delete
> Can someone give me shove in the right direction with this?
See above.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 3 Jun 2003 16:43:16 -0500
From: "Matt" <nospam.hciss@yahoo.com>
Subject: Re: Accounting File Help
Message-Id: <4E8Da.409$Lw1.41106@news.uswest.net>
> > Can someone give me shove in the right direction with this?
>
>
> See above.
Thanks! Thats a good shove.
Matt
------------------------------
Date: 3 Jun 2003 10:33:23 -0700
From: dayjp@yahoo.com (Jday)
Subject: Re: Comparing Arrays
Message-Id: <827501f5.0306030933.1a617bed@posting.google.com>
thank you for this, i really appreciate the direction as i wasn't
aware of perldoc. this will help a great deal!!!
"J. Gleixner" <glex_nospam@qwest.net> wrote in message news:<WzQCa.397$CY.60971@news.uswest.net>...
> Jday wrote:
> > Would anybody have any idea how to compare two arrays (@array1 and
> > @array2) and pull out the data from @array2 that is not contained in
> > @array1? I am a perl newbie and have managed to hit my knowledge
> > threshold and need ideas. Please help!!! It is MUCH appreciated.
> > Thank you.
>
> perldoc -q "How do I compute the difference of two arrays"
------------------------------
Date: Wed, 04 Jun 2003 00:05:20 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Directory Notification in Unix?
Message-Id: <ut2qdv07jpo3g5qug59dpa16kt3798bd3t@4ax.com>
On 31 May 2003 21:09:07 +0100, Brian McCauley <nobull@mail.com> wrote:
>> I'm looking for something like Win32::ChangeNotify except that it
>> needs to run on Solaris. For those who don't know, it notifies you
>> when something has happened in a particular directory.
>There is no standard Unix feature for this.
>This is really a Unix question.
So, may we say that we finally found a win* feature that *nices don't
provide? OK, then one would have to argue wether this is a useful
feature or not... if I understand correctly, this is the kind of
facility exploited e.g. in a file browser to instantly update the
visual representation of a "folder" as files are added/removed/etc.,
isn't it?
Michele
--
$\=q.,.,$_=q.print' ,\g,,( w,a'c'e'h,,map{$_-=qif/g/;chr
}107..q[..117,q)[map+hex,split//,join' ,2B,, w$ECDF078D3'
F9'5F3014$,$,];];$\.=$/,s,q,32,g,s,g,112,g,y,' , q,,eval;
------------------------------
Date: 3 Jun 2003 09:10:36 -0700
From: email_entropy123@yahoo.com (entropy123)
Subject: Re: Help: Sort HOH by value?
Message-Id: <90cdce37.0306030810.ea5b195@posting.google.com>
Xho,
HoH = a Hash of Hashes (I've been yelled at a few times for NOT using
HoH :()
%HoH <- refers to a hash o hashes
$HoH{$key1}{$key2} = $value <-This HoH ?element? two keys give a
particular value
For example:
# Molecule
#
# C1=C2
# / \
#C3 C4
$HoH{C1}{C2} = 2 #Double Bond
$HoH{C2}{C1} = 2 #Double Bond
$HoH{C1}{C3} = 1 #Single Bond
$HoH{C3}{C1} = 1 #Single Bond
$HoH{C2}{C4} = 1 #Single Bond
$HoH{C4}{C2} = 1 #Single Bond
After some consideration I don't want to sort by $value, but by number
of keys. Any suggestions on how to do this?
Thanks,
entropy
------------------------------
Date: Tue, 03 Jun 2003 18:29:26 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: Help: Sort HOH by value?
Message-Id: <3EDCE8C0.7020707@dev.null>
entropy123 wrote:
> Xho,
>
> HoH = a Hash of Hashes (I've been yelled at a few times for NOT using
> HoH :()
>
> %HoH <- refers to a hash o hashes
>
> $HoH{$key1}{$key2} = $value <-This HoH ?element? two keys give a
> particular value
>
> For example:
> # Molecule
> #
> # C1=C2
> # / \
> #C3 C4
>
> $HoH{C1}{C2} = 2 #Double Bond
> $HoH{C2}{C1} = 2 #Double Bond
> $HoH{C1}{C3} = 1 #Single Bond
> $HoH{C3}{C1} = 1 #Single Bond
> $HoH{C2}{C4} = 1 #Single Bond
> $HoH{C4}{C2} = 1 #Single Bond
>
> After some consideration I don't want to sort by $value, but by number
> of keys.
What does this mean? What are the things that you want to put in order?
The (Ci,Cj) pairs? The values (2,2,1,1,1,1)? The second keys for a fixed
first key? I just don't understand what you are trying to do here.
>Any suggestions on how to do this?
>
> Thanks,
> entropy
>
------------------------------
Date: 03 Jun 2003 18:41:17 GMT
From: ctcgag@hotmail.com
Subject: Re: Help: Sort HOH by value?
Message-Id: <20030603144117.691$yi@newsreader.com>
email_entropy123@yahoo.com (entropy123) wrote:
> Xho,
>
> HoH = a Hash of Hashes (I've been yelled at a few times for NOT using
> HoH :()
"HoH" means a hash of hashes, a datastructure which you should use when
appropriate. The actual term "HoH" is not Perl, it is an (English)
abbreviation used to stand for a Perl concept/data structure.
$HoH is a scalar variable which has the misleading name "HoH".
>
> %HoH <- refers to a hash o hashes
Well, I'd say that \%HoH refers to a hash of hash(reference)es, but
I know what you mean.
> $HoH{$key1}{$key2} = $value <-This HoH ?element? two keys give a
> particular value
OK, here "$HoH{...." is accessing part of %HoH. Just $HoH, without
the curly, is a scalar which has the misleading name of "HoH".
I emphasize this not because your usage confuses me, but because I've
seen your usage confuse you several times.
BTW, $key2 may exist as a variable, but there is no unified concept behind
it, i.e. there is no second level hash. There is one second level hash
for each value of "$key1", and each of these hashes is independent, and
each is oblivious of the others, unless your code forces them acknowledge
each other.
> For example:
> # Molecule
> #
> # C1=C2
> # / \
> #C3 C4
>
> $HoH{C1}{C2} = 2 #Double Bond
> $HoH{C2}{C1} = 2 #Double Bond
> $HoH{C1}{C3} = 1 #Single Bond
> $HoH{C3}{C1} = 1 #Single Bond
> $HoH{C2}{C4} = 1 #Single Bond
> $HoH{C4}{C2} = 1 #Single Bond
>
> After some consideration I don't want to sort by $value, but by number
> of keys. Any suggestions on how to do this?
Sure.
my @x = sort { keys %{$HoH{$a}} <=> keys %{$HoH{$b}} } keys %HoH;
here, $x[0] is the "name" of (i.e. the value of "$key1" corresponding to)
the smallest hash, in this case either "C3" or "C4", since they
are tied for smallest, and $HoH{$x[0]} is a reference to the smallest hash.
If you don't care about the names, then you can simplify by:
my @x = sort { keys %$a <=> keys %$b } values %HoH;
now $x[0] is a reference to the smallest hash.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service New Rate! $9.95/Month 50GB
------------------------------
Date: 3 Jun 2003 08:09:08 -0700
From: corey@test-tools.net (Corey_G)
Subject: HTTP digest authentication in perl?
Message-Id: <68f50fd5.0306030709.a3b42de@posting.google.com>
has anyone done HTTP Digest authentication in Perl (not with LWP, i
need to do it for use with IO::socket)? I am trying to calculate the
digest response based on a nonce sent by a challenge from a server and
not having much luck.
-Corey
------------------------------
Date: Tue, 03 Jun 2003 15:37:53 -0500
From: <motgage@mgage.com>
Subject: I Need A Favour From US and Ca Citizens Please !!
Message-Id: <r#isBAhKDHA.560@lime.oak-park.us>
Please May I Ask For All US People To FIll This Form In As Best They Can Please !!
Thankyou So Much
http://www.wuyi-88.com/2/index.asp?RefID=245795
------------------------------
Date: Tue, 3 Jun 2003 10:51:24 -0500
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: Is there a bail() function?
Message-Id: <bbigl4$8js$1@slb0.atl.mindspring.net>
"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:bbi5ru$kr9$1@mamenchi.zrz.TU-Berlin.DE...
> Unknown Poster <use63net@yahoo.com> wrote in comp.lang.perl.misc:
> > I can't find it in Programming Perl 3E, but it's used like die() in
> > Learning Perl 2E, as in the following:
> >
> > open(CHANDLE, "+< $CHATNAME") || bail ("cannot open $CHATNAME: $!");
>
> Are you sure that line is in _Learning Perl_? "$CHATNAME" in all-caps
> looks awfully strange for something that must have been run by Randal
> Schwartz.
Page 201, line 9 - the first line of code on the page.
Bill Segraves
------------------------------
Date: 3 Jun 2003 11:17:14 -0700
From: da_bisti@yahoo.com (Shabble)
Subject: Re: Is there a bail() function?
Message-Id: <8fc4ae12.0306031017.1a72d9ef@posting.google.com>
use63net@yahoo.com (Unknown Poster) wrote in message news:<c62e93ec.0306021044.62f2c78e@posting.google.com>...
> I can't find it in Programming Perl 3E, but it's used like die() in
> Learning Perl 2E, as in the following:
>
> open(CHANDLE, "+< $CHATNAME") || bail ("cannot open $CHATNAME: $!");
If you look back a few pages (page 198 for me, 2nd Ed), you'll see the
function is defined as:
sub bail { # function to handle errors gracefully.
my $error = "@_";
print h1("Unexpected Error"), p($error), end_html;
die $error;
}
as part of the error handling for a CGI script.
I'm not sure if this would be better than using CGI::Carp, but it
would allow
more control over just what you tell the user.
--
Shabble.
------------------------------
Date: 3 Jun 2003 09:05:20 -0700
From: carltonbrown@hotmail.com (Carlton Brown)
Subject: Re: move() from File::Copy package fails with cross-device link
Message-Id: <aa611a32.0306030805.4b47d36c@posting.google.com>
After further investigation, I am pretty sure I have found a bug in
File::Copy. I tested this on 5.005_03 and 5.6.1 and the behavior was
identical.
If anyone believes this is not a bug, I am interested in your reason
for thinking this.
The move() function of File::Copy was designed to encapsulate moving
files between file systems, and therefore it should never fail with
the error "Cross-device link." However, I have found a scenario where
exactly this situation occurs.
Basically, if the files are on different file systems, and if
effective UID of the script doesn't have write permissions to the
source directory, then move() will fail and set $! to an inappropriate
error message of "cross-device link."
Now, of course you'd expect a failure of "Permission denied" if the
source dir isn't writable; as you know, the delete part of the move()
can't succeed. And this is what you get - if the source and target
are on the same file system. If they're on different file systems,
the error becomes "Cross-device link," a condition which File::Copy is
*supposed* to tolerate.
Of course you could also say that one should always check their
permissions in advance, but these things can't always be foreseen.
This is why we rely on the language to give us meaningful feedback as
to what the failure is.
carltonbrown@hotmail.com (Carlton Brown) wrote in message news:<aa611a32.0305210621.38f9ded0@posting.google.com>...
> If it is true that the move() method in File::Copy uses a
> copy-and-delete strategy to "move" a file from one file system to
> another, then why do I get a "Cross-device link" error using the
> move() function between files on different file systems?
>
> I am aware that it is impossible to truly "move" a file between file
> systems in the inode sense, but I thought the move() method was
> designed to commit the same sort of fraud as the "mv" shell command in
> giving the appearance of "moving" a file between file systems. That
> is the desired effect here.
>
> For example, see the the code fragment below (marked by an explanatory
> comment). This is for a log archiving utility.
>
> # perl v. 5.005_03 on solaris 8 (yes I realize it is a fossil, it's
> beyond my control).
> unless (move("$currFile","$dstFile")) {
> # Why is $! "Cross-device link" in this block?
> logger("Failed moving $currFile to $dstFile operation failed
> because: $!");
> return 1;
> } else {
> logger("Success moving $currFile to $dstFile");
> }
------------------------------
Date: 3 Jun 2003 12:33:53 -0700
From: satishi@gwu.edu (slash)
Subject: n-gram for words
Message-Id: <30fe9f1e.0306031133.4fa82ab8@posting.google.com>
I have been fiddling with this problem for a while and desperately
need some help. Linguistic applications frequently call for examining
linguitic units in a particular context. I am trying to do an n-gram
for word forms with a fixed context width. For example, by viewing all
sequences of three word forms in a text, like this --
"by viewing all"
"viewing all sequences"
"all sequences of"
"sequences of three"
"of three word"
"three word forms"
"word forms in"
"forms in a"
"in a text"
you might be able to spot some clear patterns once you have a critical
mass of text at your disposal. I have seen lots of examples of
character realted n-grams but none for a complete word, where concepts
can be extracted given a fixed context width.
I am also new to perl so am very overwhelmed by the non-intuitive
syntax. I have been able to write a small script that generates a text
file consisting of tokens (- stop words). How can I generate something
like this?
* * * * united
* * * united states
* * united states patent
* united states patent april
united states patent april 16
states patent april 16 2002
patent april 16 2002 method
april 16 2002 method apparatus
Any suggestions would be greatly appreciated.
Slash
------------------------------
Date: Tue, 03 Jun 2003 21:41:20 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: n-gram for words
Message-Id: <3edd152e.180382865@news.erols.com>
satishi@gwu.edu (slash) wrote:
: I am trying to do an n-gram
: for word forms with a fixed context width. For example, by viewing all
[snip]
: How can I generate something like this?
:
: * * * * united
: * * * united states
: * * united states patent
: * united states patent april
: united states patent april 16
: states patent april 16 2002
: patent april 16 2002 method
: april 16 2002 method apparatus
#!perl
use warnings;
use strict;
$_ = 'united states patent april 16 2002 method apparatus';
my $n = 5;
my @words = ( ('*') x ($n-1), split );
$" = "\t";
while( @words >= $n ) {
print "@words[0..$n-1]\n";
shift @words;
}
------------------------------
Date: Tue, 03 Jun 2003 21:47:59 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: n-gram for words
Message-Id: <jI8Da.646$7_2.52402334@newssvr21.news.prodigy.com>
slash <satishi@gwu.edu> wrote:
> I am also new to perl so am very overwhelmed by the non-intuitive
> syntax.
Perl borrows some of its syntax from many other older languages. If you
are familiar with C or awk, you might find some similarities.
> I have been able to write a small script that generates a text file
> consisting of tokens (- stop words). How can I generate something like
> this?
> * * * * united
> * * * united states
> * * united states patent
> * united states patent april
> united states patent april 16
> states patent april 16 2002
> patent april 16 2002 method
> april 16 2002 method apparatus
Do you care about the spacing? Looks like an array of words with n
consecutive elements printed from all the index positions..
I'd love to write it this way...
my @array = qw(Now is the time for all perl programs to run);
my $size = 5;
my $start = -$size + 1;
my $stop = @array - 1;
foreach my $content_index ($start .. $stop)
{
no warnings 'uninitialized'/;
print "@array[($content_index .. ($content_index+$size-1))]\n";
}
But the negative indexes into the array are read from the end rather
than as undefined elements. So I have to special case the loop.
foreach my $content_index ($start .. $stop)
{
my $word_start = $content_index
$word_start = 0 if ($word_start < 0);
my $word_stop = $content_index + $size - 1;
$word_stop = $stop if ($word_stop > $stop);
print "@array[($word_start .. $word_stop)]\n";
}
--
Darren Dunham ddunham@taos.com
Unix System Administrator Taos - The SysAdmin Company
Got some Dr Pepper? San Francisco, CA bay area
< This line left intentionally blank to confuse you. >
------------------------------
Date: Tue, 03 Jun 2003 22:02:35 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: n-gram for words
Message-Id: <3EDD1AC3.5020302@dev.null>
slash wrote:
> How can I generate something
> like this?
>
>
> * * * * united
> * * * united states
> * * united states patent
> * united states patent april
> united states patent april 16
> states patent april 16 2002
> patent april 16 2002 method
> april 16 2002 method apparatus
>
> Any suggestions would be greatly appreciated.
>
> Slash
>
use strict;
my $text='Greenspan said the Fed has no concerns';
#set this to what you need
my $context_width=2; #we want two words on either side
#break the text up into individual words
my @text=split/\W+/, $text;
#@text is now (Greenspan, said, the, Fed, has, no, concerns)
#let's add $context_width of stars at either end of @text:
my @stars=split//, '*' x $context_width;
@text=(@stars, @text, @stars);
#@text is now (* * Greenspan, said, the, Fed, has, no, concerns * *)
my $number_of_words_in_text=$#text;
for ($context_width .. $number_of_words_in_text-$context_width){
print "@text[$_-$context_width .. $_+$context_width]\n"
};
+++++++++++++++++++
* * Greenspan said the
* Greenspan said the Fed
Greenspan said the Fed has
said the Fed has no
the Fed has no concerns
Fed has no concerns *
has no concerns * *
------------------------------
Date: 03 Jun 2003 20:35:43 GMT
From: mooseshoes <mooseshoes@gmx.net>
Subject: Passing Hash To Subroutine Question
Message-Id: <bbj0qv$fbj@dispatch.concentric.net>
All:
Some supplemental assistance is requested -
I am passing a hash and an array to a subroutine (General::set_mkwl_references) as such:
%master_keyword_list = General::set_mkwl_references(\%master_keyword_list,\@subscriber);
The relevant corresponding subroutine lines are:
my ($mkwl_ref, $sub_ref) = @_;
@sub_subscriber = @$sub_ref;
%sub_master_keyword_list = %$mkwl_ref;
I have no trouble with the array, but the hash generates the following error message when
I attempt to access it using:
my $tempvalue = "keyword3";
print $sub_master_record_list{$tempvalue};
ERROR MESSAGE: "Use of uninitialized value in print at General.pm line 104, <MASTER_KEYWORD_LIST> line 10"
The hash is known to be good upon passing to the subroutine and the array works fine inside the subroutine.
Both @sub_subscriber and %sub_master_keyword_list are previously initialized in the subroutine.
Please let me know if you catch an error.
Thanks in advance.
Moose
------------------------------
Date: Tue, 03 Jun 2003 20:57:07 GMT
From: "dw" <me@verizon.invalid>
Subject: Re: Passing Hash To Subroutine Question
Message-Id: <DY7Da.6755$b8.2857@nwrdny03.gnilink.net>
"mooseshoes" <mooseshoes@gmx.net> wrote in message
news:bbj0qv$fbj@dispatch.concentric.net...
> %master_keyword_list =
General::set_mkwl_references(\%master_keyword_list,\@subscriber);
>
> The relevant corresponding subroutine lines are:
>
> my ($mkwl_ref, $sub_ref) = @_;
> @sub_subscriber = @$sub_ref;
> %sub_master_keyword_list = %$mkwl_ref;
>
> I have no trouble with the array, but the hash generates the following
error message when
> I attempt to access it using:
>
> my $tempvalue = "keyword3";
> print $sub_master_record_list{$tempvalue};
Your variable name changed from ...keyword_list to ...record_list
print $sub_master_keyword_list{$tempvalue}
You can use your original reference and avoid the extra variable:
print $mkwl_ref->{$tempvalue}
------------------------------
Date: 03 Jun 2003 21:28:56 GMT
From: mooseshoes <mooseshoes@gmx.net>
Subject: Re: Passing Hash To Subroutine Question
Message-Id: <bbj3uo$9sd@dispatch.concentric.net>
Thanks for the response.
The typo was out of last minute frustration, but the results were the same
when the name was corrected to %sub_master_keyword_list.
I also tried using the passed variable directly as you suggested and I had
an identical result. The compiler thinks (and who am I to dispute it?)
that there is an "uninitialized value". As far as I can tell, I have
initialized everything, however...
Any more thoughts?
Thanks,
Moose
dw wrote:
>
> "mooseshoes" <mooseshoes@gmx.net> wrote in message
> news:bbj0qv$fbj@dispatch.concentric.net...
>> %master_keyword_list =
> General::set_mkwl_references(\%master_keyword_list,\@subscriber);
>>
>> The relevant corresponding subroutine lines are:
>>
>> my ($mkwl_ref, $sub_ref) = @_;
>> @sub_subscriber = @$sub_ref;
>> %sub_master_keyword_list = %$mkwl_ref;
>>
>> I have no trouble with the array, but the hash generates the following
> error message when
>> I attempt to access it using:
>>
>> my $tempvalue = "keyword3";
>> print $sub_master_record_list{$tempvalue};
> Your variable name changed from ...keyword_list to ...record_list
> print $sub_master_keyword_list{$tempvalue}
>
> You can use your original reference and avoid the extra variable:
> print $mkwl_ref->{$tempvalue}
------------------------------
Date: Tue, 03 Jun 2003 23:57:31 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Passing Hash To Subroutine Question
Message-Id: <bbj5mg$abbqp$1@ID-184292.news.dfncis.de>
mooseshoes wrote:
> my $tempvalue = "keyword3";
> print $sub_master_record_list{$tempvalue};
>
> ERROR MESSAGE: "Use of uninitialized value in print at General.pm
> line 104, <MASTER_KEYWORD_LIST> line 10"
<snip>
> Both @sub_subscriber and %sub_master_keyword_list are previously
> initialized in the subroutine.
The hash element $sub_master_record_list{'keyword3'} is obviously not
initialized. One way to prevent that warning is to do something like
this before printing:
unless (defined $sub_master_record_list{$tempvalue}) {
$sub_master_record_list{$tempvalue} = '';
}
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
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 5069
***************************************