[7373] in Perl-Users-Digest
Perl-Users Digest, Issue: 998 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 8 21:07:13 1997
Date: Mon, 8 Sep 97 18:00:50 -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 Mon, 8 Sep 1997 Volume: 8 Number: 998
Today's topics:
Re: -e and unlink not finding files <rootbeer@teleport.com>
Re: </.*?> vs. </[^>]*> (Jason Gloudon)
Re: </.*?> vs. </[^>]*> <v3100411@student.anu.edu.au>
A simpler perl question. <ordway@iwshost.net>
Re: Beginner's question : Perl or Java ? <fishrman@shell.wco.com>
Re: Beginner's question : Perl or Java ? (dave)
Better regex answer to FMTEYEWTK question "Is it a numb <Brett.W.Denner@lmtas.lmco.com>
Re: cannot create file within while loop <rootbeer@teleport.com>
DNS lookup with gethostbyaddr? <peter@preview.org>
Re: Free Perl Docs (was: Re: (no subject) ) <rootbeer@teleport.com>
Re: Getting rid of \n in textarea input (brian d foy)
Re: Getting rid of ] and [ in perl <pc1@scigen.co.uk>
HELP! subroutine is making me cry! <jscott@pixelny.com>
Re: how to make passwd.pl secure? <rootbeer@teleport.com>
Re: Incredibly basic Newbie question <camerond@mail.uca.edu>
Loadable C++ modules (Jason Proctor)
Re: Minimizing Memory Needed for Numbers Read from Bina (Ilya Zakharevich)
Re: Numeric sorting (Gabor Egressy)
Re: Passing varaibles or parameters from perl to javasc <c.megens@imn.nl>
Perl interpreters...I18n??? <amanuja@baynetworks.com>
problems building 5.004_01 on HP-UXB.09.00 (Stuart McDow)
Q: HOWTO - Manifest Constants <geoffrey@iname.com>
Re: Q: HOWTO - Manifest Constants (Matthew Cravit)
Re: regex problems (Jon Orwant)
Re: Regexp a Yes or No question? (Gabor Egressy)
Re: Regexp a Yes or No question? (Matthew Cravit)
Trying to get perl to load 2 files from the same call. (Greg Miller)
Re: what has it got in its ssocketses? (Michael Fuhr)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 8 Sep 1997 15:44:29 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "Michael A. Watson" <fishrman@shell.wco.com>
Subject: Re: -e and unlink not finding files
Message-Id: <Pine.GSO.3.96.970908153048.1108K-100000@julie.teleport.com>
On 8 Sep 1997, Michael A. Watson wrote:
> I am building a string which contains the path and file name of a file I
> wish to delete. I have $maindir which contains the complete path to my
> base directory, $path which contains the name of a subdirectory where
> the file that I wish to delete exists, and $num.html the file.
> The problem is that the following returns a message that the file does
> not exist through a browser, but when run through my shell account it
> says the file does exist:
> $filepath = "$maindir/$path/$num.html";
> -e $filepath and print "$filepath file exists!<BR>\n";
> -e $filepath or print "$filepath file doesn't exists!<BR>\n";
Could some component of the path to the file be unreadable to the server's
uid (gid)?
> If I replace $path with the actual directory name it works, but printing
> the old $path and the new hardcoded one reveals no differences.
(Not likely, but... Any symlinks and parent directories? chrooted server?)
Perhaps there are differences not visible to the naked eye. :-)
sub hexified {
join "\n", map(unpack('H*', $_), @_), '';
}
print "\$path is: ", hexified($path);
print hexified($filepath, "/what/you/want/as/the/filepath");
Is that output what you wanted or not? Is everything chomped, if need be?
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: 8 Sep 1997 23:16:37 GMT
From: jgloudon@bbn.com (Jason Gloudon)
Subject: Re: </.*?> vs. </[^>]*>
Message-Id: <5v210l$26o$1@daily.bbnplanet.com>
In article <52u3fv35gh.fsf@plight.lbin.com>,
kendall shaw <kshaw@plight.lbin.com> wrote:
>tadmc@flash.net (Tad McClellan) writes:
>
>> kendall shaw (kshaw@plight.lbin.com) wrote:
>> : Duhhh. How come </.*?> doesn't do what I thought it did?
>>
>> I dunno.
>>
>> Would you care to share with us what you thought it did?
>>
>> What *is* it anyway?
>>
>> A glob?
>>
>> A regex?
>
>Sheesh!
>
>Well, I'm failing to repeat the problem. I probly just messed
>something up, but let me ask a question instead:
>
>Is there ever a difference between the regular expressions: </.*?> and
></[^>]*>?
Hmm lots of ?'s. I'm ignoring both your question marks.
What are you trying to say by *? in </.*?> . Let's pretend that ? isn't
there.
Assuming you leave out that ? </.*> and </[^>]*> will always match on
the same strings but not in the same way.
Taking </A>F> as an example:
</.*> will match on the entire string since * is greedy
but
</[^>]*> will match on the substring </A> because you don't allow >
in your match
Jason Gloudon
------------------------------
Date: Tue, 09 Sep 1997 10:08:02 +1000
From: "MJ.VAN OOSTERHOUT" <v3100411@student.anu.edu.au>
Subject: Re: </.*?> vs. </[^>]*>
Message-Id: <34149362.721E@student.anu.edu.au>
> >Is there ever a difference between the regular expressions: </.*?> and
> ></[^>]*>?
>
> Hmm lots of ?'s. I'm ignoring both your question marks.
>
> What are you trying to say by *? in </.*?> . Let's pretend that ? isn't
> there.
>
> Assuming you leave out that ? </.*> and </[^>]*> will always match on
> the same strings but not in the same way.
>
> Taking </A>F> as an example:
> </.*> will match on the entire string since * is greedy
> but
> </[^>]*> will match on the substring </A> because you don't allow >
> in your match
>
> Jason Gloudon
The .*? means the same as .* except that it is not greedy. Therefore
</.*?> will match the string </A> and not the whole string. This ?
syntax can be used on several other operators as well. See perlre.
Also, I think .*? is not valid in Perl 4.
Martijn
Australia
------------------------------
Date: 6 Sep 1997 15:59:49 GMT
From: "OrdwayNet Webmaster" <ordway@iwshost.net>
Subject: A simpler perl question.
Message-Id: <01bcbadc$fdfcb5e0$1f178cd0@presario>
I have a question that I need answered-
I have a directory full of files. Lets say that I want to add something to
each one of those files. How would I do it?
I think it would be something like this, but it isn't enough-
foreach $file
print "bla bla"\n";
How do I make $file mean every file in the dir. Thanks for any help!
Email me at ordway@iwshost.net or post it on this newsgroup.
------------------------------
Date: 8 Sep 1997 22:00:48 GMT
From: "Michael A. Watson" <fishrman@shell.wco.com>
Subject: Re: Beginner's question : Perl or Java ?
Message-Id: <5v1sig$j8u$1@news.wco.com>
Bart Lateur <bart.mediamind@tornado.be> wrote:
> I don't know if this is an important question. But you seem to be
> unaware of a very important distinction between Perl and Java:
> * Perl runs on the web server
> * Java runs on the client's computer
JAVA's main advantage is that you can create an application that runs on
multi platforms. this includes a web server. You statement is inaccurate.
You seem to refering to the JAVA script that is embedded in HTML files,
and not a JAVA application.
------------------------------
Date: Mon, 08 Sep 1997 22:52:16 GMT
From: over@the.net (dave)
Subject: Re: Beginner's question : Perl or Java ?
Message-Id: <3414804f.2709834@news.one.net>
comdog@computerdog.com (brian d foy) wrote:
>In article <3416fa6a.2078526@news.tornado.be>, bart.mediamind@tornado.be (Bart Lateur) wrote:
>
>>roy@unice.fr wrote:
>>
>>[program specifications snipped]
>>
>>>Is the Perl program *much* simpler than the corresponding Java one, or are they
>>>about the same size ?
>>
>>I don't know if this is an important question.
>
>sure it's an important question, especaiily for the task he mentioned. Perl
>wins out for rapid development in this case.
>
>>But you seem to be
>>unaware of a very important distinction between Perl and Java:
>>
>> * Perl runs on the web server
>> * Java runs on the client's computer
>
>Java might run on the client's computer as an applet, but that is not a
>requirement. Java is a lot more than just applets.
I don't keep a very close eye on this stuff, but I did catch an
article in BYTE about Java Server and Java Servlets. Claimed servlets
are much more efficient on NT as threaded tasks than are forked perl
scripts. I went to Java Server page and saw it available for both
Solaris and NT. Does anyone in this group have any experience or
opinions on this or how soon, if ever, it might show up at NT and/or
Linux ISP's?
Dave
|
| Please visit me at http://w3.one.net/~dlripber
|
| For reply by email, use:
| dlripber@one.net
|________
------------------------------
Date: Mon, 08 Sep 1997 17:35:50 -0500
From: Brett Denner <Brett.W.Denner@lmtas.lmco.com>
Subject: Better regex answer to FMTEYEWTK question "Is it a number?"
Message-Id: <34147DC6.167E@lmtas.lmco.com>
I've been trying to match strings which contain numbers which may or may
not
be separated by commas:
, 10 20.5, -30.35e+02, ,
When I tried using a regex of the form:
/^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/
(from the FMTEYEWTK series) to handle the numeric parts, I got a regex
error message. Here's what I tried:
$_ = ' , 10 20.5, -30.35e+02, ,';
print "good\n" if
m/([+-]? (?=\d|\.\d) \d* (\.\d*)? ([Ee] [+-]? \d+)? \s*
(,\s*)*)+/x;
^^^^^^^^^^^^^^^^^^^^^^^^
and the message was:
/([+-]? (?=\d|\.\d) \d* (\.\d*)? ([Ee] [+-]? \d+)? \s* (,\s*)*
)+/: \
regexp *+ operand could be empty (...)
If I change the match part to:
print "good\n" if
m/([+-]? (\d+(\.\d*)? | \.\d+) ([Ee] [+-]? \d+)? \s* (,\s*)*
)+/x;
^^^^^^^^^^^^^^^^^^^^^
my script worked. It seems that (?=\d|\.\d) portion in the first
attempt causes (or fails to prevent) the above regex error message.
This may or may not be a bug in the regex compiler; I'm not sure. If
it's
not, then a better way to match numbers with a regex would be
m/^[+-]?(\d+(\.\d*)?|\.\d+)([Ee][+-]?\d+)?$/;
which differs from the regex in the FMTEYEWTK series.
Brett
P.S. By the way, the idea for the "better" (possibly) regex comes from
"Mastering Regular Expressions".
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Brett W. Denner Lockheed Martin TAS
Brett.W.Denner@lmtas.lmco.com P.O. Box
748
(817) 935-1144 (voice) Fort Worth, TX 76101
(817) 935-1212 (fax) MZ 9333
------------------------------
Date: Mon, 8 Sep 1997 15:29:58 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: dellis@frycomm.com
Subject: Re: cannot create file within while loop
Message-Id: <Pine.GSO.3.96.970908152435.1108J-100000@julie.teleport.com>
On Mon, 8 Sep 1997 dellis@frycomm.com wrote:
> open(MF,"$opt_m");
Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check of the return value of open. But I know
that's not the problem here. Or is it? :-)
> while (<MF>) {
...
> open(OF,">/tmp/dclause.tmp") or die "Cannot open output
> /tmp/dclause.tmp: $!\n";
> }
Now, you know that you're overwriting that file each time through the
loop, right? Is the problem that it's not created, or that it's empty? If
it's empty, the I don't see what the problem is. :-)
Good luck!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Mon, 8 Sep 1997 16:38:32 -0700
From: "Peter Tiemann" <peter@preview.org>
Subject: DNS lookup with gethostbyaddr?
Message-Id: <5v223u$ebt$1@ha1.rdc1.sdca.home.com>
My webserver's logfile only tells me the IP address of visitors - I'd like
to see where they are from.
I guess, I need to do a reverse DNS lookup. Right?
At first, I tried a piece of code like this:
----------
print "Content-type: text/html\n\n";
print "<html>\n <head>\n <title>GET</title>\n </head>\n";
print "<BODY>Start:<BR>\n";
$paddr = "207.36.32.122";
($a, $b, $c, $d) = split(/\./, $paddr);
$address = pack('C4', $a, $b, $c, $d);
($nam, $alias, $addrtype, $leng, @add) = gethostbyaddr($address, AF_INET);
print "$nam,$alias,$addrtype,$leng\n";
print "<BR>End</BODY>";
----------
In 95% of my cases, the result strings are empty. What's wrong with the
script?
Is gethostaddr the right function for this?
Thanks for your help,
Peter
peter@preview.org
P.S.:
I cannot install complex modules since I use a virtual webserver where I do
not have the possibility to run makefiles etc.
------------------------------
Date: Mon, 8 Sep 1997 15:13:44 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: Free Perl Docs (was: Re: (no subject) )
Message-Id: <Pine.GSO.3.96.970908151123.1108I-100000@julie.teleport.com>
On Mon, 8 Sep 1997, Cameron Dorey wrote:
> [Part 1, Text/HTML 19 lines]
> [Cannot display this part. Press "V" then "S" to save in a file]
I cannot agree or disagree with your comments, but I find your means of
expression to be quite disagreeable. :-) If you have something to say,
please change to type text/plain and post again. Thanks!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Mon, 08 Sep 1997 21:02:10 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Getting rid of \n in textarea input
Message-Id: <comdog-ya02408000R0809972102100001@news.panix.com>
In article <comdog-ya02408000R0809971302210001@news.panix.com>, comdog@computerdog.com (brian d foy) wrote:
>and then find out is only removes trailing $INPUT_SEPARATOR characters
it's $INPUT_RECORD_SEPARATOR. had you read English.pm you would have
known that and not realize on the subway home that you typed the
wrong thing :)
--
brian d foy <comdog@computerdog.com>
------------------------------
Date: Tue, 09 Sep 1997 00:16:55 +0100
From: Phil Carmody <pc1@scigen.co.uk>
Subject: Re: Getting rid of ] and [ in perl
Message-Id: <34148767.6807@scigen.co.uk>
> Matt Weber wrote:
> > How do I get rid of these two charectors in perl: []
Mark Tripod wrote:
> the right and left brackets are special characters in pattern matching,
> therefore if you want to match those characters specifically you have to
> escape them.
>
> Try:
> $value =~ s/(\[|\])//g;
Isn't ] non-special immediately after a [?
Aren't special characters in places where they can't be special
non-special?
so
$value =~ s/[][]//g;
uses a character class consisting of ] and [.
Or is it late in the evening, and I'm braindead. (v. possible)
Phil
--
\|/ ____ \|/ int c,a,x,y;main(){for(;a<2000;c Phil Carmody,
@~/ ** \~@ %=80)printf("%c"," .:lU@\nPhil"[ Consultant,
/_( \_ / )_\ x=a%80-40,y=a/80-13,c+=(x=400-x* Scientific Generics,
\__U_/ x-y*y*4)>0?x:0,a++%80?c/80:6]);} Cambridge, UK
------------------------------
Date: Mon, 08 Sep 1997 20:33:48 -0400
From: js <jscott@pixelny.com>
Subject: HELP! subroutine is making me cry!
Message-Id: <3414996C.7DF1@pixelny.com>
Hello -
I am writing a script which sends images via sendmail on user (form)
input. Everything works beautifully. However I must do some simple
logging of how many of each image the user chooses to send. I'm using a
simple sub which opens and increments a file. The subroutine works
perfectly when called alone - but will not open and write to the file
AFTER sending the image - it is just ignored.
Question:
is there something I must flush after closing my mail program? - in
order to open and write to the count.txt file?
I have my successfull redirect in the mail subroutine and it's seemless
- but appending my <&count_this;> call seems to be ignored.
I've tried everything I can think of - now I will be fired and homeless
unless one of you super-heros assists!
relevant code available upon request - no suggestion to silly.
thank you - I love you!
jenifer west
P I X E L, Inc.
http://www.pixelny.com
------------------------------
Date: Mon, 8 Sep 1997 15:06:56 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Fil Krohnengold <fil@amnh.org>
Subject: Re: how to make passwd.pl secure?
Message-Id: <Pine.GSO.3.96.970908145903.1108H-100000@julie.teleport.com>
On 7 Sep 1997, Fil Krohnengold wrote:
> Subject: how to make passwd.pl secure?
> Me again with this chunk from the passwd.pl available from CPAN
> under scripts/nutshell/ch6/.
> eval $foo; # Note: this defines sub badpats
> Okay, so here's a subroutine being refined at runtime. Here are my
> questions:
>
> 1) Why is it necessary to do this? Why not just push the words in the
> $BADPATS file into the same array with /usr/dict/words for checking?
The regexps need to be compiled; it's more efficient to compile each one
once rather than every time through the loop.
> 2) If it is necessay, how can I do this and make it secure enough for
> setuid?
You need taint checking, and that's hare to retrofit. Think of it as a
house built out of radioactive bricks: It's best to rebuild the whole
thing. The only real way to make a script like that secure is to,
essentially, rewrite the whole thing with 'use strict', -T and -w. A lot
of work, of course, but worth it for security.
The other day, I posted a way to use a sub to compile a regexp; you could
use that method to make the above eval unnecessary (while using a safer
one instead).
Good luck!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Mon, 08 Sep 1997 17:34:20 -0500
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: Incredibly basic Newbie question
Message-Id: <34147D6B.B5BC7315@mail.uca.edu>
This is a copy of my last message, since it apparently did not come over
correctly. :^(
Fred wrote:
> I'm just beginning to look at perl. I bought a book which helped
> (although it's a bit over my head for now), and all I'm trying to do
> is
> run a sample perl program under Windows95. Is this possible?
> Unfortunately, the book doesn't mention something this simple.
>
> I'm starting with the most basic Hello World program:
>
> #!/usr/local/bin/perl
> #
> # Program to do the obvious
> #
> print 'Hello world.';
>
> and I simply want to see it do something before I move on to more
> difficult tasks. My problem is that I have no idea how to run the
> damn
> thing (under Windows95). I typed it as text with Notepad, then
> changed
> the filetype to .prl but when I try to run it via the Start/Run
> function of Windows95, it simply opens it as a text file. Do I have to
>
> go to the MS.DOS window? What exact steps do I have to take to run it?
>
>
>From one newbie to another (although I've gotten a little bit farther
than you have so far), hit this webpage:
http://hjs.geol.uib.no/Perl/index6.html-ssi . This will get you up and
running right now. I would suggest you have Gurusamy's port (5.004.02
bindist 04), since it works well for me in Win95 (Thank you, thank you,
thank you Gurusamy).
I think this might be the second testimonial of Perl5 working well
in Win95, somebody a couple of days ago said he/she had not heard of
anyone having any luck with it.
> Can it be run on a p.c. or does it need to be uploaded first to a UNIX
>
> system?
>
(1) Yes. (2) No.
> If it can be run from a p.c., do I need to compile it first, or is
> that
> part of the run fuction? Do I need a program/compiler that is not part
>
> of the general Windows95 system (and if so, which one, and how do I
> install it?)
>
Perl is an interpreted language, no compiler necessary.
> (Can someone point me to a tutorial or book which covers such
> elementary
> basics?)
See above. There are other tutorials all over the web.
http://www.cgi-resources.com/ leads you to several of them. Also, BTW,
which book did you buy? The one that Mark mentioned in his post is being
shipped (according to ORA) but no copies have hit any of the bookstores
around here yet.
Cameron Dorey
camerond@mail.uca.edu
------------------------------
Date: Mon, 08 Sep 1997 17:37:18 -0700
From: jason@redfish.xo.com (Jason Proctor)
Subject: Loadable C++ modules
Message-Id: <jason-0809971737180001@ws2.redfish.xo.com>
Hello everyone,
We're doing mixed Perl/C++ development and we're having problems with
static objects. Basically the Perl runtime doesn't call the any of the
startup routines which call static constructors and destructors etc, so
we're having to make our static objects singletons and jump through hoops
to get them destructed at the right time.
Is there a "fix" for this (maybe a C++ aware module loader for Perl?) or
does anyone have a cool way of doing this?
Thanks in advance.
Jason
------------------------------
Date: 8 Sep 1997 23:20:34 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Minimizing Memory Needed for Numbers Read from Binary Files
Message-Id: <5v2182$j3r@agate.berkeley.edu>
In article <34140DDF.41C6@lmtas.lmco.com>,
Brett Denner <Brett.W.Denner@lmtas.lmco.com> wrote:
> I ran a simple test script using four different methods of "loading"
> the @array list mentioned above. The script looks like this:
>
> -------------
> open(FH, "< file.bin") or die "Error opening file\n"; # Hi, Tom! ;-)
>
> $PI = 4 * atan2(1,1);
> $string = pack "f", $PI;
> @array;
>
> for ($j=0; $j < 2000; $j++)
> {
> for ($i=0; $i < 2000; $i++)
> {
> # method of loading array (see below)
> }
> }
a) You did not preallocate the arrays, so they grow on demand, leaving
a "trace" behind. This should not take more than 2000 extra words,
though.
> $array[$j][$i] = '3.1415927'; # 234 Mb
> $array[$j][$i] = 1; # 80 Mb
> $array[$j][$i] = $PI; # 184 Mb
> $array[$j][$i] = unpack "f", $string; # 96 Mb
Doing it here with a 400x200 array gives
'3.1415927' => 3.37M # scaled 270M
1 => 1.76M # scaled 88M
3.1415927 => 2.09M # scaled 104M
unpack 'f', "\332\cOI\@" => 2.09M # scaled 104M
Let us count: 2000 arrays of length 2000, approx 4M words. 4M perl
variables, 12M words.
Integers: 4M words, total 20M words => 80M. Perl OK.
Floats: 8M words, total 24M words => 96M. Perl OK.
Strings: 4M pointers + 4M 3-words => 128M. Perl could be better.
I cannot reproduce your $PI bad results, probably you need to upgrade.
And it looks like my malloc() is worse than yours (or statistics with
PERL_DEBUG_MSTATS=2 is buggy). Need to investigate this.
I *think* I fixed bad parsing of 'blah' (into a bigger structure than
strictly required, so your '3.1415927' example would take 128M), but I
need to investigate it too.
Ilya
------------------------------
Date: 8 Sep 1997 22:19:10 GMT
From: gabor@vinyl.quickweb.com (Gabor Egressy)
Subject: Re: Numeric sorting
Message-Id: <5v1tku$8jn$1@flint.sentex.net>
Trevor Chambers (chambers_t@svhdev.bt.co.uk) wrote:
: I have a file along the lines of
: name1 1
: name2 31
: name3 7
: name4 2
: etc, and I want to sort it into descending numerical order....but I'm
: stuck. I presently read the file in to an associative array, and then
: tried to sort by the values, but couldn't make it work.
open FILE, "file" or die "$!";
while(defined ($_ = <FILE>)) {
($name,$num) = $_ =~ /(\w+)\s(\d+)/;
$names{$name} = $num;
}
close FILE;
@names = sort {$names{$b} <=> $names{$a}} keys %names;
Is this what you want?
------------------------------
Date: Tue, 09 Sep 1997 00:48:31 +0200
From: "C.Megens" <c.megens@imn.nl>
To: hi@univ-perp.fr
Subject: Re: Passing varaibles or parameters from perl to javascript module ?
Message-Id: <341480BF.46B4@imn.nl>
Henri Irla wrote:
> =
> HI,
> I vould pass variable or parameters from CGI perl program to javascrip=
t module.
> CGI perl module create dynamicaly html page with data information .
> there is javascrip module in this dynamic jtml page created . how can u=
se parameters or variable from perl program to javascrip module ?
> =
> any help would be apreciate .
> please can send you Email
> =
> ---
> =
> Best regards from sunny Pyrenees near the Mediterannee sea ...
> =
> Henri.
> =
> -------------------------------------------------------
> Henri Irla Email : hi@univ-perp.fr - henri@eva.univ-perp=
=2Efr
> Ing=E9nieur - Consultant
> Syst=E8mes & Traitement de L'information
> Chemin du Mas de L'arbre
> 66350 Toulouges - France http://gala.univ-perp.fr/~hi
> --------------------------------------------------------
Use a form (can all have hidden fields, created by your perl CGI using
the variables and/or parameters given)
and use javascript's form object to retrieve information from
the (preferably named) form.
Go to http://www.javagoodies.com for examples.
There are more out there, but this one sprang to mind...
Hope this helps,
Carry Megens
------------------------------
Date: Mon, 08 Sep 1997 17:56:09 -0400
From: Ajay Manuja <amanuja@baynetworks.com>
Subject: Perl interpreters...I18n???
Message-Id: <34147478.41C67EA6@baynetworks.com>
------------- Begin Forwarded Message -------------
Hello,
I am trying to figure out whether the Perl interpreters are
I18n or not. I am supposed to run it on a Japanese machine.
Is the code same for japanese version?
Thanks
Rekha
------------------------------
Date: 8 Sep 1997 23:28:36 GMT
From: smcdow@arlut.utexas.edu (Stuart McDow)
Subject: problems building 5.004_01 on HP-UXB.09.00
Message-Id: <5v21n4$kfb@ns1.arlut.utexas.edu>
I'm trying to build 5.004_01 on a
`uname -a` = HP-UX foo B.09.00 A 9000/382 xxxxxxxxxxxx two-user license
Everything went OK except for a couple of things:
I had to remove '#line' directives from generated c files in the ext
directories to get them to compile. Since I had no perl available, I
had to use sed. I can barely contain my shame.
The compiler (not gcc) was complaining about NULLs in the input
file. Removing the '#line' lines fixed it. Probably a compiler
problem.
I'm getting this error when the POSIX module is being built:
Making POSIX (dynamic)
LD_RUN_PATH="/lib" ld -o ../../lib/auto/POSIX/POSIX.sl -b -L/usr/local/lib POSIX.o -lm
ld: supplemental symbol table required for module /lib/libm.a
ld: (Warning) did not generate an output file
*** Error code 1
This one is the show-stopper.
HP-UX is not my forte (Solaris is, for better or worse). Does anyone
know whats going on here? Any help would be appreciated. Upgrading to
a more recent version of HP-UX is not an option.
Thanks.
--
Stuart McDow Applied Research Laboratories
smcdow@arlut.utexas.edu The University of Texas at Austin
------------------------------
Date: Mon, 08 Sep 1997 17:36:40 -0600
From: Geoffrey Leach <geoffrey@iname.com>
Subject: Q: HOWTO - Manifest Constants
Message-Id: <873757688.670@dejanews.com>
Call me a throwback, but "$TRUE" bothers me. It used to be that the
following was the reccomended way of having a manifest constant,
but this seems not to work anymore. Any suggestions, short of
creating an extension? Version is 5.004
cat t.pl
#!/usr/local/bin/perl
eval 'sub TEST_BARE {1}';
printf("TEST_BARE says: %d\n", TEST_BARE);
printf("TEST_BARE() says: %d\n", TEST_BARE());
$t.pl
TEST_BARE says: 0
TEST_BARE() says: 1
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: 8 Sep 1997 16:32:50 -0700
From: mcravit@best.com (Matthew Cravit)
Subject: Re: Q: HOWTO - Manifest Constants
Message-Id: <5v21v2$mel$1@shell3.ba.best.com>
In article <873757688.670@dejanews.com>,
Geoffrey Leach <geoffrey@iname.com> wrote:
>eval 'sub TEST_BARE {1}';
I'm not sure quite why youhave the eval around that sub. Why not just say,
sub TEST_BARE { 1; }
printf("TEST_BARE says: %d\n", TEST_BARE);
printf("TEST_BARE() says: %d\n", TEST_BARE());
which reports the following:
TEST_BARE says: 1
TEST_BARE() says: 1
(Tested under Perl 5.004 on a Solaris 2.5.1 box)
/MC
--
Matthew Cravit, N9VWG | Experience is what allows you to
E-mail: mcravit@best.com (home) | recognize a mistake the second
mcravit@taos.com (work) | time you make it.
------------------------------
Date: 08 Sep 1997 22:24:36 GMT
From: orwant@fahrenheit-451.media.mit.edu (Jon Orwant)
To: dsiebert@gate.net (David Siebert)
Subject: Re: regex problems
Message-Id: <ORWANT.97Sep8182436@fahrenheit-451.media.mit.edu>
dsiebert@gate.net (David Siebert) writes:
how can a replace any amount of whitespace follwed by a ; with just a ;.
$your_string =~ s/\s+;/;/;
-Jon
----------------
Jon Orwant
The Perl Journal
http://tpj.com/
------------------------------
Date: 8 Sep 1997 22:25:56 GMT
From: gabor@vinyl.quickweb.com (Gabor Egressy)
Subject: Re: Regexp a Yes or No question?
Message-Id: <5v1u1k$8jn$2@flint.sentex.net>
Matthew Cravit (mcravit@best.com) wrote:
: In article <341425BA.38BB@nortel.ca>,
: Sylvain St.Germain <sgermain@nortel.ca> wrote:
: >How do you regexp the answer to
: >a yes or no question?
: >
: >I mean Y, y, yes, Yes, YES, YEs, yES,
: >OK, ok, Ok, oK, true, TRUE ...
: >
: >and
: >
: >No, no, No, nO....
: I usually use something like this:
: # Assumes the user's response is in $response
: if ($response =~ /^[YyTtOo]/) {
what if the user types 'yellow'
should that be accepted?
: &DoWhatever;
: }
: else {
: &DoSomethingElse;
: }
--
And don't tell me there isn't one bit of difference between null and space,
because that's exactly how much difference there is. :-)
--Larry Wall in <10209@jpl-devvax.JPL.NASA.GOV>
Check out this site about the persecution of Randal Schwartz by Intel
http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 8 Sep 1997 16:28:21 -0700
From: mcravit@best.com (Matthew Cravit)
Subject: Re: Regexp a Yes or No question?
Message-Id: <5v21ml$l7a$1@shell3.ba.best.com>
In article <5v1u1k$8jn$2@flint.sentex.net>,
Gabor Egressy <gabor@vinyl.quickweb.com> wrote:
>: if ($response =~ /^[YyTtOo]/) {
>
>what if the user types 'yellow'
>should that be accepted?
As far as I'm concerned, if my program asks the user
Do you want to frobnicate the data (yes/no)?
and the user types "yellow", then s/he deserves what s/he gets. :)
Seriously, though, if you're really concerned about the user typing
random text in response to a yes/no prompt, it's probably better to
say
while ($response !~ /^yes/i) {
print "Your response was not understood.\n";
print "Please answer yes or no.\n";
}
if ($response =~ /^yes$/i) {
&DoSomething;
else {
&DoSomethingElse;
}
I usually take the approach I said earlier, because it's easier and I
can generally trust the people who run my scripts to provide a semi-sensible
answer to prompts. In cases where one is really paranoid, one could use
the Tk module, and provide a drop-down list with only the desired
choices on it.
*shrug*
It all depends how much intelligence you assume on the part of your users.
/MC
--
Matthew Cravit, N9VWG | Experience is what allows you to
E-mail: mcravit@best.com (home) | recognize a mistake the second
mcravit@taos.com (work) | time you make it.
------------------------------
Date: Tue, 09 Sep 1997 00:25:14 GMT
From: fallrivr@kayhay.com (Greg Miller)
Subject: Trying to get perl to load 2 files from the same call.
Message-Id: <3414957b.1420158@news.kayhay.com>
I'm writing a cgi script to replace a javascript routine that loads 2
files into different frames from each call.
I want to click on a link in the top frame, and load a file in the
middle frame, and the right frame from the same link. This is easy in
javascript, but apparently AOL brosers don't support javascript, so I
want to do the same thing in perl.
Is there a way to use the print "Location: http://....." to assign
the files into specified frames. ie "target = "MainFrame".
If this is not possible, is there an alternative that will do the same
thing?
TIA
Greg
------------------------------
Date: 8 Sep 1997 18:05:21 -0600
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: what has it got in its ssocketses?
Message-Id: <5v23s1$r73@flatland.dimensional.com>
"Lloyd " <_lloyd_@vwv.com> writes:
> I was wondering if anybody could help me solve this tricky beast....
> I am trying to initialise a Socket which in the end will connect to a
> listening POP3 port. (Haven't even got to the binding of the socket or the
> connecting etc...). Pretty simple stuff I thought!
I haven't used it, but there's a Net::POP3 module you might want to
check out. It's part of libnet, which you can get from the Comprehensive
Perl Archive Network (CPAN):
http://www.perl.com/CPAN/modules/by-module/Net/
> A snippet of my script (the only two lines which affect the problem that I
> can see) follows:
> --
> ($dummy1, $dummy2, $prototype) = getprotobyname("TCP");
BTW, you can do "(undef, undef, $prototype) = ..." here.
> #$prototype contains 6 now if this means anything to you
> socket(SOCKET, 2, 1, $prototype) || do {&error("Socket not
> Initialised\n$!");};
> --
> Anyway - I ran my script on a Solaris box (running perl 5.004) and then on
> another Solaris box (running perl 5.004_02) and keep running into the same
> error. [I ran the script as root and as me.]
> $! contains the text: 'Protocol not supported'. The script terminates at
> the &error routine.
Take a look at the IO::Socket module -- it makes life a little easier;
let us know if that doesn't work either.
Hope this helps!
--
Michael Fuhr
http://www.dimensional.com/~mfuhr/
------------------------------
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 998
*************************************