[12973] in Perl-Users-Digest
Perl-Users Digest, Issue: 383 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 5 12:07:22 1999
Date: Thu, 5 Aug 1999 09:05:10 -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 Thu, 5 Aug 1999 Volume: 9 Number: 383
Today's topics:
Re: *Yet another* Net::FTP question (John Borwick)
Re: => only in hash initialization? (WAS: mySQL & Perl (Larry Rosler)
Re: A matter of style? (Larry Rosler)
Re: Capturing Browser Data <c4jgurney@my-deja.com>
Re: Capturing Browser Data <eedalf@eed.ericsson.se>
Re: chomp not working jembow@my-deja.com
Complex Extract HTML (LWP does not work) inlandpac@my-deja.com
DBI question (hoz)
Re: DBI question (Malcolm Ray)
how can I write an e-mail in an perl prg? <knigge@garnix.unix-ag.uni-hannover.de>
Re: how can I write an e-mail in an perl prg? <eedalf@eed.ericsson.se>
Re: how to match this pattern? <eedalf@eed.ericsson.se>
Re: how to match this pattern? (Gary O'Keefe)
Re: IMPORTANT: "19$year" (Jerome O'Neil)
Re: Invalid cross link error message (Malcolm Ray)
Is there any way to get user name <jaganna@shell.one.net>
Re: Is there any way to get user name <eedalf@eed.ericsson.se>
Nastiness contrary to the spirit of perl? <jmeacham@hume.jhuccp.org>
Re: Newbie: how do I send shell script output to my per <russell.zah@tellabs.com>
Re: perl problem with associative array (Matthew David Zimmerman)
Re: Perl seems to be LAME! (David Cantrell)
String <alau@americasm01.nt.com>
Re: String <craig@mathworks.com>
Trouble with Sockets <dkr@freerealtime.com>
Re: truncation without rounding (Anno Siegel)
Re: truncation without rounding <revjack@radix.net>
Re: truncation without rounding (Anno Siegel)
Re: Why is it.... (Greg Andrews)
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 5 Aug 1999 14:15:51 GMT
From: John.Borwick@sas.com (John Borwick)
Subject: Re: *Yet another* Net::FTP question
Message-Id: <37ab9c65.266856689@newshost.unx.sas.com>
On 3 Aug 1999 18:00:39 GMT, fl_aggie@thepentagon.com (I R A Darth
Aggie) wrote:
>and then it times out. Even if I excise the debugging stuff, and just pass
>in Port 23, it times out. As a wild-assed guess, I tried this:
>
>%options=qw(Debug 10 23 Port);
>
>Well, shiver me timbers, that worked. That strikes me as being somewhat
>anti-intuitive, but maybe I'm not thinking about it correctly?
Maybe this worked because there was no defined port key, so it ignored
23 => Port and used the default port of 23?
--
John Borwick
------------------------------
Date: Thu, 5 Aug 1999 08:42:28 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: => only in hash initialization? (WAS: mySQL & Perl -> Something simple)
Message-Id: <MPG.121350aefbc30686989ddf@nntp.hpl.hp.com>
In article <19990805130504.64945.qmail@hotmail.com> on Thu, 05 Aug 1999
09:05:04 EDT, Perl King <perlking@hotmail.com> says...
[starting yet another thread, because there is no References header in
there:
Path:
nntp.hpl.hp.com!hplabs.hpl.hp.com!sdd.hp.com!usc!howland.erols.net!newsf
eed.berkeley.edu!newsfeed1.earthlink.net!news.alt.net!anon.lcs.mit.edu!n
ym.alias.net!mail2news
Message-ID: <19990805130504.64945.qmail@hotmail.com>
X-Originating-IP: [192.58.185.9]
From: "Perl King" <perlking@hotmail.com>
Subject: Re: => only in hash initialization? (WAS: mySQL & Perl ->
Something simple)
Date: Thu, 05 Aug 1999 09:05:04 EDT
Mime-Version: 1.0
Content-Type: text/plain; format=flowed
Mail-To-News-Contact: postmaster@nym.alias.net
Organization: mail2news@nym.alias.net
Newsgroups: comp.lang.perl.misc
Lines: 21
Xref: nntp.hpl.hp.com comp.lang.perl.misc:241020
I don't see a newsreader either. Please get one and use it properly!]
> Larry Rosler <lr@hpl.hp.com> says...
> >Perl King <perlking@hotmail.com> says...
> >>open PW => '/etc/passwd'; # Vorausgehenproblem!
> >
> >This seems like a classic case of TMTOWTDI, in this case involving
> >nothing but taste and judgment, on which we can all differ.
>
> A little exercise:
>
> % perl
> open PW, '/etc/passwd';
>
> % perl
> open PW => '/etc/passwd';
> Precedence problem: open PW should be open(PW) at - line 1.
>
> Perl King (again decrees to use => only in hash initialization)
It is more than a little disingenuous of you to quote selectively to
make it appear as if I was endorsing a syntax error by advocating the
use of => when the autoquoting property was not desired. TMTOWTDI does
not include creating syntax errors.
I will not continue this discussion here. I have already referred to an
extensive thread in comp.lang.perl.moderated, where I chose to post the
query in the first place in the hope of getting intelligent, well-
reasoned arguments either way. You certainly have not provided them
here.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 5 Aug 1999 08:27:30 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: A matter of style?
Message-Id: <MPG.12134d31f7bdfd6d989dde@nntp.hpl.hp.com>
In article <37a9834a.101957329@news.hydro.co.uk> on Thu, 05 Aug 1999
12:33:20 GMT, Gary O'Keefe <gary@onegoodidea.com> says...
> Gary O'Keefe wrote:
> > # in order to match inverted commas (or quotes)
> > # the character has to be escaped ( eg. \' or \" )
> >
> > s/(.*)\'\'/$1\'$dir\'/;
> > print OUT;
>
> It is not necessary to use $1 here,
>
> s/\'\'/'$dir'/;
>
> would have done.
>
> > # I'm not sure if the inverted commas in the
> > # replacement string must be escaped. Try it
> > # either way to see
>
> They're not.
They're not needed to be escaped in the regex either.
s/''/'$dir'/;
If you can't think of the metasyntactic meaning for a punctuation
character in a regex, there probably isn't any. (Of course, you could
also look it up, but I guess it's easier to backslash everything in
sight. :-)
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 05 Aug 1999 15:22:25 GMT
From: Jeremy Gurney <c4jgurney@my-deja.com>
Subject: Re: Capturing Browser Data
Message-Id: <7oca74$e92$1@nnrp1.deja.com>
In article <933862238.8029@www.remarq.com>,
Samay <anonymous@web.remarq.com> wrote:
> Hi,
> I would like to write simple perl script (may be
> complicated) which deals with my surfing the Internet.
There's an article in PerlMonth about this sort of thing.
http://www.PerlMonth.com/
HTH,
Jeremy Gurney
SAS Programmer | Proteus Molecular Design Ltd.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Thu, 05 Aug 1999 17:43:40 +0200
From: Alex Farber <eedalf@eed.ericsson.se>
To: Samay <anonymous@web.remarq.com>
Subject: Re: Capturing Browser Data
Message-Id: <37A9B12C.8815FD6F@eed.ericsson.se>
Hi Samay,
Samay wrote:
> I would like to write simple perl script (may be
> complicated) which deals with my surfing the Internet.
maybe Netscape::* Moudules? Please see
ftp://ftp.gwdg.de/pub/languages/perl/CPAN/modules/by-module/Netscape/
Regards
Alex
--
Ich studiere Elektrotechnik (Technische Informatik) an der RWTH Aachen
und bin ein guter Perl-Programmierer (arbeite seit 4 Jahren als Intranet-
Entwickler). Kann auch C, Java, SQL, JavaScript und HTML, CGI und TCP/IP.
Ich suche eine gut bezahlte Diplomstelle in Koeln, Aachen oder Umgebung.
------------------------------
Date: Thu, 5 Aug 1999 08:47:05 -0700
From: jembow@my-deja.com
To: "comp.lang.perl.misc@list.deja.com" <comp.lang.perl.misc@list.deja.com>
Subject: Re: chomp not working
Message-Id: <v04210102b3cf6258973f@[206.169.190.24]>
>
>Are you sure about that? Let's see a code snippet, please.
>
#!/usr/bin/perl -w
$x = "good night\n";
chomp($x);
print($x);
yields the following error message. "Chop", however, works fine:
"chomp" may clash with future reserved word at ./chomp_test line
3syntax error i
n file ./chomp_test at line 3, next 2 tokens "chomp("
Execution of ./chomp_test aborted due to compilation errors.
Thanks,
-John
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Thu, 05 Aug 1999 15:23:01 GMT
From: inlandpac@my-deja.com
Subject: Complex Extract HTML (LWP does not work)
Message-Id: <7oca88$e9k$1@nnrp1.deja.com>
After trying HTML::Parser and after trying all long-winded scripting
techniques I could think of to remove HTML tags, I have still come up
short of success.
I have extracted HTML tags many times, but in this case, it is not
working!
Some web sites that I fetch with LWP::UserAgent where I need to extrace
these HTML tags show somewhat correctly while others don't show
anything (almost like it's removing everything, even the text between
the tags).
Can anyone give more assistance in this? In this case, I would like to
avoid having to use HTML::Parser and would like to go about it the long
way.
Could this have something to do with complex tag elements and
attributes?
CLH
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Thu, 05 Aug 1999 23:48:39 GMT
From: hoz@rocketmail.com (hoz)
Subject: DBI question
Message-Id: <37aa22cc.106967938@news.netvision.net.il>
I am trying to confirm the return value ($rv) from a SELECT
statement. The DBI doc is not specific about what is returned from a
SELECT statement if zero rows are returned. My tests show that "0E0"
is returned in the case where zero rows are returned. Can I count on
this? The DBI doc simply says it will return true.
Can anyone confirm this? (my pseudo code...)
if select returns a value, $rv >0
if select returns nothing $rv eq "0E0"
if select doesn't return $rv is undef
-hoz
------------------------------
Date: 5 Aug 1999 15:46:32 GMT
From: M.Ray@ulcc.ac.uk (Malcolm Ray)
Subject: Re: DBI question
Message-Id: <slrn7qjceo.7sm.M.Ray@carlova.ulcc.ac.uk>
On Thu, 05 Aug 1999 23:48:39 GMT, hoz <hoz@rocketmail.com> wrote:
>I am trying to confirm the return value ($rv) from a SELECT
>statement. The DBI doc is not specific about what is returned from a
>SELECT statement if zero rows are returned. My tests show that "0E0"
>is returned in the case where zero rows are returned. Can I count on
>this? The DBI doc simply says it will return true.
>Can anyone confirm this? (my pseudo code...)
>if select returns a value, $rv >0
>if select returns nothing $rv eq "0E0"
>if select doesn't return $rv is undef
Assuming a statement handle in $sth, and you've done $sth->execute,
the number of rows can be found by:
$rows = $sth->rows;
Unless the number isn't available for some reason (depends on the driver),
in which case you get -1.
--
Malcolm Ray University of London Computer Centre
------------------------------
Date: Thu, 05 Aug 1999 17:09:06 +0200
From: Christian WIese <knigge@garnix.unix-ag.uni-hannover.de>
Subject: how can I write an e-mail in an perl prg?
Message-Id: <37A9A912.BAE8AC8A@garnix.unix-ag.uni-hannover.de>
in an Variable I habe an text. These text I like to sende to an person.
I work whith unix.
how can I do this
like system(mail,"xyz@gmx.com",$text);
or `echo $text|mail "xyz@gmx.com"'
what is the correct way?
Thanks
knigge
------------------------------
Date: Thu, 05 Aug 1999 17:31:01 +0200
From: Alex Farber <eedalf@eed.ericsson.se>
To: knigge@stud.uni-hannover.de
Subject: Re: how can I write an e-mail in an perl prg?
Message-Id: <37A9AE35.936DB708@eed.ericsson.se>
Christian,
Christian WIese wrote:
> in an Variable I habe an text. These text I like to sende to an person.
> I work whith unix.
there is an article in "The Perl Journal" on how to
send e-mail (with 3 methods) - please see the source code at
http://www.itknowledge.com/tpj/programs/Issue_14/Sending_Mail/
Gruss
Alex
--
Ich studiere Elektrotechnik (Technische Informatik) an der RWTH Aachen
und bin ein guter Perl-Programmierer (arbeite seit 4 Jahren als Intranet-
Entwickler). Kann auch C, Java, SQL, JavaScript und HTML, CGI und TCP/IP.
Ich suche eine gut bezahlte Diplomstelle in Koeln, Aachen oder Umgebung.
------------------------------
Date: Thu, 05 Aug 1999 17:41:31 +0200
From: Alex Farber <eedalf@eed.ericsson.se>
To: bloeth@gosub.de
Subject: Re: how to match this pattern?
Message-Id: <37A9B0AB.6A371C74@eed.ericsson.se>
Hi Roman,
"Roman Blöth" wrote:
> someword_someotherword_1.gif
> someword_1.gif
>
> Now I want the first word to get into $1 and - if there's a second one
> - the second one into $2. The underscores and numbers (which vary)
> should not get into $1 and $2.
$_ = 'someword_someotherword_1.gif';
# $_ = 'someword_1.gif';
/([a-z]+)_(?:([a-z]+)_)?\d+\.gif/i;
print "$1 $2\n"
Regards
Alex
--
Ich studiere Elektrotechnik (Technische Informatik) an der RWTH Aachen
und bin ein guter Perl-Programmierer (arbeite seit 4 Jahren als Intranet-
Entwickler). Kann auch C, Java, SQL, JavaScript und HTML, CGI und TCP/IP.
Ich suche eine gut bezahlte Diplomstelle in Koeln, Aachen oder Umgebung.
------------------------------
Date: Thu, 05 Aug 1999 15:50:11 GMT
From: gary@onegoodidea.com (Gary O'Keefe)
Subject: Re: how to match this pattern?
Message-Id: <37a9ac93.112527995@news.hydro.co.uk>
Roman Blöth wrote:
>Dear readers,
>
>how can I do pattern matching, if I want to extract two strings out of
>a string:
>
>I got strings like:
>
>someword_someotherword_1.gif
>
>but also
>
>someword_1.gif
>
>
>Now I want the first word to get into $1 and - if there's a second one
>- the second one into $2. The underscores and numbers (which vary)
>should not get into $1 and $2.
Have you tried
@words = split /[\_|\.]/, $filename;
If the string is stored in a scalar called $filename, this will
populate the list @words with the words seperated by either underscore
or period. They are preceded by the backslash in the regular
expression as underscore and period have special meanings in the
context of an RE and must be escaped by the backslash character so the
RE is evaluated for their literal value. In the above example if
$filename = 'someword_someotherword_1.gif';
then, after split, the contents of @words are
$words[0] someword
$words[1] someotherword
$words[2] 1
$words[3] gif
(as long as the variable $[ == 0). It's up to you to identify which of
the list elements you should keep - you can figure that out for
yourself.
By the way, before posting to the group, be sure to scrutinise (and I
mean really scrutinise) the documentation with your perl installation
(either perldoc or man) before you post a question. As the initial
learning curve for perl can be quite steep for novice programmers, the
same question get asked ad nauseum and there is no surer way to piss
off the experienced programmers (i.e. the ones that can help you when
the problems get _really_ tricky) than asking these questions. A quick
search through the perlfunc section of the manual would have found the
split function and you could have answered this question yourself.
Don't make this mistake again or all you'll get will be flames (and be
killfiled).
Gary (still third tier 'til anyone tells him different)
--
Gary O'Keefe
gary@onegoodidea.com
You know the score - my current employer has nothing to do with what I post
------------------------------
Date: 5 Aug 1999 14:54:49 GMT
From: jeromeo@atrieva.com (Jerome O'Neil)
Subject: Re: IMPORTANT: "19$year"
Message-Id: <7oc8jp$7td$2@brokaw.wa.com>
In article <Pine.GSO.4.10.9908042129110.27740-100000@crusoe.crusoe.net>,
Jeff Pinyan <jeffp@crusoe.net> writes:
> Do not accept ANY substitutes.
>
> $date = 1900 + $year;
$year = (split(/ /, localtime()))[5];
--
Jerome O'Neil, Operations and Information Services
Atrieva Corporation, 600 University St., Ste. 911, Seattle, WA 98101
jeromeo@atrieva.com - Voice:206/749-2947
The Atrieva Service: Safe and Easy Online Backup http://www.i-filezone.com
------------------------------
Date: 5 Aug 1999 15:31:28 GMT
From: M.Ray@ulcc.ac.uk (Malcolm Ray)
Subject: Re: Invalid cross link error message
Message-Id: <slrn7qjbig.7sm.M.Ray@carlova.ulcc.ac.uk>
On Wed, 04 Aug 1999 18:33:48 -0400, Gary Nielson <gnielson@charlotte.com>
wrote:
[and also sent a stealth cc. Please don't do that]
>Thanks for your help. I am still perplexed -- there's something I don't
>understand. I moved the files onto the same filesystem and am using unlink instead
>of system. The script, as always, works fine from the command line, but not from a
>cron job.
When something works from the command line but not from cron (under
the same uid), the two commonest causes are: (1) differences in PATH
variable (e.g. some called by the script is found in one of the
directories on your PATH when run from the command line, but that
directory isn't in the PATH the script inherits from cron), and (2)
invalid assumptions about current directory (e.g. the script looks
for files in the current directory, which happens to be a different
directory than that the cron job runs in). Both should be easy to
diagnose and fix. (1) doesn't appear to apply to your problem, but
(2) might: you don't tell us the value of $TheOneJustDownloaded and
$LastGoodOneStored.
>As a cron it produces the error "No such file or directory at
>/home/gnielson/bin/scripts/perl/thatsracin/votemonitor.pl line 112" so it does
>remove the file, but then does not move the other file over to replace it.
That sounds to me like $TheOneJustDownloaded doesn't exist, or one
of the parent directories for the destination file doesn't exist.
>Yet
>when run from the command line, like I said, works fine. I looked at the system
>perldoc and perldoc perlop but dont understand how the operators have something to
>do with it.
My mention of system and backticks was because you were mixing them in
a way which made no sense, but you've now dropped that bit of code, so
it's not relevant to the continuing problem.
After this line:
> 111 print "Now moving $TheOneJustDownloaded to $LastGoodOneStored\n";
add:
warn "Source file $TheOneJustDownloaded does not exist"
unless -e $TheOneJustDownloaded;
> 112 move($TheOneJustDownloaded, $LastGoodOneStored) || warn $!;
By the way, is this the move function from File::Copy? See, when
I said that the error you were getting before suggested that the
source and destination of the move were on different filesystems,
I'd forgotten that File::Copy's move copes with this. The error you
were getting *is* symptomatic of trying to rename a file from one
filesystem to another, but File::Copy detects this and falls back to
a copy and unlink. So it should have worked anyway... unless this
is a different move function.
--
Malcolm Ray University of London Computer Centre
------------------------------
Date: 5 Aug 1999 11:28:41 -0400
From: Tanvada Jagannadha <jaganna@shell.one.net>
Subject: Is there any way to get user name
Message-Id: <37a9ada9@news1.one.net>
Sir,
is there anyway we could get the user information along with the
environmental variables? I mean the login name. If not with env variables,
is there any command like unix 'w/who' so that we could get the login
name. Thanks in advance.
Regards,
Jagannadh
------------------------------
Date: Thu, 05 Aug 1999 17:48:41 +0200
From: Alex Farber <eedalf@eed.ericsson.se>
To: Tanvada Jagannadha <jaganna@shell.one.net>
Subject: Re: Is there any way to get user name
Message-Id: <37A9B259.63BFB81F@eed.ericsson.se>
Hi Jagannadha,
Tanvada Jagannadha wrote:
> is there anyway we could get the user information along with the
> environmental variables? I mean the login name. If not with env variables,
> is there any command like unix 'w/who' so that we could get the login name.
maybe
qx(whoami);
Regards
Alex
--
Ich studiere Elektrotechnik (Technische Informatik) an der RWTH Aachen
und bin ein guter Perl-Programmierer (arbeite seit 4 Jahren als Intranet-
Entwickler). Kann auch C, Java, SQL, JavaScript und HTML, CGI und TCP/IP.
Ich suche eine gut bezahlte Diplomstelle in Koeln, Aachen oder Umgebung.
------------------------------
Date: 05 Aug 1999 06:57:45 -0500
From: James Meacham <jmeacham@hume.jhuccp.org>
Subject: Nastiness contrary to the spirit of perl?
Message-Id: <so5ymocm.fsf@hume.jhuccp.org>
When I first left the world of the church and academe, where I had spent my last 15 or so years, to follow my interest in computers, the attitude of humanity embodied in the Camel Book attracted me. Larry Wall is clearly a spiritual and humanistic person, and the fact that the language embodies the desire to meet people how they think rather than forcing them into reductionistic computerisms was, and remains, among the main reasons I use perl rather than the other languages out there. So while the creator of the language and really the language itself manifest an attitude of humanistic synthesis, the overwhelming tone of this newsgroup is one of nastiness, condescension, and intolerance.
Perhaps this is due only to a couple of prodigious posters with bad attitudes, and also to the disembodiment inherent in the Usenet medium, but I'd be interested to know what others thought about this apparent contradiction, or at least inconsistency. I've been programming and working with computers for a long time now, and I could probably be a useful member of the perl community, but the tone of this newsgroup has discouraged me from posting lest I make a mistake, or be guilt of not having read the FAQ recently or carefully enough. Just curious if I'm the only one, and if I'm the only one who has noticed this disparity between the creator and the language in contradistinction to the Usenet groups devoted to the language.
Peace,
James
--
James David Meacham, 3rd
Systems Administrator/Internet Systems Specialist
Johns Hopkins University's Center for Communication Programs
jmeacham@jhuccp.org
410.659.6967 (office) 410.619.6760 (pager)
------------------------------
Date: Thu, 05 Aug 1999 11:05:49 -0400
From: Russell Zah <russell.zah@tellabs.com>
Subject: Re: Newbie: how do I send shell script output to my perl program?
Message-Id: <37A9A84D.28CFAFA2@tellabs.com>
> Yuck! That sure doesn't sound optimal. Unless your boss is
> supposed to make all programming decisions, that sounds like micro-managing.
> Does your boss also tell you how to click on
> your mouse properly [that's a Dilbert joke]? I would have
> used DBI and one of the DBD::* modules to access the database
> directly inside Perl, then the CGI module to throw the formatted
> output onto the webpage.
Thanks for the info!
Actually, my boss does make the programming decisions, as I'm just an intern who
started learning perl on Monday. (Imagine how I felt when he mentioned KRON
JOB(chronjob) the first time) Besides, the SQL interface is the only way to get
to the database without messing with permissions and eliminates the possibility
of overwriting data.
Thanks again,
Russell
------------------------------
Date: 5 Aug 1999 15:43:24 GMT
From: mdz4c@node8.unix.Virginia.EDU (Matthew David Zimmerman)
Subject: Re: perl problem with associative array
Message-Id: <7ocbes$dg1$1@murdoch.acc.Virginia.EDU>
In article <7o67n1$2im$1@nnrp1.deja.com>, <superba77@my-deja.com> wrote:
>- I've created an associative array:
or "hash" in Perl-speak.
>%thumbswidth =
>("up1",64,"up88",68,"up87",80,"up85",52,"up79",72,"up75",72,"up63",128,"
>up52",56,"up4",76,"up34",64,"up21",104,"up17",52,"up14",48,"up13",128,"u
>p10",72);
>
>- Then in a loop I wanted to call this array:
>
>$actimgw = $thumbswidth{'$elementname'};
This won't work, the variable isn't substituted.
> or I also tried:
>$actimgw = $thumbswidth{$elementname};
This is fine.
[description of hash non-substitution deleted]
>Is it possible to give a scalar of an associative array a variable as
>index-name like in: $actimgw = $thumbswidth{$elementname};
>or must it always be a specific index-name like eg. $actimgw =
>$thumbswidth{'up1'}; ?
Yes, you can put a variable there.
>How can I solve this problem? Any hints very very welcome!!
When I ran your code, it worked fine. I suspect that you should check the
value of $elementname before you pass it to the hash. Maybe $elementname
has leading or trailing spaces, for example, and the name of the hash key
should be exact.
>akris@gmx.net (write in English or German.thanks)
Meine Deutsch sind sehr schlecht.
HTH!
Matt
--
Matthew Zimmerman ------------ http://www.people.virginia.edu/~mdz4c
Interdisciplinary Biophysics Program --------- University of Virginia
| "You got to be very careful if you don't know where you're going, |
| because you might not get there." -- Yogi Berra |
------------------------------
Date: Thu, 05 Aug 1999 15:18:30 GMT
From: NukeEmUp@ThePentagon.com (David Cantrell)
Subject: Re: Perl seems to be LAME!
Message-Id: <37a9aa96.107968139@news.insnet.net>
[let's ignore the flame-bait subject for a moment]
On Tue, 03 Aug 1999 23:19:57 +0200, Moritz Mertinkat <bluebit@gmx.net>
said:
> I'm using a text file (~1.11 MB) with about 10000 entries
> for searching. Now, when I just run through all the lines
> - without even doing *anything* - it takes up to 7 seconds!
> And with the search algorithm about 11 seconds!
>
> [snip code]
>
> Any ideas are welcome!
Whilst you got one thing right (you supplied code) you forgot to ask a
question. Thanks for supplying so much information though.
[Copying newsgroup posts to me by mail is considered rude]
--
David Cantrell, part-time Unix/perl/SQL/java techie
full-time chef/musician/homebrewer
http://www.ThePentagon.com/NukeEmUp
------------------------------
Date: Thu, 05 Aug 1999 11:48:21 -0400
From: Alan Lau <alau@americasm01.nt.com>
Subject: String
Message-Id: <37A9B245.226E1158@americasm01.nt.com>
Hi,
Does anyone know how to extract the first character from a string?
Thanks,
Alan
------------------------------
Date: Thu, 05 Aug 1999 12:03:38 -0400
From: Craig Ciquera <craig@mathworks.com>
Subject: Re: String
Message-Id: <37A9B5D9.4DB7152F@mathworks.com>
Alan Lau wrote:
> Hi,
>
> Does anyone know how to extract the first character from a string?
>
perldoc -f substr
perl -de0
Loading DB routines from perl5db.pl version 1.01
Emacs support available.
Enter h or `h h' for help.
main::(-e:1): 0
DB<1> $string = "Test";
DB<2> $first_char = substr( $string, 0, 1 )
DB<3> p $first_char
T
DB<4>
-Craig
------------------------------
Date: Thu, 05 Aug 1999 14:13:06 +0000
From: Doug Robinson <dkr@freerealtime.com>
Subject: Trouble with Sockets
Message-Id: <37A99BF2.554BEBBE@freerealtime.com>
This is a multi-part message in MIME format.
--------------C60721302DF7AA45822293E4
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hello
I have a small problem here. The attached programs work
fully on Linux but half fail on Solaris.
What t.pl does is prepare a socket for multi-cast
operation and throw a single udp packet to the group.
The QuoteListener.pl program is supposed to
prepare the same Multi-cast group as t.pl and listen.
On Linux the QuoteListener.pl will receive the t.pl packets
both from Solaris and Linux but on Solaris the QuoteListener.pl
receives nothing.
Can anybody send me a clue as to why this is?
dkr
--
The Office of Doug Robinson. These types are not "abstract"; they are as
dkr@freerealtime.com real as int and float. - Doug McIlroy
--------------C60721302DF7AA45822293E4
Content-Type: text/plain; charset=us-ascii;
name="Constants.pm"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="Constants.pm"
package FRT::Constants;
use strict;
use vars qw ($MULTI_CAST_ADDR $MULTI_CAST_QUOTE_PORT $MULTI_CAST_LOGIN_PORT
$ENFORCER_HASH_FILE $BANNER_AD_CONFIGURE);
#
# this block of constants are used to
# control the communication channels amongst
# the enforcer & the Quote servers
#
$MULTI_CAST_ADDR = "224.7.7.7"; # set by enforcer
$MULTI_CAST_QUOTE_PORT = 8998; # set by enforcer
$MULTI_CAST_LOGIN_PORT = 8999; # set by enforcer
#
# This is path name to a memory maped
# file that contains a hash table used
# by the Quote server to keep a list of
# freerealtime abusers!
#
$ENFORCER_HASH_FILE = "/tmp/badPersonFile";
#
# This is the path to the Banner Ad configure file
#
$BANNER_AD_CONFIGURE = "conf/banneradrc";
1;
--------------C60721302DF7AA45822293E4
Content-Type: application/x-perl;
name="QuoteListener.pl"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="QuoteListener.pl"
use diagnostics;
use strict;
use IO::Socket;
use FRT::Constants;
my $IP_ADD_MEMBERSHIP = 35; # for Linux
#my $IP_ADD_MEMBERSHIP = 19; # for Solaris
my $IPPROTO_IP = 0;
my $MAX_INPUT_BUFFER_LENGTH = 1024;
my $socket =
IO::Socket::INET ->
new (Proto => 'udp',
LocalPort => $FRT::Constants::MULTI_CAST_QUOTE_PORT,
Reuse => 1,
Type => SOCK_DGRAM)
or die "Socket $!";
my $sa1 = inet_aton ($FRT::Constants::MULTI_CAST_ADDR);
my $sa = pack ("a4C4", $sa1, 0, 0, 0, 0);
$socket -> setsockopt ($IPPROTO_IP, #multi-cast join group
$IP_ADD_MEMBERSHIP,
$sa)
or die "setsockopt: $!";
while (1) { # over & over & over
my $buffer;
my $hispaddr =
$socket -> recv ($buffer, $MAX_INPUT_BUFFER_LENGTH)
or die "socket -> recv $1";
print "Got: ", $buffer;
}
--------------C60721302DF7AA45822293E4
Content-Type: application/x-perl;
name="t.pl"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="t.pl"
use diagnostics;
use strict;
use IO::Socket;
use FRT::Constants;
my $IP_ADD_MEMBERSHIP = 35; # for linux
#my $IP_ADD_MEMBERSHIP = 19; # for Solaris
my $IPPROTO_IP = 0;
my $socket =
IO::Socket::INET ->
new (PeerAddr => $FRT::Constants::MULTI_CAST_ADDR,
Proto => 'udp',
PeerPort => $FRT::Constants::MULTI_CAST_QUOTE_PORT,
Reuse => 1,
Type => SOCK_DGRAM)
or die "Socket $!";
my $sa1 = inet_aton ($FRT::Constants::MULTI_CAST_ADDR);
my $sa = pack ("a4C4", $sa1, 0, 0, 0, 0);
$socket -> setsockopt ($IPPROTO_IP, #multi-cast join group
$IP_ADD_MEMBERSHIP,
$sa)
or die "setsockopt: $!";
my $buffer;
$socket -> send ("gorp\n", 0, $sa);
--------------C60721302DF7AA45822293E4--
------------------------------
Date: 5 Aug 1999 15:35:27 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: truncation without rounding
Message-Id: <7ocavv$egb$1@lublin.zrz.tu-berlin.de>
<ericp@us.ibm.com> wrote in comp.lang.perl.misc:
>I'm writing a CGI script for calculating a golfers handicap. The number
>produced has to be truncated to the tenths without rounding. I know
>that both printf() and sprintf() will round the last digit, so how do I
>make it NOT round?
int( 10*$number)/10;
Anno
------------------------------
Date: 5 Aug 1999 15:50:59 GMT
From: revjack <revjack@radix.net>
Subject: Re: truncation without rounding
Message-Id: <7ocbt3$fup$1@news1.Radix.Net>
Keywords: Hexapodia as the key insight
Anno Siegel explains it all:
: <ericp@us.ibm.com> wrote in comp.lang.perl.misc:
:>I'm writing a CGI script for calculating a golfers handicap. The number
:>produced has to be truncated to the tenths without rounding. I know
:>that both printf() and sprintf() will round the last digit, so how do I
:>make it NOT round?
:int( 10*$number)/10;
Can a handicap be zero?
------------------------------
Date: 5 Aug 1999 15:58:27 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: truncation without rounding
Message-Id: <7occb3$ej0$1@lublin.zrz.tu-berlin.de>
Keywords: Hexapodia as the key insight
revjack <revjack@radix.net> wrote in comp.lang.perl.misc:
>Anno Siegel explains it all:
>: <ericp@us.ibm.com> wrote in comp.lang.perl.misc:
>:>I'm writing a CGI script for calculating a golfers handicap. The number
>:>produced has to be truncated to the tenths without rounding. I know
>:>that both printf() and sprintf() will round the last digit, so how do I
>:>make it NOT round?
>
>:int( 10*$number)/10;
>
>Can a handicap be zero?
What if it is? Did you mean to ask, can 10 be zero?
Anno
------------------------------
Date: 4 Aug 1999 21:39:03 -0700
From: gerg@shell.ncal.verio.com (Greg Andrews)
Subject: Re: Why is it....
Message-Id: <7ob4h7$d0n$1@shell1.ncal.verio.com>
tchrist@mox.perl.com (Tom Christiansen) writes:
>
>Do you believe that someone who doesn't have a logical mind can be
>taught to have one?
>
I think the premise of that question is flawed.
I believe that most people do not *percieve* the fact that they
have a logical mind, but shown the logical things they do day in
and day out (writing and/or following cooking recipes, planning
the route to drive while out doing errands, giving a friend
directions to the house, cooking all the parts of the evening
meal so that the different parts are ready at the same time)
they will see the truth.
There are indeed many people who have difficulty applying their
logic skills to abstract endeavors such a writing computer programs.
That does not mean they lack such skills.
Can these people learn to apply logic skills to abstract activities?
I believe so. It's more difficult than for someone accustomed to
abstract activities, but not impossible.
-Greg
--
::::::::::::::::::: Greg Andrews gerg@wco.com :::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
------------------------------
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". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". 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". It appears twice
weekly in the group, but is not distributed in the digest.
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 383
*************************************