[13068] in Perl-Users-Digest
Perl-Users Digest, Issue: 478 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 12 09:27:43 1999
Date: Thu, 12 Aug 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 Thu, 12 Aug 1999 Volume: 9 Number: 478
Today's topics:
Calculation problems in Perl <alex[at]suffix.demon.co.uk>
Re: CHMOD function (Malcolm Ray)
Copy a hash of hashes of hashes remsta@my-deja.com
Re: Dereferencing anon hash <hgonzalez@mindspring.com>
Re: dot is too precious to be only for string concatena <tchrist@mox.perl.com>
Re: Fastest form of an 'if' (elephant)
Re: Fastest form of an 'if' (Gary O'Keefe)
Re: How to count clicks to HTML link. <lane@rettig.com>
Re: is our reese the author of mysql book? (Graham Ashton)
Re: Multi-Page Forms <flavell@mail.cern.ch>
Newbie? => Merging 2 files to a third file bobby1233847@my-deja.com
Re: Newbie? => Merging 2 files to a third file (Gary O'Keefe)
Re: pricing a perl job <picaza@chsi.com>
Problem Connecting To a remote database <nikos@biznet.com.gr>
Re: Reset .. ie clear out a hash array <hgonzalez@mindspring.com>
Sending mail to "QuestionExchange" <tchrist@mox.perl.com>
Re: Sesssion ID <x9730915@uea.ac.uk>
Re: Time:: Hires (Michel Dalle)
Re: turn $6 into $6000 (Anno Siegel)
Why ? (Afgin Shlomit)
Re: Why ? <mock@knapp.co.at>
Re: Why use Perl when we've got Python?! <kvan@dis.dk>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 12 Aug 1999 11:17:38 +0100
From: "Alex Croton" <alex[at]suffix.demon.co.uk>
Subject: Calculation problems in Perl
Message-Id: <934453073.6416.0.nnrp-09.9e98d8a3@news.demon.co.uk>
Hi,
I'm hoping that someone can help me - I seem to have a problem with simple
calculation in Perl.
Given the subroutine below,
sub calcBal {
my ($type, $bal, $change) = @_;
my ($newBal);
if ($type =~ /pay/i) {
$newBal = $bal - $change;
}
elsif ($type =~ /inv/i) {
$newBal = $bal + $change;
}
else {
print "UNKNOWN calculation type!!\n"
}
print "Calc: Type=> $type\t\tOld=> $bal\t\tChange=> $change\t\tNew=>
$newBal\n";
return ($newBal/100);
} # end sub calcBal
Where the parameters $bal and $change are 2dp numeric values, I am getting
(sometimes) lines on the output as follows :-
"Calc: Type=> Pay Old=> 46.73 Change=> 38.87 New=> 786.000000000002"
Where I get the problem, it's always in the same place.
I'm running perl with the -w switch - all is quiet
I've looked at the source data - that's OK, with no control codes or other
poor data.
I've tried runnning the same calculation with perl -e from the command line,
and I get the correct value.
Given the (highly complex) math involved here, I'm probably missing
something trivial
does anybody have any ideas, I'm going cross-eyed looking at this!
Cheers,
Alex Croton
------------------------------
Date: 12 Aug 1999 10:17:32 GMT
From: M.Ray@ulcc.ac.uk (Malcolm Ray)
Subject: Re: CHMOD function
Message-Id: <slrn7r57ps.4ot.M.Ray@carlova.ulcc.ac.uk>
On Thu, 12 Aug 1999 00:55:23 -0400, stirling@banet.net <stirling@banet.net>
wrote:
>Martien Verbruggen wrote in message ...
>>In article <37b22ce2@news1.us.ibm.net>,
>> <stirling@banet.net> writes:
>>
>>> If you don't believe me try my testing methods as described in my last
>>> follow up to Malcom Ray.
>>
>>The last response of you to Malcolm Ray is a reference to your
>>response to Tom Briles. You're really into recursion, aren't you?
>>
>>Do you really believe that you would know better than people who
>>actually read the source of perl? Why are you so stubborn? You could
>>have tested this yourself, you know?
>I did, and put the files in scripts. I then posted both versions of the
>scripts, (copy and paste onto the newsgroups). Along with this I posted a
>perl -V listing at the request of Malcom Ray. This is listed under his
>response on 8/10/99 at 7:15pm.
That's good, but it hasn't shown up here, nor at Deja. Perhaps your
ISP has problems?
It would probably be a good idea for you to repost that article. See,
you've claimed a Perl bug. If you're right, it's important to demonstrate
it so that it can be fixed, and if you're wrong, it's important for the
claim to be refuted so that people can stop worrying about whether their
code is vulnerable to that bug.
--
Malcolm Ray University of London Computer Centre
------------------------------
Date: Thu, 12 Aug 1999 12:14:06 GMT
From: remsta@my-deja.com
Subject: Copy a hash of hashes of hashes
Message-Id: <7oudq7$vs4$1@nnrp1.deja.com>
I need to copy a hash...that contains several nested (and nested and
nested) hashes.
When I try to copy the hash using:
my %new_hash = %$old_hash
This copies the first level of keys and values, but does not copy the
hashes that are nested. eg.
use strict;
my $hash = {};
$hash->{'testflag'}->{'testflag2'} = "a";
print "\n1.testflag: $hash->{'testflag'}->{'testflag2'}";
my %new_hash = %$hash;
%new_hash->{'testflag'}->{'testflag2'} = "b";
print "\n2.testflag new: " . %new_hash->{'testflag'}->{'testflag2'};
print "\n3.testflag old: $hash->{'testflag'}->{'testflag2'}";
And prints
1.testflag: a
2.testflag new: b
3.testflag old: b
Can anyone tell either, how to *copy* the entire complex data structure
such as these?
In need of help.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Thu, 12 Aug 1999 09:06:59 -0400
From: Hector Gonzalez <hgonzalez@mindspring.com>
Subject: Re: Dereferencing anon hash
Message-Id: <37B2C6F2.35D5C5F7@mindspring.com>
I am very sorry about the inconveniences that my stupid formatting program has
caused. I didn't mean to disrupt your newsgroup in this way. I will stop sending
any mail to this newsgroup. Please forgive me.
Sorry
Hector Gonzalez
hgonzalez@questionexchange.com
Uri Guttman wrote:
> how many times do we have to tell you, DON'T QUOTE THE ENTIRE PREVIOUS
> POST!!!!
>
> this is as bad as jeopardy quoting. if you are commenting about a small
> amount of the original post, DELETE THE REST. and INTERSPERSE YOUR
> COMMENTS WITH THE QUOTED TEXT.
>
> i am shouting since that is the only way i know to get experts to
> listen.
>
> there seems to be cabal of people behind this web site and none of them
> realize or know that they are being gatewayed to this group. they have
> this USENET customer id which seems to get some posts from here into
> their pay for answers site. i think this is to drum up customers. but
> the expert quality has been proven very lacking.
>
> and the losuy quoting is because of the stupid web interface which
> probably just post the quote and the answer and doesn't allow
> editing. on top of that it mangles line wraps in both directions.
>
> this is getting very annoying very fast.
>
> i may actually killfile something. i do mark win32 subjects and skip them.
>
> uri
>
> --
> Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
> uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
> Have Perl, Will Travel ----------------------------- http://www.sysarch.com
> The Best Search Engine on the Net ------------- http://www.northernlight.com
> "F**king Windows 98", said the general in South Park before shooting Bill.
--
QuestionExchange, the Knowledge Marketplace.
http://www.questionexchange.com
------------------------------
Date: 12 Aug 1999 03:38:35 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: dot is too precious to be only for string concatenation
Message-Id: <37b2961b@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
"John Lin" <johnlin@chttl.com.tw> writes:
:What do you think about it?
I think you're twelve years too late.
--tom
--
"Bigotry dwarfs the soul by shutting out the truth."
- Edwin Hubbel Chaplin
------------------------------
Date: Thu, 12 Aug 1999 19:07:37 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: Fastest form of an 'if'
Message-Id: <MPG.121d39e8d3a9dd61989c16@news-server>
Andrew Fry writes ..
>Which of these 3 forms of 'if a then b' is faster ?...
>1. if (a) { b; }
>2. b if (a);
>3. a && b;
>... or isnt there enough in it to worry about ?
yes
--
jason - elephant@squirrelgroup.com -
------------------------------
Date: Thu, 12 Aug 1999 10:07:39 GMT
From: gary@onegoodidea.com (Gary O'Keefe)
Subject: Re: Fastest form of an 'if'
Message-Id: <37b29b43.6724134@news.hydro.co.uk>
A keyboard was whacked upside Andrew Fry's head and out came:
>Which of these 3 forms of 'if a then b' is faster ?...
>1. if (a) { b; }
>2. b if (a);
>3. a && b;
>... or isnt there enough in it to worry about ?
I've never used Benchmark before (and I was a wee bit bored), so I
tried this:
#!/usr/local/bin/perl -w
use strict;
use Benchmark;
my $a = 0;
my $b = 1;
my $c;
my $count = 10_000_000;
timethese(
$count, {
'if ( $a ) { $c = $b }' => 'if ( $a ) { $c = $b; }',
'$c = $b if ( $a )' => '$c = $b if ( $a );',
'$c = $a && $b' => '$c = $a && $b;'
}
);
and the results were:
Benchmark: timing 10000000 iterations of $c = $a && $b, $c = $b if (
$a ), if ( $a ) { $c = $b }...
$c = $a && $b: 15 secs (12.95 usr 0.00 sys = 12.95 cpu)
$c = $b if ( $a ): 8 secs ( 8.19 usr 0.00 sys = 8.19 cpu)
if ( $a ) { $c = $b }: 6 secs ( 6.76 usr 0.00 sys = 6.76 cpu)
suggesting that the first form is nearly twice as fast as using the &&
operator, but these were over 10M iterations (it took about 1M
iterations before Benchmark would even report on the timings, the
timings were so small).
Gary
--
Gary O'Keefe
gary@onegoodidea.com
You know the score - my current employer has nothing to do with what I post
------------------------------
Date: Thu, 12 Aug 1999 06:29:17 -0400
From: Lane Rettig <lane@rettig.com>
Subject: Re: How to count clicks to HTML link.
Message-Id: <37B2A1FD.A9009F56@rettig.com>
[CC'ed to author]
$refresh_string = '<META HTTP-EQUIV="REFRESH" CONTENT="0; URL=';
$tail = '">";
print "$refresh_string$url_string$quote$tail\n";
You don't need to use HTML code for a browser-redirect. It'd be a
better idea to use HTTP headers. For example:
print "Location: $url_string\n\n";
Good luck!
Amonotod wrote:
>
> Well, I've not been at this long, but what do you think of this?
> http://www.geocities.com/SiliconValley/Circuit/8340/my_redir_solution.ht
> ml
------------------------------
Date: 12 Aug 1999 10:41:19 GMT
From: billynospam@mirror.bt.co.uk (Graham Ashton)
Subject: Re: is our reese the author of mysql book?
Message-Id: <slrn7r596g.aag.billynospam@wing.mirror.bt.co.uk>
In article <slrn7r46h9.d88.abigail@alexandra.delanet.com>, Abigail wrote:
>
>Not only is the Perl and DBI usage bad, "select * from $table" is
>also bad HTML.
It's *very* bad HTML ! ;)
--
Graham
------------------------------
Date: Thu, 12 Aug 1999 13:41:39 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Multi-Page Forms
Message-Id: <Pine.HPP.3.95a.990812133944.21009B-100000@hpplus03.cern.ch>
On 12 Aug 1999, Sam Holden wrote:
> On 12 Aug 1999 1:49:7 GMT, QuestionExchange <USENET@questionexchange.com> wrote:
>
> <snip 30 line quote without attribution>
(and so on)
> Do you really think your post was useful? Do you think it was more
> useful than yesterdays answer by Randal L. Schwartz?
The only way they seem to have found of raising the relative value of
their for-pay service is to vandalise this group.
------------------------------
Date: Thu, 12 Aug 1999 09:28:38 GMT
From: bobby1233847@my-deja.com
Subject: Newbie? => Merging 2 files to a third file
Message-Id: <7ou43u$pe6$1@nnrp1.deja.com>
HI,
having probs. with the foll. code
I want to merge 2 files to a third file like
This is line1 from file1
This is line2 from file2
...
and so on..
Can somebody pls. help me..
#########################
open(FILE1,"merge1.txt") || die("File open error");
$line1 = <FILE1>;
chop($line1);
print("After opening value of line1: $line1\n");
open(FILE2,"merge2.txt") || die("File open error");
$line2 = <FILE2>;
chop($line2);
print("After opening value of line2:$line2\n");
open(FILE3,">mergedfile.txt");
while(<FILE1> && <FILE2>)
{
print("Inside while loop,if line1 condn:$line1\n");
$line1 = <FILE1>;
chop($line1);
print("Inside while loop,if line2 condn:$line2\n");
$line2 = <FILE2>;
chop($line2);
}
close(FILE1);
close(FILE2);
close(FILE3);
######################
many thanks,
Bobby
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Thu, 12 Aug 1999 11:55:57 GMT
From: gary@onegoodidea.com (Gary O'Keefe)
Subject: Re: Newbie? => Merging 2 files to a third file
Message-Id: <37b2ae6b.3094432@news.hydro.co.uk>
A keyboard was whacked upside bobby1233847@my-deja.com's head and out
came:
>HI,
> having probs. with the foll. code
>I want to merge 2 files to a third file like
>This is line1 from file1
>This is line2 from file2
>...
>and so on..
>Can somebody pls. help me..
>
[ Code snipped ]
I assumed that when one file ended, the rest of the other is to be
appended to the output, and I wrote this:
### Code ###
#!/usr/local/bin/perl -w
use strict;
my $fileone;
my $filetwo;
open ( FILE1, "file1.txt" ) ||
die "Error opening file1.txt for reading. $!\n";
open ( FILE2, "file2.txt" ) ||
die "Error opening file2.txt for reading. $!\n";
open ( FILE3, ">file3.txt" ) ||
die "Error opening file3.txt for writing. $!\n";
while(defined($fileone = <FILE1>) + defined($filetwo = <FILE2>)) {
if ( $fileone ) { print FILE3 "this is file 1: $fileone"; }
if ( $filetwo ) { print FILE3 "this is file 2: $filetwo"; }
}
close ( FILE1 ) || die "Could not close file1.txt. $!\n";
close ( FILE2 ) || die "Could not close file2.txt. $!\n";
close ( FILE3 ) || die "Could not close file3.txt. $!\n";
### End Code ###
The short-circuiting of the || operator caused me a wee headache as I
originally wanted to write the while condition as
while(defined($fileone = <FILE1>) || defined($filetwo = <FILE2>)) {
which would only evaluate the LHS if there were lines left to be read
from FILE1. The output would only be from FILE1, until it was
exhausted, then from FILE2.
Using the + operator as a non-short-circuiting logical-OR is a bit
unsatisfactory as it relies on the knowledge that return value of
defined() will be a positive number if TRUE and zero if FALSE. If the
behaviour of defined() is changed later (and the docs say it will for
proper operation on aggregate data structures), or the accepted
definition of TRUE and FALSE are changed, then this code may break.
Writing code that's closely coupled with a particular language
implementation (either to a library version or to a particular
platform) is always a bad idea.
A better idea for a workaround would be:
while((defined($fileone = <FILE1>)?1:0) + (defined($filetwo =
<FILE2>)?1:0)) {
which should be implementation independent (but a bit complicated when
I was trying to make my earlier point about short-circuiting) as the
return value from defined() is explicitly cast from TRUE or FALSE to 1
or 0.
Can anyone else answer: is there a non-short-circuiting logical-OR
operator available? I won't ask if one should be available (I read the
?? thread - too much fuss).
Gary
--
Gary O'Keefe
gary@onegoodidea.com
You know the score - my current employer has nothing to do with what I post
------------------------------
Date: Thu, 12 Aug 1999 07:47:15 -0400
From: "Peter Icaza" <picaza@chsi.com>
Subject: Re: pricing a perl job
Message-Id: <7ouc7s$5jka$1@pike.uhc.com>
can we move on now?
peter
------------------------------
Date: Thu, 12 Aug 1999 13:22:24 +0300
From: Nikos Mavrogiannakis <nikos@biznet.com.gr>
Subject: Problem Connecting To a remote database
Message-Id: <37B2A060.9D808E5D@biznet.com.gr>
We are trying to connect to a remote database (Oracle 7 - AIX) via sql
net from a Win Nt server. We wrote a script using win32::ODBC modules.
The problem is that we can connect to the database running the script
from MS-DOS prompt but we cannot access the database through World Wide
Web. We tried to achieve a connection creating User, System and file
DSN's with the ODBC Administrator but we have the same problem (Actually
the file DSN doesn't work at all - the script seems that it cannot
recognise a file DSN ).
We would appreciate your help.
------------------------------
Date: Thu, 12 Aug 1999 09:05:00 -0400
From: Hector Gonzalez <hgonzalez@mindspring.com>
Subject: Re: Reset .. ie clear out a hash array
Message-Id: <37B2C67C.68F7D086@mindspring.com>
I am very sorry about the inconveniences that my stupid formatting program
has caused. I didn't mean to disrupt your newsgroup in this way. I will stop
sending any mail to this newsgroup. Please forgive me.
Sorry
Hector Gonzalez
hgonzalez@questionexchange.com
Larry Rosler wrote:
> [Posted and a courtesy copy sent.]
>
> In article <828qx@questionexchange.com> on 12 Aug 1999 5:26:50 GMT,
> QuestionExchange <USENET@questionexchange.com> says...
>
> <SNIP of unattributed quote of article, in toto except for the first
> line and the blank lines.>
> >
> >
> >
>
> At least this answer isn't incorrect.
>
> WHAT THE FUCK ARE YOU TRYING TO DO TO THIS NEWSGROUP?
>
> You are spewing batches of crap here, despite being asked many times to
> stop.
>
> The questions are not being sent as requests to the website that you are
> trying to promote at our expense, but you are answering them anyhow.
>
> Your answers are inexpert, inexact, sometimes dangerously wrong.
>
> You have improved from unformatted unreadable crap to misformatted
> unintelligible crap.
>
> You have responded to our requests for signed articles by providing
> occasionally a four-letter name, without any other identification of the
> individual involved so that we can know whom we are dealing with and can
> open a corrective dialogue.
>
> You are not being killfiled because you are too dangerous to be allowed
> to continue unmonitored.
>
> I have run out of patience, but I do not know enough about Usenet
> management to know what to do about this blatant abuse.
>
> WILL SOMEONE RID US OF THIS PESTILENCE?
>
> --
> (Just Another Larry) Rosler
> Hewlett-Packard Laboratories
> http://www.hpl.hp.com/personal/Larry_Rosler/
> lr@hpl.hp.com
--
QuestionExchange, the Knowledge Marketplace.
http://www.questionexchange.com
------------------------------
Date: 12 Aug 1999 03:34:24 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Sending mail to "QuestionExchange"
Message-Id: <37b29520@cs.colorado.edu>
These people are a plague. They do not admit who they are. Anonymity
destroys accountability. They overquote, including sigs and spamvert
attachments. They give bad answers. Worst of all, they appear to be
using this newsgroup as a publicity gimmick to sucker people in to
some pay-per-question commerical venture.
I encourage everyone to send them mail detailing your displeasure
over their transgressions. A quick killfile entry is perhaps necessary,
but not sufficienty. Send them mail.
--tom
--
If the space is a problem, get a bigger computer. Computers are supposed
to serve man, not vice versa, the experience of the last 40 years
notwithstanding. --Larry Wall in <1995Jul30.033515.25114@netlabs.com>
------------------------------
Date: Thu, 12 Aug 1999 13:43:27 +0100
From: Paul Russell <x9730915@uea.ac.uk>
Subject: Re: Sesssion ID
Message-Id: <Pine.OSF.3.95q.990812134128.9145E-100000@cpca4.uea.ac.uk>
> > Okay, I want to write a login program which asks for a login name and
> > password and then keeps track of which user is using the script, someone
> > told me to use session id's. I have been looking on the net for ages but
> > can't find info on what session id's are and how to use them. Can anyone
> > help?
>
> why not just use the username?
Yeah, you could put the username in a cookie if you just want to know who
the person is. If you want 'proper' session management (where you're
storing lots of pieces of information about the session) you could do
worse than looking at the Apache::Session module, which also has the
benifit of being a little more secure (no plain text user id flying
backwards and forwards).
Paul
------------------------------
Date: Thu, 12 Aug 1999 09:58:46 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: Time:: Hires
Message-Id: <7ou61d$rrk$1@news.mch.sbs.de>
In article <7osauf$pie$1@usenet.rational.com>, "Ashish Bhargava" <abhargav@rational.com> wrote:
>After checking the docs for select(), I see that it is used for selecting
>filehandle. How would I use this for time measurements?
You haven't looked at the whole explanation for select :
perldoc -f select :
..
You can effect a sleep of 250 milliseconds this way:
select(undef, undef, undef, 0.25);
Besides, you can also install the Time::HiRes module directly
with ppm (for ActivePerl), so that should work too...
Michel.
------------------------------
Date: 12 Aug 1999 10:16:59 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: turn $6 into $6000
Message-Id: <7ou6ur$qcf$1@lublin.zrz.tu-berlin.de>
Larry Rosler <lr@hpl.hp.com> wrote in comp.lang.perl.misc:
>In article <slrn7r34j0.dc3.fl_aggie@thepentagon.com> on 11 Aug 1999
>15:08:13 GMT, I R A Darth Aggie <fl_aggie@thepentagon.com> says...
>> On Wed, 11 Aug 1999 07:49:23 -0700, Larry Rosler <lr@hpl.hp.com>, in
>> <MPG.121b2d413991c4ca989e30@nntp.hpl.hp.com> wrote:
>> + But that solution is only O(N). Surely you can do worse.
>>
>> Worse? sure.
>>
>> perl -e '$bucks=0; foreach (0..5999) { $bucks+=1;} print "\$$bucks\n";'
>>
>> If I'm remembering things correctly, there's the time/space required to
>> generate a list of (0..5999), of course looping iteratively just to add
>> a constant isn't particularly efficient. No, just like the subject, this
>> is a terrible way to get to $6000.
>
>A couple of problems here.
>
>1. It is still O(N).
>
>2. It doesn't get from '$6' to '$6000', but from 0 (or '$0').
>Abigail's ++ solution works, though. '++' is not the same as '+= 1',
>
>> Somehow:
>>
>> perl -e '$bucks=0; foreach (0..6000) { $bucks+=$_;} print "\$$bucks\n";'
>>
>> has a much prettier result. But just as inefficient... ;)
>
>Prettier if it's my bank balance. But still only O(N). Try harder!
Okay...
my @l = ( '0000' ) x 6000;
$l[ rand 6000] = '6000';
my $pat = '(....)' x 6000;
( join '', sort @l) =~ m/$pat/;
print '$', $6000, "\n";
Anno, contemplating bubblesort
------------------------------
Date: 12 Aug 1999 10:39:31 GMT
From: vshlomit@vegas.weizmann.ac.il (Afgin Shlomit)
Subject: Why ?
Message-Id: <7ou893$ksm$1@wissol.weizmann.ac.il>
I have a very strange problem with perl, at list to me.
part of the source look:
my @variables = ("First Name","Last Name","Department","Position","EMail ",
"Human Genomic sequences",
"Genbank", "Genecards", "Unigene", "Epd", "Other",
"Mapping Databases",
"Udb", "Udg", "Genemap", "Other",
"Resources",
"Other", "Local resources", "Comments");
my @context = ("fn", "ln", "dept", "pos", "email",
"title",
"genbank", "genecards", "unigene", "epd", "other_seq_db",
"title",
"udb", "udg", "genemap", "other_map_db",
"title",
"intron_exon", "alt_splic",
"promoter", "enhancer",
"mrna_to_genomic", "gen_fam",
"other_sources", "local_resources", "comments");
my $tt;
for ($i = 0; $i <=$#variables; $i++) {
$stam{'$variables[$i]'} = "xxx$i";
$tt = $variables[$i];
print "$variables[$i]:\t$stam{'$variables[$i]'}\n";
}
$i=1;
$tt = $variables[$i];
print "i= $i context: $context[$i] stam_var: $stam{'$variables[$i]'} var: $variable
s[$i] $variables[2]\n";
print "i= $i context: $context[$i] stam_var: $stam{'$variables[2]'} var: $variable
s[$i] $variables[2]\n";
print "i= $i context: $context[$i] stam_var: $stam{$variables[2]} var: $variable
s[$i] $variables[2]\n";
print "i= $i tt= $tt context: $context[$i] stam_var: $stam{$tt} var: $variables[
$i] $variables[2]\n";
The problem is with the stam array. Now look at the print command.
in The first print it's print the last elemnt (25) of my array even that I asked for
the $i and $i equal 1.
In all other lines it's print nothing.
The output is:
i= 1 context: ln stam_var: xxx25 var: Last Name Department
i= 1 context: ln stam_var: var: Last Name Department
i= 1 context: ln stam_var: var: Last Name Department
i= 1 tt= Last Name context: ln stam_var: var: Last Name Department
--
Shlomit.
------------------------------
Date: Thu, 12 Aug 1999 15:02:52 +0200
From: mock <mock@knapp.co.at>
Subject: Re: Why ?
Message-Id: <37B2C5FC.21840839@knapp.co.at>
Dies ist eine mehrteilige Nachricht im MIME-Format.
--------------E6BF1DA22C132923C258CC21
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Afgin Shlomit schrieb:
> I have a very strange problem with perl, at list to me.
> part of the source look:
> my @variables = ("First Name","Last Name","Department","Position","EMail ",
> "Human Genomic sequences",
> "Genbank", "Genecards", "Unigene", "Epd", "Other",
> "Mapping Databases",
> "Udb", "Udg", "Genemap", "Other",
> "Resources",
> "Other", "Local resources", "Comments");
> my @context = ("fn", "ln", "dept", "pos", "email",
> "title",
> "genbank", "genecards", "unigene", "epd", "other_seq_db",
> "title",
> "udb", "udg", "genemap", "other_map_db",
> "title",
> "intron_exon", "alt_splic",
> "promoter", "enhancer",
> "mrna_to_genomic", "gen_fam",
> "other_sources", "local_resources", "comments");
> my $tt;
> for ($i = 0; $i <=$#variables; $i++) {
> $stam{'$variables[$i]'} = "xxx$i";
> $tt = $variables[$i];
> print "$variables[$i]:\t$stam{'$variables[$i]'}\n";
> }
>
your problem is a misuse of '$variables[$i]'. single quoted strings will not be expanded
(interpolated). use instead double quotes ("$variables[$i]") if you wanna get a Hash
with elements like $stam{'First Name'}, $stam{'Last Name'}...
have a nice day and keep on writing perl
klaus
> The problem is with the stam array. Now look at the print command.
> in The first print it's print the last elemnt (25) of my array even that I asked for
> the $i and $i equal 1.
> In all other lines it's print nothing.
> The output is:
> i= 1 context: ln stam_var: xxx25 var: Last Name Department
> i= 1 context: ln stam_var: var: Last Name Department
> i= 1 context: ln stam_var: var: Last Name Department
> i= 1 tt= Last Name context: ln stam_var: var: Last Name Department
>
> --
>
> Shlomit.
--------------E6BF1DA22C132923C258CC21
Content-Type: text/x-vcard; charset=us-ascii;
name="mock.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Visitenkarte für mock
Content-Disposition: attachment;
filename="mock.vcf"
begin:vcard
n:Mock;Klaus
x-mozilla-html:FALSE
org:Knapp Logistik Automation
version:2.1
email;internet:mock@knapp.co.at
x-mozilla-cpt:;0
fn:Klaus Mock
end:vcard
--------------E6BF1DA22C132923C258CC21--
------------------------------
Date: 12 Aug 1999 13:36:14 +0200
From: Kvan <kvan@dis.dk>
Subject: Re: Why use Perl when we've got Python?!
Message-Id: <u907h5iz5.fsf@dis.dk>
Ian Clarke <I.Clarke@strs.co.uk> writes:
> Perl seems to be more of a rebellion against good language design, and
> while people claim that this makes it "more efficient" to code in, I
> have yet to see the proof - particularly if you include the time it
> takes to debug the code.
The proof with a thing such as coding, and particularly debugging, can
only be seen by doing it. Perl offers lots of debugging options, and
is in fact one of the easiest languages I've debugged in yet.
> The first thing that hit me with Perl is that different types of
> variables require different special characters to identify them, this
> reminds me of Atari Basic of the early 80s, and is not a feature we find
> in C.
Yet, many C programmers actually use a Hungarian notation anyway. In
perl it is enforced, and allows you to quickly judge the type of
complex constructs (it's easy to tell that @{$foo->bar("snafu")} is an
array, even without knowing a thing about the scalar $foo). This is,
I'll admit, quite contrary to the TIMTOWTDI philosophy of Perl, but it
works well.
The bottom line is that, while it may look less clean to the untrained
eye, Perl code is actually very readable once you know how to read
it. This also means that you cannot fairly assess the repective merits
of Python and Perl without knowing both fairly well--and since I don't
know much Python (always meant to learn it, but didn't find the time
so far), I won't get any further into this.
Kvan.
--
-------Casper Kvan Clausen------ | 'A *person* is smart. People are
---------<kvan@dis.dk>---------- | dumb, panicky, dangerous animals
| and you know it.'
| - "K" in Men in Black.
------------------------------
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 478
*************************************