[9028] in Perl-Users-Digest
Perl-Users Digest, Issue: 2646 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 20 08:13:07 1998
Date: Wed, 20 May 98 05:00:54 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 20 May 1998 Volume: 8 Number: 2646
Today's topics:
Re: "Here" docs & cgi programming <ljz@asfast.com>
Re: "Here" docs & cgi programming (Shishir Gundavaram)
Re: Benchmark: \s against [ \t] (Jari Aalto+mail.perl)
Re: CGI-Publishing-Scripts (Fa Q 242)
Re: Connected users on a NT-Server msuszko@my-dejanews.com
Re: Function syntax with prototyping, filehandles and a (Marc Haber)
Re: Function syntax with prototyping, filehandles and a <qdtcall@esb.ericsson.se>
Re: Getting at the symbol table for an object. <qdtcall@esb.ericsson.se>
Re: Help please... <perlguy@inlink.com>
Re: How well does Perl work with VMS? <qdtcall@esb.ericsson.se>
Information about fetchrow... <cristina.durana@iie.min-edu.pt>
Re: Information about fetchrow... <agruskin@melbpc.org.au>
Re: Need a Perl Data Processing Example <ebohlman@netcom.com>
Newbie cgi question <bgebhart@juno.com>
Re: Newbie cgi question (Craig Berry)
omnihttpd <abcdm@wanadoo.fr>
perl and html ?? <abcdm@wanadoo.fr>
Perl Net::Telnet() (Antti-Jussi Korjonen)
Re: Perl Net::Telnet() (Martien Verbruggen)
Re: Perl Net::Telnet() (Antti-Jussi Korjonen)
Perl unable to read a file on IIS brabazon@blue.ocn.ne.jp
Run .pl or .cgi under Win95 <unique@net-lynx.com>
Sendmail to alias from Perl CGI script? <noels@chilli.net.au>
Re: sort array of hashes (Tom Grydeland)
test Perl program ?? <abcdm@wanadoo.fr>
Re: uploading but getting 0 bytes <qdtcall@esb.ericsson.se>
usage of perl in NT. ($ENV{'PREVIOUS_URL'} yat@scmp.com
Re: why doesn't it work?? (Martien Verbruggen)
Re: why doesn't it work?? <ebohlman@netcom.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 20 May 1998 00:00:06 -0400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: "Here" docs & cgi programming
Message-Id: <ltemxpa8xl.fsf@asfast.com>
Liz & Joe Niederberger <lniederberger@monmouth.com> writes:
> I was thinking how nice it would be if I could write
> cgi scripts with "variable interpolation" operating on
> subroutine references as well as scalars and arrays.
>
> Combined with here documents it would allow a very clean
> expression of "recursive descent" style text generation.
> You could call it syntactic sugar but it sure would make
> the typical code I write much easier to read.
>
> Anyone know why Perl only interpolates scalars & arrays?
Try this:
sub xxx {
my $arg = shift;
unless (defined($arg)) {
$arg = 'None';
}
return ("result($arg)");
}
print "No argument: ${\&xxx()}\n";
print "With argument: ${\&xxx(foobar)}\n";
--
Lloyd Zusman ljz@asfast.com
perl -e '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
$t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
$x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x\n"'
------------------------------
Date: 20 May 1998 08:14:48 GMT
From: shishir@ruby.ora.com (Shishir Gundavaram)
Subject: Re: "Here" docs & cgi programming
Message-Id: <6ju3do$ha9$1@amber.ora.com>
Liz & Joe Niederberger (lniederberger@monmouth.com) wrote:
: I was thinking how nice it would be if I could write
: cgi scripts with "variable interpolation" operating on
: subroutine references as well as scalars and arrays.
[...]
: Anyone know why Perl only interpolates scalars & arrays?
Of course, it can. You just need a different syntax:
print <<_Some_Junk;
$a
@a
Calling a: @{[ a() ]}
The current time is: @{[ scalar localtime ]}
_Some_Junk
Happy? Good.
--Shishir
------------------------------
Date: 20 May 1998 11:06:32 +0300
From: <jari.aalto@poboxes.com> (Jari Aalto+mail.perl)
Subject: Re: Benchmark: \s against [ \t]
Message-Id: <tbvhr1jrhz.fsf@blue.sea.net>
| 98-05-18 Jonathan Feinberg <jdf@pobox.com> comp.lang.perl.misc
| Jari Aalto <jari.aalto@poboxes.com> writes:
|
| > I have played with benchmark and I thought that \s was somehow
| > specially optimized.
| > Would someone comment if my bencmark method was wrong or does \s
| > just get translated to [ \t] when compiling the regexp?
|
| Those are not exclusive options. \s is indeed a character class,
| though it includes *all* whitespace.
I posed my question a bit unclearly: "Usually people use \s as a synonym
to [ \t]. Is there any difference in speed?"
The \s mathes [ \t\n\r\f], but I was in an assumtrion that the \s itself
was somehow specially optimized. According to benchamrk, there seems to
be no difference, which would indicate that \s gets tranlated to
[ \t\n\r\f] before giving to Matcher.
That would lead to [ \t] and [ \t\n\r\f] comparision, which is
(practically) identical in execution time.
So, \s is not optimised?
| > perl 5.4.4 :
That's shorthad to 5.004_04
jari
------------------------------
Date: 20 May 1998 05:03:51 GMT
From: faq242@aol.com (Fa Q 242)
Subject: Re: CGI-Publishing-Scripts
Message-Id: <1998052005035100.BAA05665@ladder03.news.aol.com>
Awhile back I used to give away free web space on my regular virtually hosted
account, so I needed a way to allow people to make/edit their sites without
logging in to ftp. I used genesis which allows this. It allows you to do
almost anything you could do with an ftp account and lets you create or edit
text/html files over your browser. Get it at:
http://www.xav.com/scripts/genesis
------------------------------
Date: Wed, 20 May 1998 05:18:01 GMT
From: msuszko@my-dejanews.com
Subject: Re: Connected users on a NT-Server
Message-Id: <6jtp28$53q$1@nnrp1.dejanews.com>
In article <6js6lr$5b0$1@mdtyr.oss.dk>,
"Arne Jaeger" <aej@md-oss.dk> wrote:
>
> Does anybody know of some routines to get all the usernames currently
> connected to a given NT-Server ?
> I need it to send a message from a script, but only if a user have an
active
> connection to a given server.
>
> Thanx
>
> Hunter
>
>
Try using the 'net session' command.
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Wed, 20 May 1998 08:46:05 GMT
From: Marc.Haber-usenet@gmx.de (Marc Haber)
Subject: Re: Function syntax with prototyping, filehandles and arrays
Message-Id: <6ju58h$cum$3@nz12.rz.uni-karlsruhe.de>
Marc.Haber-usenet@gmx.de (Marc Haber) (that's me!) wrote:
>Hi!
I then proceeded to word an exact question about writing a perl script
running on Linux, relating to perl syntax and semantic, even posting a
code snipped that I tried and that doesn't work. Also, I stated that I
actually read the docs _and_ the camel book but I didn't fully grasp
the more advanced concepts.
What did I do wrong this time to again not qualify for an answer? What
do you expect me do to? Beg? Pray?
Greetings
Marc
--
-------------------------------------- !! No courtesy copies, please !! -----
Marc Haber | " Questions are the | Mailadresse im Header
Karlsruhe, Germany | Beginning of Wisdom " | Fon: *49 721 966 32 15
Nordisch by Nature | Lt. Worf, TNG "Rightful Heir" | Fax: *49 721 966 31 29
------------------------------
Date: 20 May 1998 11:11:45 +0200
From: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: Function syntax with prototyping, filehandles and arrays
Message-Id: <isg1i58fxq.fsf@godzilla.kiere.ericsson.se>
Marc.Haber-usenet@gmx.de (Marc Haber) writes:
> What did I do wrong this time to again not qualify for an answer?
It may just be that not that many people have used function
prototypes, and thus that there aren't all that many who know the
answer to your question.
Waiting a bit longer than a day and a half might be a good idea, too.
Article propagation on Usenet is far from instantaneous.
--
Calle Dybedahl, UNIX Sysadmin
qdtcall@esavionics.se http://www.lysator.liu.se/~calle/
------------------------------
Date: 20 May 1998 09:28:55 +0200
From: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: Getting at the symbol table for an object.
Message-Id: <islnrx8kp4.fsf@godzilla.kiere.ericsson.se>
Steve Goldstein <steveg_nospam@gcg.com> writes:
> How do I generalize this to all variables in an instantiation of an
> object?
Since there is no standard way to store instance variables in an
object, you don't. You have to look at the code for the object in
question, first to figure out how it stores its information and then
how to access it.
--
Calle Dybedahl, UNIX Sysadmin
qdtcall@esavionics.se http://www.lysator.liu.se/~calle/
------------------------------
Date: Wed, 20 May 1998 11:20:11 GMT
From: Brent Michalski <perlguy@inlink.com>
Subject: Re: Help please...
Message-Id: <3562BC6B.1FA38191@inlink.com>
DimCe,
I am sorry but you seem to have no clue whatsoever even where to start!
If this is an assignment for a job, I suggest changing careers.
If this is an assignment for a class at school, do they have any books
or instructors for this class? That is a good starting point.
Here are some links to help you get started, but you seem to have a long
road ahead on this one...
http://www.perl.com (look for the Windows NT links at the bottom of the
page)
http://www.activestate.com (For Perl/Win32)
http://www.roth.net (For ODBC connectivity)
Buy a good Perl book! Get the "Camel" or "Llama" book by O'Reilly
Also, I have written a little on similar subjects. For Form processing,
go to: http://www.webresource.net and click on the CGI area. Or go to
http://www.inlink.com/~perlguy/simple for a simple database in Perl.
The simple database is NOT recommended for large databases.
No matter where you go though, you will have a lot of work ahead of
you. There are tons of resources out on the 'net for those who "help
themselves".
Good luck!
Brent Michalski
------------------------------
Date: 20 May 1998 09:22:28 +0200
From: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: How well does Perl work with VMS?
Message-Id: <isogwt8kzv.fsf@godzilla.kiere.ericsson.se>
violadawn@my-dejanews.com writes:
> I need some suggestion from who has ported Perl on VAX/VMS.
VMS is one of the platforms supported by the standard distribution.
> I wonder how well Perl can handle these large amount of data.
Well, as long as you have the RAM/swap/whateverVMSuses for it (if you
don't have the memory, you may have to program cleverly instead).
> Also, are there any support or documentation about Perl and Perl/VMS
> available either in written or html format. If there are, where can
> I find those?
There's a VMS-Perl mailing list. Check http://www.perl.com/ for the
subscription address.
--
Calle Dybedahl, UNIX Sysadmin
qdtcall@esavionics.se http://www.lysator.liu.se/~calle/
------------------------------
Date: Wed, 20 May 1998 12:05:06 +0200
From: Cristina Durana <cristina.durana@iie.min-edu.pt>
Subject: Information about fetchrow...
Message-Id: <3562AAD2.CD482067@iie.min-edu.pt>
Hi all!!!!!!
I need, with urgency, infromation about the instruction "fetchrow"...
Anybody could help me, please...
Thanks in advance
Cristina
------------------------------
Date: Wed, 20 May 1998 21:26:12 +1000
From: Andrew Gruskin <agruskin@melbpc.org.au>
Subject: Re: Information about fetchrow...
Message-Id: <3562BDD3.451F3D94@melbpc.org.au>
Cristina Durana wrote:
> Hi all!!!!!!
> I need, with urgency, infromation about the instruction "fetchrow"...
> Anybody could help me, please...
> Thanks in advance
> Cristina
Usual deal, Cristina. What information do you need? The documentation
for Win32::ODBC, assuming this is the FetchRow you want will explain how
to use all the methods and successfully attach to an ODBC database. Have
a look at http://www.roth.net/odbc if you don't have the documentation.
Andrew
------------------------------
Date: Wed, 20 May 1998 08:29:38 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Need a Perl Data Processing Example
Message-Id: <ebohlmanEt8y9E.H0M@netcom.com>
Randal Rayborn <rrayborn@slip.net> wrote:
: I have two fixed field data files which I need to read in, join together on
: a merge key (say one for simplicity) and write out as a complete file. Does
: anyone have a good code example for this? I am specifically interested in
: the process of reading a record from one file then looping through and
: matching the key field on the other file. This is a very "COBOL-like"
: operation.
Consider reading one of the files into a hash, keyed on the match field,
and then looping through the other file once. If one of the files
contains only one record per match-field value, it should be the one you
read into the hash; if both files can contain multiple records with the
same value, you'll need to create a hash of arrays rather than of simple
strings.
Unless the files are very small, this will be a *lot* faster than reading
every line of the second file for every line of the first one.
------------------------------
Date: 20 May 1998 05:01:28 GMT
From: "Bob Gebhart" <bgebhart@juno.com>
Subject: Newbie cgi question
Message-Id: <6jto38$fnc@bgtnsc02.worldnet.att.net>
We're evaluating Perl, SilverStream, JBuilder, etc., trying to pick a good
Internet/Intranet development tool. I'm strongly attracted to Perl because
of its power and "C-look", but am very, very ignorant, particularly in CGI
programming. Here's my question:
Say I have a form with 10 fields, and I don't want to let the user enter
all 10 fields and send the form back to let me check it server-side. I want
to data-check the 4th field, say (it's a part #, with a required format),
and bitch at the user if he screwed up. The 11th field, say, I want to
check against a database of umpty-ump company names, resident on the
server.
The point is that I want to do data-checking on a field-by-field basis,
rather than doing all data checks at the end of the form.
I know this can be done with Java applets, but MUST I use Java for this
sort of thing? All I really want to do is tell the client to send the
server the 4th and 11th fields any time they change, but I'll accept any
method that tells the user he screwed up immediately after entering a
field.
Is there a practical way to do this in CGI Perl?
Yeah, I know, really a pitiful question. But you gotta start somewhere ...
---Bob
------------------------------
Date: 20 May 1998 05:57:58 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Newbie cgi question
Message-Id: <6jtrd6$8t5$1@marina.cinenet.net>
This is a CGI question more than a Perl question, and I've set followups
accordingly. But, since I'm in a good mood tonight... :)
Bob Gebhart (bgebhart@juno.com) wrote:
: We're evaluating Perl, SilverStream, JBuilder, etc., trying to pick a good
: Internet/Intranet development tool. I'm strongly attracted to Perl because
: of its power and "C-look", but am very, very ignorant, particularly in CGI
: programming. Here's my question:
Don't fall into the trap of asking "I wonder what I need to build this
house? A hammer, a saw, or a screwdriver?" There's no 'one best tool'
for net development; rather, successful net service providers have a full
toolkit of client and server side solutions available, and mix'n'match as
needed for each specific task.
: Say I have a form with 10 fields, and I don't want to let the user enter
: all 10 fields and send the form back to let me check it server-side. I want
: to data-check the 4th field, say (it's a part #, with a required format),
: and bitch at the user if he screwed up.
Use Javascript to do simple, non-server-dependent form validity checking
like this. However, *never* count on it having been done on the form
submitted to the server! Plenty of people out there don't have
Javascript-enabled browsers, by necessity or choice. Javascript form
pre-checking is purely a convenience for the user, pointing out simple
screw-ups without a long server round trip delay.
: The 11th field, say, I want to
: check against a database of umpty-ump company names, resident on the
: server.
That you do want to do with a server side solution; Java servlets talking
to Java on the served page, or Perl processing on the submitted form, or
whatever. If you need "right after entering the form field" rather than
"after the user submits the form", you want Java...but be aware that many
users will find the hang during net transaction time unacceptably
annoying.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: 20 May 1998 05:16:08 GMT
From: "DUTOIT" <abcdm@wanadoo.fr>
Subject: omnihttpd
Message-Id: <01bd83ae$2750d940$c891fcc1@SIT.wanadoo.fr>
Hello,
I want to use omnihttpd like a local server . I have it but how can I do ?
Thanks you very much
Mr DUTOIT
abcdm@wanadoo.fr
------------------------------
Date: 20 May 1998 05:13:57 GMT
From: "DUTOIT" <abcdm@wanadoo.fr>
Subject: perl and html ??
Message-Id: <01bd83ad$d901da00$c891fcc1@SIT.wanadoo.fr>
Hello,
I develop a program in Perl which may generate dynamical HTML pages.
At this time, I may test under DOS . I put in it a "query" for testing it ,
like:
my $query = new CGI('nbcol8=20&nocde=2456&cache=A&devise=Franc');
and I verify generated HTML pages.
My problem is to test completely my PERL program in connection with my
dynamical HTML pages.
Can I use omnihttpd like a local server and how?
Other solution to test it easily?
Thanks you very much
Mr DUTOIT
abcdm@wanadoo.fr
------------------------------
Date: 20 May 1998 05:27:55 GMT
From: aajii@aajii.ton.tut.fi (Antti-Jussi Korjonen)
Subject: Perl Net::Telnet()
Message-Id: <6jtpkr$s31$1@baker.cc.tut.fi>
HI!
Does anybody know where I could get documentation for that subject?
Reply, please.
--
__/ __/ __/ __/ Antti-Jussi Korjonen
__/ __/ __/ __/ __/__/ Vaajakatu 5 D 85
__/ __/ __/ __/ __/__/ 33720 TAMPERE, FINLAND
__/ __/ __/__/__/ __/ __/ tel. +358-(0)40-577 83 23
Antti-Jussi.Korjonen@sonera.fi
--------->> http://www.students.tut.fi/~k150556 <<---------
------------------------------
Date: 20 May 1998 06:17:06 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Perl Net::Telnet()
Message-Id: <6jtsh2$1nk$1@comdyn.comdyn.com.au>
In article <6jtpkr$s31$1@baker.cc.tut.fi>,
aajii@aajii.ton.tut.fi (Antti-Jussi Korjonen) writes:
> HI!
>
> Does anybody know where I could get documentation for that subject?
# perldoc Net::Telnet
If course, you will need to install it first. Otherwise, just download the
thing, and look at the documentation in the source directories.
> Reply, please.
uhuh.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
Date: 20 May 1998 08:05:43 GMT
From: aajii@aajii.ton.tut.fi (Antti-Jussi Korjonen)
Subject: Re: Perl Net::Telnet()
Message-Id: <6ju2sn$d2n$2@baker.cc.tut.fi>
I tried this on my Linux machine. The problem is that the
program doesn't seem to understand the Password: prompt.
It just complains:
timed-out waiting for password prompt at ./telnet.pl line 4.
But when I try with another host, say a Sun, everything
works just fine. The program executes the who command
and prints the output correctly.
But not with my Redhat Linux 5.0. What could be the cause?
------
use Net::Telnet ();
$t = new Net::Telnet (Timeout => 10, Prompt => '/bash\$ $/');
$t->open("sparky");
$t->login($username, $passwd);
@lines = $t->cmd("/usr/bin/who");
print @lines;
------
--
__/ __/ __/ __/ Antti-Jussi Korjonen
__/ __/ __/ __/ __/__/ Vaajakatu 5 D 85
__/ __/ __/ __/ __/__/ 33720 TAMPERE, FINLAND
__/ __/ __/__/__/ __/ __/ tel. +358-(0)40-577 83 23
Antti-Jussi.Korjonen@sonera.fi
--------->> http://www.students.tut.fi/~k150556 <<---------
------------------------------
Date: Wed, 20 May 1998 11:09:07 GMT
From: brabazon@blue.ocn.ne.jp
Subject: Perl unable to read a file on IIS
Message-Id: <6judkj$hk$1@nnrp1.dejanews.com>
The perl runs on IIS. There is output from the perl program by way of dummy
lines and what not. the code looks like this: A bogus file name will cause
the error message in the browser to appear.
open KIHON_DATA,"kihon_data.dat |" or die "Can't open
'kihon_data.dat':bcos $!"; my $count = 0; while (read KIHON_DATA, $_, 8192)
{ $count += tr/\n//; } close KIHON_DATA; print "Content-type:
text/html\n\n"; print "<html>\n"; print "<body>\n"; print "The file
'$kihon_data_file' has $count lines.\n<BR>"; <close the tags and end program>
I have tried an explicit file path, and all permutations to test if the file
is being found and opened. It seems to be open and the problem seems to be
with the read. Ive seen other postings re: the IIS registry, but if the
browser is able to show the output: The file 'kihon_data.dat' has 0 lines.
then I assume there are no problems there. I have other scripts producing
html and passing parameters to other scripts. The only catch seems to be in
reading files thru perl.
Any solutions considered .
TYIA
EB
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Wed, 20 May 1998 01:31:59 -0400
From: unique <unique@net-lynx.com>
Subject: Run .pl or .cgi under Win95
Message-Id: <35626ACF.BDDD777E@net-lynx.com>
I need help on running a perl script under a browser/Win95 .
What I am trying to do is to use Perl as a CGI to dynamically create a
"HTML" type output as stdout to be accepted by a browser!
Thanks a lot!
------------------------------
Date: Wed, 20 May 1998 20:31:22 +1000
From: "Noel Sampol" <noels@chilli.net.au>
Subject: Sendmail to alias from Perl CGI script?
Message-Id: <6jubbp$ec7$1@the-fly.zip.com.au>
Hi...
I have a Perl CGI script that runs /usr/bin/sendmail to send confirmation
e-mail to me and to the 'visitor'. The problem is when I try the script via
HTTP FORM POST using my e-mail alias of noels@ozinet.zip.com.au, the mail
does not get sent to my alias but only to my real email of noels@zip.com.au.
I have a virtual web domain www.ozinet.zip.com.au under my provider
www.zip.com.au .
My aliases work when sending from a mail client such as Outlook Express for
Win 95.
The script basically opens a connection to sendmail by:
open(MAIL, "|$mailprog $email");
print MAIL ("From: ..... etc etc
where $mailprog = "/usr/bin/sendmail";
and $email is the e-mail address that a visitor has typed in the HTTP form.
What does the "|" mean?
Also, I can't seem to provide parameters in the form "-X logfilename" as in
open(MAIL, "|$mailprog $email -X logfilename");
Is there another way to open a sendmail session from perl CGI?
If I use my noels@zip.com.au address, everything works fine, I've even
tested it from another ISP account and received mail to it at
noels@chilli.net.au BUT when I use my alias of noels@ozinet.zip.com.au or
sales.admin@ozinet.zip.com.au I don't get e-mail confirmation.
Sometimes, the log files indicate "bad header" apparently when I use an
address like
sales.admin@ozinet.zip.com.au .
Any ideas ?
Thanks
Noel Sampol
noels@ozinet.zip.com.au
------------------------------
Date: 20 May 1998 10:58:01 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: sort array of hashes
Message-Id: <slrn6m5dpp.fs.Tom.Grydeland@mitra.phys.uit.no>
On 19 May 1998 23:32:29 GMT,
Irene Barg <barg@nickel.as.arizona.edu> wrote:
> Hello,
>
> I'm running perl5.004_04 on a Sun SPARC.
>
> I want to sort an array of hashes based on the value of a specific key
> in each hash. I've read the Perl FAQ and Tom Christiansen's "Far More
> Than Everything You've Ever Wanted to Know About Sorting", and I'm
> still not getting it right. A portion of my code follows:
Good research. That helps.
> # foreach result, add new field 'rel_focus' so that we can sort on it
> for $href (@LoH) {
> # use obsdate to get PC relative focus
> $datetime = $href->{'psf_date_obs'};
> $rel_focus = matchfoc($datetime);
> $href->{'rel_focus'} = $rel_focus; # add a new key to $href
> }
What you're doing here is adding one key/value pair to *each* of your
hashes, namely
'rel_focus' => $rel_focus
This information will stay with your datums.
> sub byrel_focus {
> $rel_focus{$a} <=> $rel_focus{$b};
> }
Ah, but that won't work. $a and $b will be set to the elements of @LoH
to be compared, i.e. $a and $b are like the $href in your 'foreach' above.
If I read you correctly, this is what you need:
sub byrel_focus {
$a->{byrel_focus} <=> $b->{byrel_focus};
}
> I know I need to create a list of 'rel_focus' values, then sort
> that list,
That is another approach, not the one you've started on here.
> but I don't know how to keep the association to the other keys
> in each hash. I need to get this done yesterday, that's why I'm
> asking for help. I'll keep digging but appreciate any help.
Hope that helps,
> Irene Barg Email: ibarg@as.arizona.edu
--
//Tom Grydeland <Tom.Grydeland@phys.uit.no>
- Do radioactive cats have 18 half-lives? -
------------------------------
Date: 20 May 1998 05:15:09 GMT
From: "DUTOIT" <abcdm@wanadoo.fr>
Subject: test Perl program ??
Message-Id: <01bd83ae$04727500$c891fcc1@SIT.wanadoo.fr>
Hello,
I develop a program in Perl which may generate dynamical HTML pages.
My problem is to test completely my PERL program in connection with my
dynamical HTML pages.
Can I use omnihttpd like a local server and how?
Other solution to test it easily?
Thanks you very much
Mr DUTOIT
abcdm@wanadoo.fr
------------------------------
Date: 20 May 1998 09:09:42 +0200
From: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: uploading but getting 0 bytes
Message-Id: <isra1p8ll5.fsf@godzilla.kiere.ericsson.se>
cchapman@chat.carleton.ca (chris chapman) writes:
> I think it may be a configuration problem in possibly the operating system
> which is linux or the web server which is apache.
Then why on Earth are you asking about it in a newsgroup about the
Perl programming language?
--
Calle Dybedahl, UNIX Sysadmin
qdtcall@esavionics.se http://www.lysator.liu.se/~calle/
------------------------------
Date: Wed, 20 May 1998 06:41:49 GMT
From: yat@scmp.com
Subject: usage of perl in NT. ($ENV{'PREVIOUS_URL'}
Message-Id: <35627aac.88277926@news.hknet.com>
hi..
Anyone know the new function $ENV{'PREVIOUS_URL'} is work in NT w/
IIS4.0? I have try other enviroment but only this not work.
Thx. in advance.
..yat
p.s pls reply in email. too. Thx.
------------------------------
Date: 20 May 1998 05:30:51 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: why doesn't it work??
Message-Id: <6jtpqb$1bn$1@comdyn.comdyn.com.au>
Please read the following information on how to choose a good subject
line:
http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post
In article <6jteqg$dar@news.iis.com.br>,
flaon@iis.com.br (Chico) writes:
> Look at what i am trying please!!!
Please, don't shout.
> @ARGV = ('1.txt', '2.txt', '3.txt');
>
> foreach $linha (<>) {
> print "$linha at $ARGV[0]";
> }
>
> It does not print the name of the file ( $ARGV[0] )!
No need to shout.
$ARGV[0] is always a reference to the first element of @ARGV. If
you're looking for the name of the current file when reading from <>,
you need $ARG.
Do yourself a favour, and read the perlvar man page.
# perldoc perlvar
[snip]
$ARGV contains the name of the current file when reading
from <>.
[snip]
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | "In a world without fences,
Commercial Dynamics Pty. Ltd. | who needs Gates?"
NSW, Australia |
------------------------------
Date: Wed, 20 May 1998 09:40:27 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: why doesn't it work??
Message-Id: <ebohlmanEt91JF.JHJ@netcom.com>
Chico <flaon@iis.com.br> wrote:
: @ARGV = ('1.txt', '2.txt', '3.txt');
: foreach $linha (<>) {
: print "$linha at $ARGV[0]";
: }
: It does not print the name of the file ( $ARGV[0] )!
As others have pointed out, the name of the file currently being read is
$ARGV (remember that in Perl, an array and an unrelated scalar can have
the same name).
However, even $ARGV won't give you meaningful results in your code,
because you're using the <> operator in list context, which means that
Perl will read through all your files and build up an anonymous array
before you start looping. At that point, the information as to which
line came from which file will be lost.
If you changed your code to:
: while (defined($linha=<>)) {
: print "$linha at $ARGV";
: }
You'd get the results you wanted, because you'd be using <> in scalar
context, so $ARGV will still be valid.
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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 V8 Issue 2646
**************************************