[11588] in Perl-Users-Digest
Perl-Users Digest, Issue: 5188 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Mar 20 23:07:20 1999
Date: Sat, 20 Mar 99 20:00:22 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 20 Mar 1999 Volume: 8 Number: 5188
Today's topics:
access to unparse command line <kk>
Apache Win98 CGI.pm problems <richly@samart.co.th>
Re: Array of Hash Problem take 2 <GLEdwards@christianfamilies.net>
Re: Array of Hash Problem <GLEdwards@christianfamilies.net>
Re: Can an unchecked checkbox input pass a different va (Abigail)
Re: Can't read a text file with weird characters in it. (Larry Rosler)
Re: CPAN (Lee)
Re: DB Variable <rick.delaney@home.com>
Environment strings <bret@bordwell.com>
Re: Finding the size of a scalar (Larry Rosler)
Form submission for football tipping <candree@one.net.au>
Re: GNUfind -mmin and find2perl. <rpsavage@ozemail.com.au>
Re: Here 's a good one !!! (David Combs)
Re: Here 's a good one !!! (brian d foy)
Re: Need help on a algorithm (Larry Rosler)
newbie - counting words <rahulk@iname.com>
Re: newbie - counting words <revjack@radix.net>
Re: newbie - counting words <gellyfish@btinternet.com>
Re: newbie - counting words <rahulk@iname.com>
Re: passwords:crypts (Martin Vorlaender)
Print to browser before end of script <super@super-mall.net>
Problems sorting arrays correctly <agjemmes@extremeonline.com>
Re: Problems sorting arrays correctly (Andrew Johnson)
Re: Problems sorting arrays correctly <agjemmes@extremeonline.com>
Re: Q: opening multiple filehandles concurrently? <rick.delaney@home.com>
Question: web-based automated queries (J Crowtz)
Re: RAD or WYSIWIG for Perl ??? <gellyfish@btinternet.com>
Re: RAD or WYSIWIG for Perl ??? (Arved Sandstrom)
Regex Question <gwilburn@home.com>
Sending to multiple recipients via Sendmail <GLEdwards@christianfamilies.net>
Re: Testing if variable contains a certain word..... (Larry Rosler)
Variable through form (help!) <dstern@aschwebhosting.com*nospam*>
Re: Variable through form (help!) <gellyfish@btinternet.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 20 Mar 1999 19:45:23 -0500
From: <kk>
Subject: access to unparse command line
Message-Id: <36f44048@news3.us.ibm.net>
Anyone know of way to access the unparsed command line arguments (something
instead of @ARGV)?
David zADE
dzade@ibm.net
------------------------------
Date: Sun, 21 Mar 1999 08:08:42 +0700
From: "Robert White" <richly@samart.co.th>
Subject: Apache Win98 CGI.pm problems
Message-Id: <7d1gts$a4j$1@chatta.samart.co.th>
No cookies, for one thing.
No SSI for another.
I have 3 different virtual domains going with various Options set
in a standalone setup and it won't go.
.pl and .cgi scripts run ok.
Have run out of clues :-((
Robert Just another perl hacker in the Bangkok
http://members.xoom.com/robertmwhite/
------------------------------
Date: Sat, 20 Mar 1999 21:47:41 -0600
From: "Glen Lee Edwards" <GLEdwards@christianfamilies.net>
Subject: Re: Array of Hash Problem take 2
Message-Id: <7d1psh$9pu1@iac7.navix.net>
Jens,
Let's try again.
#Here's the store program program:
%sites = (link=>'www.programmersparadise.com',title=>'How to use
Perl',publisher=>'Sams Publishing',);
#Now I am saving it to a file.
open (DATEI, ">f:\\sites.dat");
foreach $key (keys %sites) {
#Note the addition of the comma and \n
print DATEI "$key, $sites{$key}\n";
}
close DATEI;
This is what the sites.dat file looks like after the above is run:
title, How to use Perl
publisher, Sams Publishing
link, www.programmersparadise.com
#Let's recall the data
open (DATEI, "<f:\\sites.dat") || die("can't open sites.dat file");
@input = <DATEI>;
close DATEI;
#And we'll turn the array into a hash:
foreach $input(@input) {
#Now lets create the key value pairs
#This is why we needed the comma
($key,$value)=split(/\,/, $input);
#Now we'll assign the hash a name:
$sites{$key}=$value;
#Lets see if it worked:
#Note that we're still in the foreach loop
print "Key is: $key \nValue is: $value\n";
}
#And now we'll see what the hash itself looks like:
print "This is the sites hash:\n";
print %sites;
print "\n\n";
Jens,
You can't use brackets to create a hash. This turns the hash into a
reference. You need to use parenthesis instead. When you store a hash as a
file it looses it's formatting. Consequently you need to store it in a form
that is easy to maneuver around, and that can easily be recalled and
restored into hash form. If you'll note, in this routine I stored the hash
as an array, separating the key from the value with a comma. On recalling
the data the hash was recreated by creating key value pairs from each
element of the array, and assigning these value pares to the hash %sites.
Hope this helps.
Glen
Jens Engelbrecht wrote in message <36F217A3.C7B64DB7@dachs.de>...
>Hello,
>
>I hope someone can help me with that problem.
>I have created an array of a hash.
>
>$sites = [{"link" => "www.programmersparadise.com", "titel"=>"How to
>use Perl"},{...}];
>
>#Now I am saving it to a file.
>
>open (DATEI, ">f:\\sites.dat");
>print DATEI @sites;
>close DATEI;
>
>OK so far;
>In another sub I am trying to read it now.
>
>sub headlines {
> open (DATEI, "<f:\\sites.dat");
> @sites = <DATEI>;
> close DATEI;
> print @sites; #gives me something like "HASH(0x0d234)
>
>..."
> print $sites[0]{"link"}; #gives me an error
>}
>
>What have I missed ?
>Thanks for helping
>
>Jens Engelbrecht
>
>--
>Dachs - Das Bvrsenmagazin
>www.dachs.de
>
>
------------------------------
Date: Sat, 20 Mar 1999 21:12:18 -0600
From: "Glen Lee Edwards" <GLEdwards@christianfamilies.net>
Subject: Re: Array of Hash Problem
Message-Id: <7d1nqf$8i01@iac7.navix.net>
Jens,
Try the following. Some comments follow.
+ACU-sites +AD0- (link+AD0APg-'www.programmersparadise.com',title+AD0APg-'How to use
Perl',publisher+AD0APg-'Sams Publishing',)+ADs-
+ACM-note the use of () instead of +AHsAfQ- or +AFsAXQ-
+ACM-Now I am saving it to a file.
open (DATEI, +ACIAPg-f:+AFwAXA-sites.dat+ACI-)+ADs-
foreach +ACQ-key (keys +ACU-sites) +AHs-
print DATEI +ACIAJA-key, +ACQ-sites+AHsAJA-key+AH0AXA-n+ACIAOw-
+ACM-note the addition of the comma and the +AFw-n
+AH0-
close DATEI+ADs-
This is what the sites.dat file looks like after the above is run:
title, How to use Perl
publisher, Sams Publishing
link, www.programmersparadise.com
+ACM-Recall data from file with the following:
open (DATEI, +ACIAPA-f:+AFwAXA-sites.dat+ACI-) +AHwAfA- die(+ACI-can't open sites.dat file+ACI-)+ADs-
+AEA-input +AD0- +ADw-DATEI+AD4AOw-
close DATEI+ADs-
+ACM-Now create the new hash key value pairs
foreach +ACQ-input(+AEA-input) +AHs-
(+ACQ-key,+ACQ-value)+AD0-split(/+AFw-,/, +ACQ-input)+ADs-
+ACM-Now assign the new hash a name:
+ACQ-sites+AHsAJA-key+AH0APQAk-value+ADs-
+ACM-Lets see if it worked:
print +ACI-Key is: +ACQ-key +AFw-nValue is: +ACQ-value+AFw-n+ACIAOw-
+AH0- +ACM-End create the new has routine
+ACM-And we'll view the hash itself
print +ACI-This is the sites hash:+AFw-n+ACIAOw-
print +ACU-sites+ADs-
print +ACIAXA-n+AFw-n+ACIAOw-
exit+ADs-
Jens,
You can't use brackets to create a hash. This turns the hash into a
reference. You need to use parenthesis instead. When you store a hash as a
file it looses it's formatting. Consequently you need to store it in a form
that is easy to maneuver around, and that can easily be recalled and
restored into hash form. If you'll note, in this routine I stored the hash
as an array, separating the key from the value with a comma. On recalling
the data the hash was recreated by creating key value pairs from each
element of the array, and assigning these value pares to the hash +ACU-sites.
Hope this helps.
Glen
Jens Engelbrecht wrote in message +ADw-36F217A3.C7B64DB7+AEA-dachs.de+AD4-...
+AD4-Hello,
+AD4-
+AD4-I hope someone can help me with that problem.
+AD4-I have created an array of a hash.
+AD4-
+AD4AJA-sites +AD0- +AFsAewAi-link+ACI- +AD0APg- +ACI-www.programmersparadise.com+ACI-, +ACI-titel+ACIAPQA+ACI-How to
+AD4-use Perl+ACIAfQ-,+AHs-...+AH0AXQA7-
+AD4-
+AD4AIw-Now I am saving it to a file.
+AD4-
+AD4-open (DATEI, +ACIAPg-f:+AFwAXA-sites.dat+ACI-)+ADs-
+AD4-print DATEI +AEA-sites+ADs-
+AD4-close DATEI+ADs-
+AD4-
+AD4-OK so far+ADs-
+AD4-In another sub I am trying to read it now.
+AD4-
+AD4-sub headlines +AHs-
+AD4- open (DATEI, +ACIAPA-f:+AFwAXA-sites.dat+ACI-)+ADs-
+AD4- +AEA-sites +AD0- +ADw-DATEI+AD4AOw-
+AD4- close DATEI+ADs-
+AD4- print +AEA-sites+ADs- +ACM-gives me something like +ACI-HASH(0x0d234)
+AD4-
+AD4-...+ACI-
+AD4- print +ACQ-sites+AFs-0+AF0AewAi-link+ACIAfQA7- +ACM-gives me an error
+AD4AfQ-
+AD4-
+AD4-What have I missed ?
+AD4-Thanks for helping
+AD4-
+AD4-Jens Engelbrecht
+AD4-
+AD4---
+AD4-Dachs - Das B+APY-rsenmagazin
+AD4-www.dachs.de
+AD4-
+AD4-
------------------------------
Date: 21 Mar 1999 00:35:28 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Can an unchecked checkbox input pass a different value?
Message-Id: <7d1esg$eeq$1@client2.news.psi.net>
Greg (greg@nospam.com) wrote on MMXXVI September MCMXCIII in
<URL:news:Y7BI2.1687$256.15597@news20.ispnews.com>:
()
() Can un unchecked checkbox input still pass a value (i.e. it passes a value
() if checked, but can it pass a different value if unchecked)? Perhaps I need
() to be looking to javascript to do this?
There are no checkboxes in Perl.
Goodbye.
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
------------------------------
Date: Fri, 19 Mar 1999 12:15:32 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Can't read a text file with weird characters in it. Help.
Message-Id: <MPG.115c503c586695989789@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <7ctv4s$cd3$1@magnum.mmm.com> on Fri, 19 Mar 1999 10:48:27 -
0600, Jason Stanley <jstanley@mmm.com> says...
> I am trying to read through the text file below, but when it hits the odd
> (ascii?) characters it won't read the rest of the file.
perldoc -f binmode
It sounds as though you are using a Windows/DOS system and running into
a "\cZ" character, which it interprets as end-of-file.
> How do I get it to
> ignore all the strange characters and read all the words.
Define what you think are 'strange' characters, and filter them out.
tr/[\x00-\x17][\x7F-\xFF]//d;
(for example). perldoc -f tr.
> = H J K S $ p v a q& t 4 A The file was
> repaired.u M The file
> F:\Tsd\Tsdusers\US275612\MSOFFICE\WINWORD\Volition\~WRL2838.TMP
Only one or two lines (or even none) of this would have been plenty!
--
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 20 Mar 1999 17:27:12 -0600
From: rlb@intrinsix.ca (Lee)
Subject: Re: CPAN
Message-Id: <B3198AF0966838930@204.112.166.88>
In article <m1ww0caxbo.fsf@halfdome.holdit.com>,
merlyn@stonehenge.com (Randal L. Schwartz) wrote:
>Jonathan> Why would you *want* all of CPAN in one large file ? There
>Jonathan> are literally thousands of files and many of these are
>Jonathan> various revisions of the same Modules. The tar file of the
>Jonathan> entire contents of CPAN would certainly be in the tens of
>Jonathan> Megabytes if not more.
>
>I just checked -- today's CPAN is 742 megs, and it's not likely to
>compress much since nearly everything in it is already a .tar.gz.
To actually answer the question, though (a revolutionary concept for this
ng, I know) a complete (but out of date, of course) CPAN is included on CD
with O'Reilly's "Perl Resource Kit".
Lee
------------------------------
Date: Sat, 20 Mar 1999 22:44:56 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: DB Variable
Message-Id: <36F426E2.B8E45380@home.com>
[posted & mailed]
Gavin wrote:
>
> tie (%db, 'MLDBM', $dbfile, O_CREAT|O_RDWR, 0666 || die $!);
^^^^^^^^^^^^^^
That can't be right. It will only die if the 5th parameter is false,
which 0666 never is.
tie (%db, 'MLDBM', $dbfile, O_CREAT|O_RDWR, 0666) || die $!;
or
tie %db, 'MLDBM', $dbfile, O_CREAT|O_RDWR, 0666 or die $!;
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Sat, 20 Mar 1999 20:42:26 -0500
From: Bret Bordwell <bret@bordwell.com>
Subject: Environment strings
Message-Id: <36F44E82.25CC@bordwell.com>
This is a re-post, in hopes to get an answer....
Hello world!
Does anyone know of problems with the environment strings being kept
and re-used after the process has finished running?
I know, that sounds real cryptic... here's my problem:
I'm writing an E-Mail game using HTML with two list selects, and a
submit btn.
After parsing the form, and getting the 'post'ed vars, everything goes
smoothly.
Subsequent plays made one after the other (I'm playing the game with
myself), appears
to use the previous 'post'ed strings, ignoring what was actually passed
in.
Assuming it's not my code, then the only logical thing left is what was
described above.
Any help?
By the way, you can play a crude but semi-working version at:
http://www.bordwell.com/sevenhtml ----> (has rules to the game, etc)
you may also play what is in development and clearly shows this problem
at:
http//:www.bordwell.com/sevenhtml/aformdev.html
Thank you for your time, in advance.
------------------------------
Date: Fri, 19 Mar 1999 12:18:54 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Finding the size of a scalar
Message-Id: <MPG.115c5104467ed8fe98978a@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <36F284FC.EB758D2E@worldnet.att.net> on 19 Mar 1999 17:06:04
GMT, Frank Hale <frankhale@worldnet.att.net> says...
> Say I want to have a scalar that stores a string and I don't want it to
> be larger than 256kb how can I get the size of it to test for this?
perldoc -f length
And then read
perldoc -f substr
to see how to clip it to the size you want.
--
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sun, 21 Mar 1999 12:44:31 +1000
From: "chris" <candree@one.net.au>
Subject: Form submission for football tipping
Message-Id: <36f45e41.0@pink.one.net.au>
Hi everyone.
Recently I had the great idea to start an on-line football tipping
competition with a few friends. My friends can log on to the page, pick the
teams that they think are going to win on the weekend, and then submit the
form. Once all forms have been submitted, I would like to view a report of
a) who has submitted a form and b) what teams they picked to win?
For example the form could have a check box beside each team:
Essendon vs Carlton *
Geelong vs North Melbourne* (* = a ticked check box)
Melbourne* vs Richmond
Brisbane* vs St Kilda
So after I have submitted the above form a report would be generated stating
that I had picked Carlton, North Melbourne, Melbourne and Brisbane to win.
The finished report would contain all names of people who submitted a form
and the teams that they picked to win.
As I am a complete newbie to CGI scripts and Perl can anyone explain to me
how a cgi script would process this information and present it as a report?
Can anyone suggest an algorithm that would help me process the submitted
form? (any code would be greatly appreciated!!!!)
Also can anyone suggest a good book for learning how to code CGI scripts?
Thankyou in advance.
Chris Andre
------------------------------
Date: Sun, 21 Mar 1999 13:14:50 +1100
From: "Pen and Ron Savage" <rpsavage@ozemail.com.au>
Subject: Re: GNUfind -mmin and find2perl.
Message-Id: <7d1kql$82q$1@reader1.reader.news.ozemail.net>
On this site:
http://www.generation.net/~cybersky/Perl/perlmod.htm
you'll find INotify.
--
Cheers
Pen and Ron Savage
rpsavage@ozemail.com.au
http://www.ozemail.com.au/~rpsavage
milburn@ltpmail.gsfc.nasa.gov wrote in message
<7ctvj4$6cf$1@nnrp1.dejanews.com>...
>I'm trying to write a perl script that will monitor a directory and
>notify me when new files arrive by checking the directory every 5 minutes.
>I'd like to use GNUfind because it has the "amin,cmin,mmin" flags to tell
>you the file status within N minutes ago. I don't want to process the
>file if it's still being ftp'd.
>
>Is there a way to modify find2perl to handle "-mmin" or does anyone
>know of another method I could use to accomplish this.
>
>thanks,
>-shane
>
>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Sat, 20 Mar 1999 21:23:59 GMT
From: dkcombs@netcom.com (David Combs)
Subject: Re: Here 's a good one !!!
Message-Id: <dkcombsF8wwrz.10o@netcom.com>
run via script:
script t.script
run perl ...
exit
EVERYTHING that went to the screen is in t.script.
------------------------------
Date: Sat, 20 Mar 1999 18:37:40 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Here 's a good one !!!
Message-Id: <comdog-ya02408000R2003991837400001@news.panix.com>
> >In article <comdog-ya02408000R1403991724100001@news.panix.com> on Sun,
> >14 Mar 1999 17:24:10 -0500, brian d foy <comdog@computerdog.com >says...
> >> In article <7chaap$7da$1@ionews.ionet.net>, "Travis" <Travis@wildboysnet.com> posted:
> >> > when using the -w on code I often get a screen full of errors due to the
> >> > fact that I forgot an
> >> > quotation mark somewhere ( on a print statement ) . Anyone know how the
> >> > errors can be saved to a file so
> >> > you can read the first offending error ?
> >>
> >> why save it to a file?
> >>
> >> perl -cw script_name | more
> >
> >Doesn't this pipe STDOUT to 'more'? The perl diagnostics are written to
> >STDERR, which goes straight to the terminal unless redirected.
oops, Larry is right. i have a habit of opening STDERR to STDOUT in
my CGI scripts, so i forgot about this :(
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
------------------------------
Date: Fri, 19 Mar 1999 12:28:16 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Need help on a algorithm
Message-Id: <MPG.115c533f4133deae98978b@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <36F281BE.CB0AEF4@worldnet.att.net> on Fri, 19 Mar 1999
11:56:30 -0500, Frank Hale <frankhale@worldnet.att.net> says...
+ Okay I have a problem. I have a file which has records consisting of 5
+ fields like so
+
+ i:1
+ n:John Smith
+ e:me@somewhere.com
+ d:19 Mar 1999
+ s:some text here
+
+ Okay there are multiple records. I have a hash which I store the index
+ of the records to be deleted. I need to rewrite the file with only the
+ records I want to keep.
+
+ I can't figure out the algorithm to do this.
+
+ **Okay here is a summary of my problem**
+
+ I got a file with multiple records having 5 fields each
+
+ I have a hash I store the indexes that need to be deleted which looks
+ like so
+
+ Say I had 5 messages
+
+ 1=1
+ 2=1
+ 3=0
+ 4=0
+ 5=0
+
+ This means records 1 and 2 need to be deleted and I need to rewrite
+ the file so that 3,4,5 are the only records there.
+
+ Could someone offer a psuedo-code algorithm on how to do this? I would
+ greatly appreciate it.
Set the input record separator $/ to whatever string separates the
records (for example, "\n\n" if there is a blank-line separator).
Read the entire file into an array:
my @array = <FILE>;
which will then be an array of records.
Use an array slice to select the records you want to keep:
my @keep = @array[2 .. 4]; # counts from 0, remember!
or, more generally,
my @keep = @array[@indices_to_keep];
Write a new file with the arrays:
print NEWFILE @keep;
--
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 20 Mar 1999 14:38:51 -0600
From: Rahul K <rahulk@iname.com>
Subject: newbie - counting words
Message-Id: <36F4075B.51185408@iname.com>
Hi,
I have a list of words which look something like this:
cat
bat
mat
the
run
cat
mat
I want to find out the number of occurences of each word. How do I do
that?
Thanks in advance,
rahul
------------------------------
Date: 20 Mar 1999 21:34:33 GMT
From: Greensboro Blum <revjack@radix.net>
Subject: Re: newbie - counting words
Message-Id: <7d1499$au1$2@news1.Radix.Net>
Keywords: Hexapodia as the key insight
Rahul K explains it all:
:Hi,
:I have a list of words which look something like this:
:cat
:bat
:mat
:the
:run
:cat
:mat
:I want to find out the number of occurences of each word. How do I do
:that?
Maybe something like this:
for(@list_of_words){
chomp;
$COUNT{$_}++;
}
foreach $key(keys %COUNT) {
print "$key $COUNT{$key}\n";
}
--
/~\ industrialism exploit tactile depreciate occasion Pakistan plus
C oo lotus solicit stave permissive shoddy memoir mi Hurwitz depart
_( ^) 1 , 0 0 0 , 0 0 0 m o n k e y s c a n ' t b e w r o n g
/___~\ http://3509641275/~revjack 03/20/99 16:32:19 revjack@radix.net
------------------------------
Date: 20 Mar 1999 21:37:46 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: newbie - counting words
Message-Id: <7d14fb$4u0$1@gellyfish.btinternet.com>
On Sat, 20 Mar 1999 14:38:51 -0600 Rahul K wrote:
>
> Hi,
>
> I have a list of words which look something like this:
>
> cat
> bat
> mat
> the
> run
> cat
> mat
>
>
> I want to find out the number of occurences of each word. How do I do
> that?
>
Say's hash to me - assuming that you have got a file like you describe
then you might do summat like :
while(<>)
{
chomp;
$blah{$_}++;
}
foreach ( keys %blah)
{
print $_,"\t",$blah{$_},"\n";
}
Of course your data might be in a different form - then all bets are off.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Sat, 20 Mar 1999 18:37:31 -0600
From: Rahul K <rahulk@iname.com>
To: Greensboro Blum <revjack@radix.net>, Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: newbie - counting words
Message-Id: <36F43F4B.F70E5AA5@iname.com>
Thanks guys! What I want the program to do is get the value of the fourth
item in a comma delimited file, calculate the number of occurences of
those items, sort it descending order and display the first twenty values.
Here is what I came up with. It works fine but I would like your feedback
as to how to make it run faster. (the comma delimited file contains more
than 500000 entries!).
thanks in advance,
-rahul
-----------------------snip-----------------------
use Text::ParseWords;
my @new = ();
my @macham = ();
open (IN,"logger.txt")|| die "unable to open logger";
@allentries = <IN>;
foreach $entry (@allentries) {
@macham = parse_it($entry);
#ignore blank entries
if ($macham[3] ne ""){
push(@new, lc($macham[3]));
}
}
for(@new){
chomp;
$COUNT{$_}++;
}
my $k = 0;
foreach $key(sort {$COUNT{$b} <=> $COUNT{$a}} keys %COUNT){
#print only first twenty items
if (($k < 21) ){
print "$key\t$COUNT{$key}";
$k++;
}
}
close(IN);
sub parse_it {
return quotewords(",",0,$_[0]);
}
-----------------------snip-----------------------
Greensboro Blum wrote:
> Rahul K explains it all:
>
> :Hi,
>
> :I have a list of words which look something like this:
>
> :cat
> :bat
> :mat
> :the
> :run
> :cat
> :mat
>
> :I want to find out the number of occurences of each word. How do I do
> :that?
>
> Maybe something like this:
>
> for(@list_of_words){
> chomp;
> $COUNT{$_}++;
> }
> foreach $key(keys %COUNT) {
> print "$key $COUNT{$key}\n";
> }
>
> --
> /~\ industrialism exploit tactile depreciate occasion Pakistan plus
> C oo lotus solicit stave permissive shoddy memoir mi Hurwitz depart
> _( ^) 1 , 0 0 0 , 0 0 0 m o n k e y s c a n ' t b e w r o n g
> /___~\ http://3509641275/~revjack 03/20/99 16:32:19 revjack@radix.net
------------------------------
Date: Sat, 20 Mar 1999 22:12:11 +0100
From: martin@RADIOGAGA.HARZ.DE (Martin Vorlaender)
Subject: Re: passwords:crypts
Message-Id: <36f40f2b.524144494f47414741@radiogaga.harz.de>
Elly (elly139@cableinet.co.uk) wrote:
: I have a db table with usernames and crypted passwords...and then a
: webpage..which users can input their usernames and passwords...and I
: have a script which should take the password from input form and crypt
: is and compare with the password in db table using SQL statements...I
: got it input password to crypt except, its different from the one in the
: db table everytime I crypt it...I use SALT in it...but then ..that makes
: all the input passwords crypts the same..so what am I doing wrong? how
: should I crypt my db table passwords?
Choose two random characters when encrypting a password for storing.
These two character will show up again as the first two characters of
the encrypted password.
When encrypting a string to compare with the password, use the first two
characters of the encrypted password as the salt.
: please email me...thanks...
Ask here, read the answer here.
cu,
Martin
--
| Martin Vorlaender | VMS & WNT programmer
VMS is today what | work: mv@pdv-systeme.de
Microsoft wants | http://www.pdv-systeme.de/users/martinv/
Windows NT 8.0 to be! | home: martin@radiogaga.harz.de
------------------------------
Date: Sat, 20 Mar 1999 17:22:48 -1000
From: "Mike Clark" <super@super-mall.net>
Subject: Print to browser before end of script
Message-Id: <7d1ol3$6gh$1@mochi.lava.net>
I am writing a script which receives values from a form, then passes the
values to a number of command lines which execute a series of other programs
in sequence.
The whole process takes several minutes.
After the viewer submits the form, I want the script to print to browser
"thanks, please wait" or some message.
But the script waits until all the processes are finished before it prints
to browser, and the browser times out.
I have tried several combinations, at the beginning of the script:
{
print( "STDOUT "Content-Type: text/html\n\n");
print(STDOUT "thanks, please wait");
}
{
print("Content-Type: text/html\n\n");
print("thanks, please wait");
}
{
print "Content-Type: text/html\n\n";
print "thanks, please wait";
}
print "Content-Type: text/html\n\n";
print "thanks, please wait";
I have also tried putting the later commands into a subroutine.
These all work by themselves.
But when other command lines follow it, the script will not print to browser
because the browser times out.
The script does execute all the commands in sequence, however, so I know the
script is functioning properly except for this glitch.
Anybody got any answers?
Thanks
Mike Clark
super@101super.com
Tel/Fax 808 982 6463
------------------------------
Date: Sun, 21 Mar 1999 01:08:52 +0100
From: "Asbjorn Gjemmestad" <agjemmes@extremeonline.com>
Subject: Problems sorting arrays correctly
Message-Id: <hOWI2.471$r76.1749@news1.online.no>
I'm having a problem sorting array elements using the sort function.
Here is what I'm trying to do:
The array elements look like this (examples) -
30|2|4|2|dddd
50|2|4|2|bbbb
50|5|10|5|aaaa
30|3|6|3|cccc
The sorting procedure looks like this:
@sorted = sort { $a <=> $b }@acc;
@sorts = reverse(@sorted);
Now the list should look like this (in my opinion):
50|5|10|5|aaaa
50|2|4|2|bbbb
30|3|6|3|cccc
30|2|4|2|dddd
The problem is, the list is sorted like this:
50|2|4|2|bbbb
50|5|10|5|aaaa
30|3|6|3|cccc
30|2|4|2|dddd
I have come to the comclusion that if the first number is the same (50, 30
whatever)
it will be sorted alphabetically. Is this correct? Am I missing something?
The numbers are obviousley data seaparated by | that needs to be ranked
correctly.
I need everything to be sorted after the numbers (in the right order -
highest number first), and after the letters
if the numbers are all the same.
Any help, suggesions, etc. is highly apprecciated.
Thank you for bearing with my poor explanation and examples.
Asbjorn
------------------------------
Date: Sun, 21 Mar 1999 00:27:18 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: Problems sorting arrays correctly
Message-Id: <G1XI2.3905$gk3.37253@news1.rdc1.on.wave.home.com>
In article <hOWI2.471$r76.1749@news1.online.no>,
Asbjorn Gjemmestad <agjemmes@extremeonline.com> wrote:
! I'm having a problem sorting array elements using the sort function.
!
! Here is what I'm trying to do:
!
! The array elements look like this (examples) -
!
! 30|2|4|2|dddd
! 50|2|4|2|bbbb
! 50|5|10|5|aaaa
! 30|3|6|3|cccc
!
! The sorting procedure looks like this:
!
! @sorted = sort { $a <=> $b }@acc;
! @sorts = reverse(@sorted);
!
! Now the list should look like this (in my opinion):
!
! 50|5|10|5|aaaa
! 50|2|4|2|bbbb
! 30|3|6|3|cccc
! 30|2|4|2|dddd
!
perl doesn't know you want treat each of those strings as
different fields to sort upon ... you'll have to it how to
sort it yourself --- use the Schwartzian Transform that is
mention in perlfaq4: How do I an array by (anything)?, and
check out the web page listed at the bottom of that FAQ for
further information.
you didn't mention which direction you wanted the alpha sort
to take, so here I've left it normal sort order, the first
3 numeric fields are sorted highest to lowest:
#!/usr/bin/perl -w
use strict;
chomp (my @data = <DATA>);
my @sorted = map{$_->[0]}
sort { $b->[1] <=> $a->[1] ||
$b->[2] <=> $a->[2] ||
$b->[3] <=> $a->[3] ||
$a->[4] cmp $b->[4]
}
map {[$_, split /\|/]} @data;
print join("\n", @sorted);
__DATA__
30|2|4|2|dddd
50|2|4|2|bbbb
50|5|10|5|aaaa
30|3|6|3|cccc
hope it helps
regards
andrew
------------------------------
Date: Sun, 21 Mar 1999 02:22:35 +0100
From: "Asbjorn Gjemmestad" <agjemmes@extremeonline.com>
Subject: Re: Problems sorting arrays correctly
Message-Id: <JSXI2.493$r76.909@news1.online.no>
Andrew Johnson skrev i meldingen ...
>In article <hOWI2.471$r76.1749@news1.online.no>,
> Asbjorn Gjemmestad <agjemmes@extremeonline.com> wrote:
>! I'm having a problem sorting array elements using the sort function.
>!
>! Here is what I'm trying to do:
>!
>! The array elements look like this (examples) -
>!
>! 30|2|4|2|dddd
>! 50|2|4|2|bbbb
>! 50|5|10|5|aaaa
>! 30|3|6|3|cccc
>!
>! The sorting procedure looks like this:
>!
>! @sorted = sort { $a <=> $b }@acc;
>! @sorts = reverse(@sorted);
>!
>! Now the list should look like this (in my opinion):
>!
>! 50|5|10|5|aaaa
>! 50|2|4|2|bbbb
>! 30|3|6|3|cccc
>! 30|2|4|2|dddd
>!
>
>perl doesn't know you want treat each of those strings as
>different fields to sort upon ... you'll have to it how to
>sort it yourself --- use the Schwartzian Transform that is
>mention in perlfaq4: How do I an array by (anything)?, and
>check out the web page listed at the bottom of that FAQ for
>further information.
>
>you didn't mention which direction you wanted the alpha sort
>to take, so here I've left it normal sort order, the first
>3 numeric fields are sorted highest to lowest:
>
>#!/usr/bin/perl -w
>use strict;
>chomp (my @data = <DATA>);
>
>my @sorted = map{$_->[0]}
> sort { $b->[1] <=> $a->[1] ||
> $b->[2] <=> $a->[2] ||
> $b->[3] <=> $a->[3] ||
> $a->[4] cmp $b->[4]
> }
> map {[$_, split /\|/]} @data;
>
>print join("\n", @sorted);
>__DATA__
>30|2|4|2|dddd
>50|2|4|2|bbbb
>50|5|10|5|aaaa
>30|3|6|3|cccc
>
>hope it helps
>regards
>andrew
What I want it to do is simply sort everything with highest number first for
all elements, and correct alphabetically order. I though I'd done that when
sorting and reversing, but when the first numbers (the numbers before the
first |) are the same, it goes over to just plain alphabetically order.
I don't know if sounds the way I want it to, but anywayz... Any suggestions
are apprecciated.
thnx
Asbjorn
------------------------------
Date: Sat, 20 Mar 1999 22:48:21 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Q: opening multiple filehandles concurrently?
Message-Id: <36F427B0.6E1E7A3E@home.com>
[posted & mailed]
anna@water.ca.gov wrote:
>
> I want to write out a section of the report to another report while
> still writing to the original report
Check out perlfaq5, "How do I print to more than one file at once?"
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Sun, 21 Mar 99 03:42:28 GMT
From: aa522@chebucto.ns.ca (J Crowtz)
Subject: Question: web-based automated queries
Message-Id: <VRZI2.102$Zy.474413@NewsRead.Toronto.iSTAR.net>
Hello,
I'm trying to find some perl-based resources for automatically loading
webpages, entering queries within a specific input-field, executing the
query, saving the results to file, then going back to the query page and
repeating this process (over and over again). I'm wondering if anyone
knows of any scripts that currently exist to perform this kind of
operation, or at least the location of some resources where one could
learn how to solve some of the problems this operation involves
(specifying an input field and inserting a string within said field, for
example).
Thanks,
Jason Crowtz
------------------------------
Date: 20 Mar 1999 21:20:20 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: RAD or WYSIWIG for Perl ???
Message-Id: <7d13ek$4s7$1@gellyfish.btinternet.com>
On Wed, 17 Mar 1999 01:29:57 -0500 Steve Davis wrote:
>
> I want a GUI that will help me assemble the code.. there are dozens of apps
> out there to help me produce java apps but nothing for Perl which surprises
> me.
>
> I am clueless when it comes to writing perl from scratch and I think a GUI
> or RAD product for Perl is long overdue.
>
O come on Perl just doesnt work like that - there is no 'application
framework' you just have to pick up your editor and type - I had a quick
thought abought making a spoof drag and drool thing here but I got bored.
Learn perl, learn to use a good text editor, use your brain and enjoy
being a genius ...
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Sat, 20 Mar 1999 19:36:31 -0400
From: Arved_37@chebucto.ns.ca (Arved Sandstrom)
Subject: Re: RAD or WYSIWIG for Perl ???
Message-Id: <Arved_37-2003991936310001@dyip-110.chebucto.ns.ca>
In article <7d13ek$4s7$1@gellyfish.btinternet.com>, Jonathan Stowe
<gellyfish@btinternet.com> wrote:
> On Wed, 17 Mar 1999 01:29:57 -0500 Steve Davis wrote:
> >
> > I am clueless when it comes to writing perl from scratch and I think a GUI
> > or RAD product for Perl is long overdue.
>
> O come on Perl just doesnt work like that - there is no 'application
> framework' you just have to pick up your editor and type - I had a quick
> thought abought making a spoof drag and drool thing here but I got bored.
>
> Learn perl, learn to use a good text editor, use your brain and enjoy
> being a genius ...
It's worth adding that RAD and GUI app frameworks aren't one and the same.
Rapid Application Development means just that - your project manager sets
a date (and it's usually not far away), and your feature set conforms to
that date, rather than the date being adjusted to a fixed feature set. The
definition is often assumed to be synonymous with the use of frameworks,
but it ain't so.
Arved
------------------------------
Date: Sun, 21 Mar 1999 02:43:10 GMT
From: Gene Wilburn <gwilburn@home.com>
Subject: Regex Question
Message-Id: <36F45CB8.48D7A089@home.com>
I'm writing a Perl script to snork in the contents of Unix cal to create
a calendar array in my program. I'm hitting a snag. My regular
expression doesn't work if the line is less than seven days long. I.e.:
$year = "1999";
$month = " 6";
@thiscal = `cal $month $year`;
# Remove first two lines from cal
shift(@thiscal);
shift(@thiscal);
$i = 0;
foreach $line (@thiscal) {
chop $line;
# Stuff each value into the cal array, including
# the blank days as imagemap placemarkers
$line =~ /(..) *(..) *(..) *(..) *(..) *(..) *(..)/;
$cal[$i++] = $1 if $1;
$cal[$i++] = $2 if $2;
$cal[$i++] = $3 if $3;
$cal[$i++] = $4 if $4;
$cal[$i++] = $5 if $5;
$cal[$i++] = $6 if $6;
$cal[$i++] = $7 if $7;
}
print @cal;
...
Everything works fine if cal has a full line, but when it's short of a
week, my regex fails. Is there a way to construct a regex that works if
there's less than a full-line match? I thought the * would do it, but
obviously not.
Thanks,
Gene
-------------------------------------------------------------------
Gene Wilburn, Northern Journey Online, http://www.interlog.com/~njo
-------------------------------------------------------------------
------------------------------
Date: Sat, 20 Mar 1999 21:27:18 -0600
From: "Glen Lee Edwards" <GLEdwards@christianfamilies.net>
Subject: Sending to multiple recipients via Sendmail
Message-Id: <7d1omb$9ic2@iac7.navix.net>
I have a small mailing list, about 25, that I use from a mailing program I
wrote. Currently I am closing the pipe after each letter is sent and then
reopening it for the next letter. Is there a way from a PERL program to
notify Sendmail that one letter is finished and a new one is coming without
closing and reopening the pipe?
The operating system is Linux.
Thanks,
Glen
------------------------------
Date: Fri, 19 Mar 1999 11:52:11 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Testing if variable contains a certain word.....
Message-Id: <MPG.115c4ac369c67259989788@nntp.hpl.hp.com>
In article <blade-1903991743070001@durandal.janton.fi> on Fri, 19 Mar
1999 17:43:07 +0200, Sami Rosenblad <blade@leela.janton.fi> says...
> In article <7ctj6o$9lf$1@news.casema.net>, "MW"
> <oursDELETE-THIS@casema.net> wrote:
> > How can I test if a variable contains a certain word?
> > I want to test $ENV{'HTTP_ACCEPT_LANGUAGE'} for 'nl'
> > to redirect people to other pages.
>
> Try matching:
>
> if ($ENV{'HTTP_ACCEPT_LANGUAGE'} =~ /nl/i) { ...
if ($ENV{'HTTP_ACCEPT_LANGUAGE'} =~ /\bnl\b/i) { ...
so that you don't also match on something like 'only'.
--
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 20 Mar 1999 16:53:14 -0500
From: "Danny" <dstern@aschwebhosting.com*nospam*>
Subject: Variable through form (help!)
Message-Id: <7d15a5$241$1@winter.news.rcn.net>
If I use a form to submit to a cgi script, like so:
(brackets are in place of less than/greater than symbols)
[form action=script.pl method="post"]
[input type=text name="address"]
[input type=submit value="send]
[/form]
In this case, how would I retrieve the data from the "address" field from my
perl script?
*Before replying to my e-mail, please remove the *nospam* tags. Thanks in
advance!
dstern@aschwebhosting.com*nospam*
------------------------------
Date: 20 Mar 1999 23:00:18 -0000
From: Jonathan Stowe <gellyfish@btinternet.com>
Subject: Re: Variable through form (help!)
Message-Id: <7d19a2$52f$1@gellyfish.btinternet.com>
On Sat, 20 Mar 1999 16:53:14 -0500 Danny wrote:
> If I use a form to submit to a cgi script, like so:
> (brackets are in place of less than/greater than symbols)
>
> [form action=script.pl method="post"]
> [input type=text name="address"]
> [input type=submit value="send]
> [/form]
>
> In this case, how would I retrieve the data from the "address" field from my
> perl script?
>
whaddya mean other than:
use CGI qw(:standard);
my $address = param('address');
...
Other than that it is no longer a perl question.
/J\
--
Jonathan Stowe <jns@btinternet.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 5188
**************************************