[15774] in Perl-Users-Digest
Perl-Users Digest, Issue: 3187 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 28 00:06:23 2000
Date: Sat, 27 May 2000 21:05:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <959486710-v9-i3187@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 27 May 2000 Volume: 9 Number: 3187
Today's topics:
Re: Chop <godzilla@stomp.stomp.tokyo>
Re: Chop <phill@modulus.com.au>
Converting an alphanumeric string into an integer numbe <diab.litoNOdiSPAM@usa.net.invalid>
Re: Converting an alphanumeric string into an integer n <bwalton@rochester.rr.com>
Re: cron job and a perl script directory <elaine@chaos.wustl.edu>
Re: Dynamic file names <phill@modulus.com.au>
Re: How do you write a loop invoked from a ketboard? <vandemen@yahoo.com>
Re: how to /s '[item]' (Gwyn Judd)
Re: how to /s '[item]' (Randal L. Schwartz)
Re: How to test perl CGI scripts on my computer first? siatris@my-deja.com
Re: IE blocks referer <s0218327@unix1.cc.ysu.edu>
Re: Mailto accomplished via Perl / CGI ? <s0218327@unix1.cc.ysu.edu>
Re: newbie: random access to large lists <nobody@newsfeeds.com>
Re: oops Re: seeking method to encode email addresses i <elaine@chaos.wustl.edu>
Re: oops Re: seeking method to encode email addresses i <elaine@chaos.wustl.edu>
Re: oops Re: seeking method to encode email addresses i <godzilla@stomp.stomp.tokyo>
Parsing (Jack)
Re: Parsing <phill@modulus.com.au>
Re: Parsing (Jack)
Re: perl and nanosleep()? <jkcohen@uci.edu>
Re: Perl problems under Solaris <elaine@chaos.wustl.edu>
Re: Perl sockets and binary data (Steve Leibel)
Re: Perl unusable as a programming language <erebus@hushmail.com>
Re: Perl unusable as a programming language (Simon Cozens)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 27 May 2000 17:02:50 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Chop
Message-Id: <3930622A.99385A80@stomp.stomp.tokyo>
BassGirl wrote:
> I've got a script for ad banners that is working almost 100%,
snippity do dah, snippity do day..
Ms. BassGirl, here are some very basic
substitution operators to compliment
my other article on using a matching
operator, to attain your goal.
You can mix, match, modify, do all
kinds of neat stuff, having this info
and info from my other article. Have
at it and have some fun.
Look this over. Now you have a lot of
'stuff' with which to work. You will
note in this article, like my other,
I use a different 'delimiter' to
avoid those victory signs \/ ¡¡
Watch out for the Word Wrap Monster.
Incidently, I play a concerto violoncello
and synth/keyboard, a mid-size Yahama.
I am guessing you don't sport fish.
Godzilla!
PRINTED RESULTS
_______________
Truncate And Save Question Mark:
Input:
http://godzilla.net/~godzilla/whamo.cgi?Kira=Annoy%20&Yada=34&???@**!
Output: http://godzilla.net/~godzilla/whamo.cgi?
Truncate Question Mark Outward:
Input:
http://godzilla.net/~godzilla/whamo.cgi?Kira=Annoy%20&Yada=34&???@**!
Output: http://godzilla.net/~godzilla/whamo.cgi
Truncate Retain Base Homepage:
Input:
http://godzilla.net/~godzilla/whamo.cgi?Kira=Annoy%20&Yada=34&???@**!
Output: http://godzilla.net/~godzilla
Truncate Tilde ~ Outward:
Input:
http://godzilla.net/~godzilla/whamo.cgi?Kira=Annoy%20&Yada=34&???@**!
Output: http://godzilla.net/
Truncate And Leave Host Name:
Input:
http://godzilla.net/~godzilla/whamo.cgi?Kira=Annoy%20&Yada=34&???@**!
Output: godzilla.net
TEST SCRIPT
___________
#!/usr/local/bin/perl
print "Content-Type: text/plain\n\n";
print "Truncate And Save Question Mark:\n\n";
$query =
"http://godzilla.net/~godzilla/whamo.cgi?Kira=Annoy%20&Yada=34&???@**!";
print "Input: $query \n\n";
$query =~ s¡(\?).*¡$1¡g;
print "Output: $query \n\n\n";
print "Truncate Question Mark Outward:\n\n";
$query =
"http://godzilla.net/~godzilla/whamo.cgi?Kira=Annoy%20&Yada=34&???@**!";
print "Input: $query \n\n";
$query =~ s/\?.*//g;
print "Output: $query \n\n\n";
print "Truncate Retain Base Homepage:\n\n";
$query =
"http://godzilla.net/~godzilla/whamo.cgi?Kira=Annoy%20&Yada=34&???@**!";
print "Input: $query \n\n";
$query =~ s¡(~[\w\.]+)/.*¡$1¡g;
print "Output: $query \n\n\n";
print "Truncate Tilde ~ Outward:\n\n";
$query =
"http://godzilla.net/~godzilla/whamo.cgi?Kira=Annoy%20&Yada=34&???@**!";
print "Input: $query \n\n";
$query =~ s/~.*//g;
print "Output: $query \n\n\n";
print "Truncate And Leave Host Name:\n\n";
$query =
"http://godzilla.net/~godzilla/whamo.cgi?Kira=Annoy%20&Yada=34&???@**!";
print "Input: $query \n\n";
$query =~ s¡http://([\w\.]+)/.*¡$1¡g;
print "Output: $query \n\n\n";
exit;
------------------------------
Date: Sun, 28 May 2000 13:02:20 +1000
From: Peter Hill <phill@modulus.com.au>
Subject: Re: Chop
Message-Id: <39308C3C.423D@modulus.com.au>
BassGirl wrote:
>
> I've got a script for ad banners that is working almost 100%, BUT here's the
> thing, I'm trying to use it from within database driven pages (the banners
> are targeted to certain categories). This is all fine and good, but when
> the referring page is logged it is like this:
> http://www.atlantanetpages.com/Results.asp?ListingRS_Action=Filter%28%22++CA
> TEGORY+LIKE+%27%2AADVERTISING%2A%27%22%29&ListingRS_Position=PAR:
>
> The problem with this is when my script tries to read & display this log
> file it is geting screwed up on the special characters. I want to be able
> to chop off everything after the "?", or ignore everything after the "?"
>
> Another problem is that not all of the logs are going to have all that stuff
> after the "?" some will be logged like this:
> http://www.atlantanetpages.com/Search.asp
>
> Here is the snippet of script that write to the log file:
>
> sub log
> {
> open (LOG,">>$log_dir$idnum.txt") || &redirect;
> flock(LOG,2);
>
> print LOG "$ENV{'HTTP_REFERER'} $ENV{'REMOTE_ADDR'} $ENV{'REMOTE_HOST'}\n";
>
> flock(LOG,8);
> close(LOG);
> }
>
> I need to be able to chop the HTTP_REFFERER to log only the basic URL.
>
> Any ideas?
>
> Thanks so much,
>
> Debbie
> Please reply to debbieREMOVETHIS@web-tec.com
Rather than using magic numbers like 2 and 8 for locking (which *may* be
correct for your platform), it is healthier to use the Fcntl module.
(perldoc Fcntl)
Explicitly releasing the lock is not necessary - close will do that. The
matching is simple - just take everything prior to '?', if, indeed, '?'
is present.
(perldoc perlop).
Thus:
use Fcntl; ### to allow symbolic references to the constants
sub log
{
open (LOG,">>$log_dir$idnum.txt") || &redirect;
flock(LOG,LOCK_EX);
if($ENV{'HTTP_REFERER'} =~ /(.*?)\?/){
$ENV{'HTTP_REFERER'} = $1;
}
print LOG "$ENV{'HTTP_REFERER'} $ENV{'REMOTE_ADDR'}
$ENV{'REMOTE_HOST'}\n";
### flock(LOG,8); Not needed - the close will release the lock
close(LOG);
}
--
Peter Hill,
Modulus Pty. Ltd.,
http://www.modulus.com.au/
------------------------------
Date: Sat, 27 May 2000 19:11:55 -0700
From: Diablito <diab.litoNOdiSPAM@usa.net.invalid>
Subject: Converting an alphanumeric string into an integer number
Message-Id: <15469506.9d3cc541@usw-ex0105-040.remarq.com>
I have a variable 'word' (letters and numbers) and I want to
convert that into an integer in the range of 1-100.
I need something like a=1,b=2,c=3,...Then I want the script to
calculate a x variable:(example) if word is 'dog' x=26,if
it's 'cat' x=23 and so on.
Thanks,
Mario
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
------------------------------
Date: Sun, 28 May 2000 02:53:03 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Converting an alphanumeric string into an integer number
Message-Id: <3930890F.14BD172D@rochester.rr.com>
Diablito wrote:
>
> I have a variable 'word' (letters and numbers) and I want to
> convert that into an integer in the range of 1-100.
> I need something like a=1,b=2,c=3,...Then I want the script to
> calculate a x variable:(example) if word is 'dog' x=26,if
> it's 'cat' x=23 and so on.
>
> Thanks,
> Mario
...
How about:
$word=<>;
for (a..z,A..Z,0..9){
$h{$_}=++$n;
}
$s=0;
for(split '',$word){
$s+=$h{$_};
}
print "x=".($s%100+1);
--
Bob Walton
------------------------------
Date: Sat, 27 May 2000 23:01:22 GMT
From: Elaine Ashton <elaine@chaos.wustl.edu>
Subject: Re: cron job and a perl script directory
Message-Id: <B555CC00.4ED0%elaine@chaos.wustl.edu>
in article 8gotb3$5nn$1@nnrp1.deja.com, johnqxu@my-deja.com at
johnqxu@my-deja.com quoth:
> All,
> When a cron job is set to invoke a perl script under other directory,
> is there any way to find current directory that the perl script located
> within this perl script?
'man crontab' or 'perldoc perlvar' paying close attention to the ENV
variable.
e.
------------------------------
Date: Sun, 28 May 2000 08:44:21 +1000
From: Peter Hill <phill@modulus.com.au>
Subject: Re: Dynamic file names
Message-Id: <39304FC5.54A8@modulus.com.au>
William Cardwell wrote:
>
> I would like to read a file, and for each line, write it to a file named in
> the line.
>
> The last thing I tried is below but it doesn't work correctly and may be
> completely wrong approach. I have spent a while with FAQs and documentation
> but perhaps not enough. All ideas are welcome.
>
> Thank you in advance,
>
> Will Cardwell
>
> Test Program:
>
> while(<>) {
> $fn=substr($_,3,5); # extract file name
> if ($fnhash{$fn}) { # if file already open
> select $fnhash{$fn};
> } else
>
> $fh=$fnhash{$fn}="F$fn"; # create handle- filename prepended with "F"
> open $fh, ">$fn" or die "Can't open $fn for output: $!"; # open it
> }
> print $_; # write this line as next line in the proper file
[snip]
#! /bin/perl -w
while(<DATA>) {
$fn = substr($_,3,5); # extract file name
if ($fnhash{$fn}) { # if file already open
select $fnhash{$fn};
} else{
$fh = $fnhash{$fn} = "F$fn"; # create handle- filename prepended
with "F"
open $fh, ">$fn" or die "Can't open $fn for output: $!"; # open
it
select $fh;
}
print $_; # write this line as next line in the proper file
}
__DATA__
aaabbbbbxxxxxxxxxxxxxxxxxxx11xxxxxxxxxxxxx
aaabbbbbxxxxxxxxxxxxxxxxxxx22xxxxxxxxxxxxx
aaaxxxxxxxxxxxxxxxxxxxxxxxx33xxxxxxxxxxxx
aaafffffbbbbbxxxxxxxxxxxxxx44xxxxxxxxxxxxxxxxxx
aaabbbbbbbbbbxxxxxxxxxxxxxx55xxxxxxxxxxxxxxxxxx
aaalkdfgbbbbbxxxxxxxxxxxxxxx66xxxxxxxxxxxxxxxxx
aaadghjebbbbbxxxxxxxxxxxxxxxxxx77xxxxxxxxxxxxxx
aaabbbbbxxxxxxxxxxxxxxxxxxxxx88xxxxxxxxxxx
aaafffffbbbbbxxxxxxxxxxxx99xxxxxxxxxxxxxxxxxxxx
aaabbbbbxxxxxxxxxxxxxxxxxxxxx1010xxxxxxxxxxx
hth
--
Peter Hill,
Modulus Pty. Ltd.,
http://www.modulus.com.au/
------------------------------
Date: Sun, 28 May 2000 11:00:52 +0800
From: "Aaron" <vandemen@yahoo.com>
Subject: Re: How do you write a loop invoked from a ketboard?
Message-Id: <HK%X4.6738$c5.10084@newsfeeds.bigpond.com>
debra karr <dkarr1@san.rr.com> wrote in message
news:VgXX4.19357$Y4.92088@typhoon2.san.rr.com...
> I have the code so far to read in a directory path from the keyboard, read
> the contents, then print it to the screen. It counts the number of files
in
> the directory, then prints that. But how do you code in how many times you
> want to run this code, inputed into the original command line?
> CODE:
>
> ###################################################
> # Database Engine to Process SQL scripts
> #
> #
> ###################################################
> my $dir;($dir = $ARGV[0]);
> my $lcount= 0;
> #($lcount = $ARGV[1]);
>
>
> opendir(DIR,"$dir") or die "could not open $dir: $!";
> print "\n $dir contains: \n";
>
>
> while ($_ = readdir(DIR)) {
> $lcount = $lcount + 1;
> {
> print "\t$_ \n";
> }
> }
>
> closedir DIR;
>
> print "\n Number of Loops: $lcount \n";
>
> exit;
>
<snip>
-----------
$loop = 0;
while($loop < $ARGV[1] )
{
rest of program
$loop++;
}
exit;
------------
But somewhere you will have to get a new directory to list or you will be
doing the same one each time.
I would suggets a better way to do it is,
----------------
sub count($)
{ Do the counting }
while(1)
{
print "Enter Directory or EXIT to finish => ";
$dir = <STDIN>;
if ($dir eq "EXIT"){exit;}
else{&count($dir);}
}
cheers
Aaron
------------------------------
Date: Sat, 27 May 2000 22:21:13 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: how to /s '[item]'
Message-Id: <slrn8j3731.39k.tjla@thislove.dyndns.org>
I was shocked! How could Larry Rosler <lr@hpl.hp.com>
say such a terrible thing:
>In article <slrn8j169e.3cn.tjla@thislove.dyndns.org>,
>tjla@guvfybir.qlaqaf.bet says...
>> >In golf you win with the fewest strokes. Same for Perl Golf.
>>
>> keystrokes? or number of characters? When is the next competition?
>
>keystrokes == number of characters + newline, right?
umm not if you make a mistake and have to hit backspace
>The Perl Conference 4.0, organized by Uri Guttman. See the O'Reilly
>conference web page for details.
which is...?
--
Gwyn Judd (tjla@guvfybir.qlaqaf.bet)
My return address is rot13'ed
Systems programmers are the high priests of a low cult.
-- R.S. Barton
------------------------------
Date: 27 May 2000 17:46:44 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: how to /s '[item]'
Message-Id: <m1aehbcxhn.fsf@halfdome.holdit.com>
>>>>> "Gwyn" == Gwyn Judd <tjla@guvfybir.qlaqaf.bet> writes:
>> The Perl Conference 4.0, organized by Uri Guttman. See the O'Reilly
>> conference web page for details.
Gwyn> which is...?
... which is the first hit if you type "O'Reilly conference" into
www.google.com.
Sheesh, do we need to SPOON FEED every single query? People, DO YOUR
HOMEWORK.
ObPerl:
# needs WWW::Search, WWW::Search::Google (from the CPAN)
use WWW::Search;
my $search = WWW::Search->new('Google');
my $query = WWW::Search::escape_query("O'Reilly Conference");
$search->native_query($query);
my $first_result = $search->next_result;
print $first_result->url, "\n";
There. Execute that. Or go find a browser. Seriously.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Sun, 28 May 2000 03:18:25 GMT
From: siatris@my-deja.com
Subject: Re: How to test perl CGI scripts on my computer first?
Message-Id: <8gq362$ckj$1@nnrp2.deja.com>
I did it by downloading a software called "Perl builder" from
www.solutionsoft.com It asks you to download Perl before the software; do it
and install it on C Then install software. Open your script with it and say
"RUN" It will react exactly as it will online. Giving you html messages of
errors or success, etc.
In article <390c132e_1@news.cybertours.com>,
"Ryan & Treena Carrier" <ryanc@nci1.net> wrote:
> I'm trying to figure out how to set my computer up so I can write some CGI
> scripts in Perl and test them on my computer before posting them to my
> internet web server.
>
> I've tried setting up Personal Web Server (I'm running Windows 98) but my
> computer locks up when trying to start the Transaction Server, so I had to
> uninstall it.
>
> HELP!
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sat, 27 May 2000 18:10:48 -0400
From: NagaPutih <s0218327@unix1.cc.ysu.edu>
Subject: Re: IE blocks referer
Message-Id: <Pine.A41.4.20.0005271728550.24048-100000@unix1.cc.ysu.edu>
On Fri, 26 May 2000, Toni wrote:
> IE refuses sending its http_referer when coming from a
> perl generated page. This is strange, because Netscape has got no
> problems doing that.
really? hm.
in my case, it only happens when i try to load a page by changing
document.location property; and it doesn't always happen in every
script-generated pages.
let me know if you found solution to this.
> elsif($referer =~ /http:\/\/nagetier\/cgi-bin\/editq.pl*/){
i may be wrong, but doesn't the above also match against
"http://nagetier/cgi-bin/editq.p" ?
------------------------------
Date: Sat, 27 May 2000 18:04:07 -0400
From: NagaPutih <s0218327@unix1.cc.ysu.edu>
Subject: Re: Mailto accomplished via Perl / CGI ?
Message-Id: <Pine.A41.4.20.0005271801100.44776-100000@unix1.cc.ysu.edu>
On 27 May 2000, Cav wrote:
> (a href=cgi-bin/email_lookup.cgi?ID=101)someone(/a)
>
> ...and have the script look up the proper email addy AND TRIGGER THE USER'S
> EMAIL CLIENT TO OPEN as the first example would?
yes there is, using META tag:
#!/usr/bin/perl -w
print "Content-type: text/html\n\n";
print <<END;
<html>
<head>
<title>mailto:user@host</title>
<meta http-equiv="refresh" content="0;url=mailto:user\@host">
</head>
<body>
</body>
END
------------------------------
Date: Sat, 27 May 2000 18:56:03 -0500
From: Anonymous <nobody@newsfeeds.com>
Subject: Re: newbie: random access to large lists
Message-Id: <MPG.139a1c90d8b60a9f989680@news2.newsfeeds.com>
In article <3930246C.C04CCAFB@vpservices.com>, jeff@vpservices.com
says...
> Thomas Stewart wrote:
> >
> > All-
> >
> > I'm working on a script that needs to randomly grab a line from a large
> > list (tens of thousands of lines). I want the whole line, and the lines
> > are not fixed length. What is the best way of going about this?
>
> If you want to do this with simple file operations, there was an entire
> thread on exactly this topic about two weeks ago. There were a number
> of answers posted. Check the archives at www.deja-news.com searching
> for "random".
>
I'll look into that. I actually did try that search but a) Deja was
acting wacky (as noted in the group archive discussion) and b) the
thread started with the poster asking how to build random lists, rather
than randomly access an existing list. Saw it and moved on, oops.
Thanks,
Thomas Stewart
--------== Posted Anonymously via Newsfeeds.Com ==-------
Featuring the worlds only Anonymous Usenet Server
-----------== http://www.newsfeeds.com ==----------
------------------------------
Date: Sat, 27 May 2000 23:08:16 GMT
From: Elaine Ashton <elaine@chaos.wustl.edu>
Subject: Re: oops Re: seeking method to encode email addresses in web page forms
Message-Id: <B555CD9D.4ED2%elaine@chaos.wustl.edu>
in article 3930371A.4D151388@stomp.stomp.tokyo, Godzilla! at
godzilla@stomp.stomp.tokyo quoth:
> I've been using our net since 1985 if you
> can call it 'the net' back then. More like
> a bunch of academic geeks sending plain
> text love letters to each other.
Well...I had a bitnet account and an academic account around 1982 but that
was strictly for research. I can't remember getting any love letters then as
I probably would have been excited to know there was 'life' on the other
end. I remember wishing to be able to use email for family and
friends....then suddenly it seemed AOL jammed the thruway with people.
> Perl is eleven years old you say?
Perl, she will be a teenager this year so actually 12 years old going on 13.
Of course, if you used Perl5 you might be able to refer to the perlhist but
failing that, there is always http://history.perl.org/
e.
------------------------------
Date: Sat, 27 May 2000 23:14:33 GMT
From: Elaine Ashton <elaine@chaos.wustl.edu>
Subject: Re: oops Re: seeking method to encode email addresses in web page forms
Message-Id: <B555CF17.4ED3%elaine@chaos.wustl.edu>
in article m1r9and7c4.fsf@halfdome.holdit.com, Randal L. Schwartz at
merlyn@stonehenge.com quoth:
> "perldoc perlhist" tells the story, if you have a reasonably modern
> version of Perl installed, either for Windows *or* Unix.
LOL...this is the proclaimed queen of Perl 4 Randal...lest we forget perhist
doesn't come along until 5.005_03-MT1 to be precise......
e.
------------------------------
Date: Sat, 27 May 2000 17:22:34 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: oops Re: seeking method to encode email addresses in web pageforms
Message-Id: <393066CA.319D5EEE@stomp.stomp.tokyo>
Elaine Ashton wrote:
> Randal L. Schwartz quoth:
> > "perldoc perlhist" tells the story, if you have a reasonably
> > modern version of Perl installed, either for Windows *or* Unix.
> LOL...this is the proclaimed queen of Perl 4 Randal...
(snipped)
Extracted from Web Dragon's recent
series of articles.
PERL 5 VERSION
(NO PRINT AT ALL)
__________________
my($gametype, $name, $rating, $mapcount);
foreach my $filez (sort @fileslist) {
my @filedata = ();
my $inputfile = File::Spec->catfile( $inputDir, $filez);
open(IN, "<$inputfile") or die("Can't open $inputfile : $!\n");
while (<IN>) {
s/\012//; #'scuse the silly linewrapping below
if (/Name: +<a +href="http:[^"]+\?nalicity\//gi ..
/\G([^"]+)"/g) {
if (defined $1) {
($gametype, $name) = split /\//, $1;
$name =~ s/\.[^.]*$//;
};
} elsif (/Rating: +\(1-10\) +([\d\.]+)/) {
$rating = $1;
$listing{$gametype}{$name} = $rating;
++$mapcount;
last;
}
}
close(IN);
}
========================================================
PERL 4 VERSION
(INCLUDES A PRETTY PRINT)
_________________________
$pretend_input = (same input as Web Dragon input)
$pretend_input =~ s/<([^>]+)>//g;
$pretend_input =~ s/\n\n|\n/¦/g;
$pretend_input =~ s/¦ ¦|¦¦/¦/g;
$pretend_input =~ s/:¦/:/g;
$pretend_input =~ s/¦ N/¡ N/g;
chop ($pretend_input);
@Count_Games = split (/ ¡ /, $pretend_input);
$count = ($#Count_Games + 1);
print "
There are $count distinct games included within
these input data. Those $count games are: \n\n";
foreach $element (@Count_Games)
{
local ($name, $author, $rating) = split (/¦/, $element);
print " $name $author $rating \n";
}
exit;
Godzilla!
------------------------------
Date: Sat, 27 May 2000 22:17:20 GMT
From: egn@telebot.net (Jack)
Subject: Parsing
Message-Id: <39324969.2988399@news.jps.net>
I cannot seem to figure out how to parse this FTP listing:
-rwx------ 1 user group 3616310 Aug 30 1998 Alexia - Number
one.zip
drwx------ 1 user group 0 Apr 18 00:15 Alice Doc.doc
In the meantime, I've parsed other FTP listing through this code
snippet:
($pr, $fs, $us, $gr, $sz, $d1, $d2, $d3, $fn) = split / +/, $Entry;
but as you can see, the $fn (filename) will only store Alexia, not the
full, Alexia - Number one.zip. Can some help me out with this?
------------------------------
Date: Sun, 28 May 2000 08:52:45 +1000
From: Peter Hill <phill@modulus.com.au>
Subject: Re: Parsing
Message-Id: <393051BD.177A@modulus.com.au>
Jack wrote:
>
> I cannot seem to figure out how to parse this FTP listing:
>
> -rwx------ 1 user group 3616310 Aug 30 1998 Alexia - Number
> one.zip
> drwx------ 1 user group 0 Apr 18 00:15 Alice Doc.doc
>
> In the meantime, I've parsed other FTP listing through this code
> snippet:
>
> ($pr, $fs, $us, $gr, $sz, $d1, $d2, $d3, $fn) = split / +/, $Entry;
>
> but as you can see, the $fn (filename) will only store Alexia, not the
> full, Alexia - Number one.zip. Can some help me out with this?
#! /bin/perl -w
use strict;
while (<DATA>){
my ($pr, $fs, $us, $gr, $sz, $d1, $d2, $d3, $fn) = split(/ +/,$_,9);
print "$fn\n";
}
__DATA__
-rwx------ 1 user group 3616310 Aug 30 1998 Alexia - Number
one.zip
drwx------ 1 user group 0 Apr 18 00:15 Alice Doc.doc
__END__
The optional third parmeter of split limits the number of times that the
split is performed.
perldoc -f split
--
Peter Hill,
Modulus Pty. Ltd.,
http://www.modulus.com.au/
------------------------------
Date: Sun, 28 May 2000 02:27:09 GMT
From: egn@telebot.net (Jack)
Subject: Re: Parsing
Message-Id: <393083e9.17966673@news.jps.net>
Thanks alot.
On Sun, 28 May 2000 08:52:45 +1000, Peter Hill <phill@modulus.com.au>
wrote:
>Jack wrote:
>>
>> I cannot seem to figure out how to parse this FTP listing:
>>
>> -rwx------ 1 user group 3616310 Aug 30 1998 Alexia - Number
>> one.zip
>> drwx------ 1 user group 0 Apr 18 00:15 Alice Doc.doc
>>
>> In the meantime, I've parsed other FTP listing through this code
>> snippet:
>>
>> ($pr, $fs, $us, $gr, $sz, $d1, $d2, $d3, $fn) = split / +/, $Entry;
>>
>> but as you can see, the $fn (filename) will only store Alexia, not the
>> full, Alexia - Number one.zip. Can some help me out with this?
>
>#! /bin/perl -w
>use strict;
>while (<DATA>){
> my ($pr, $fs, $us, $gr, $sz, $d1, $d2, $d3, $fn) = split(/ +/,$_,9);
> print "$fn\n";
>}
>__DATA__
>-rwx------ 1 user group 3616310 Aug 30 1998 Alexia - Number
>one.zip
>drwx------ 1 user group 0 Apr 18 00:15 Alice Doc.doc
>__END__
>
>The optional third parmeter of split limits the number of times that the
>split is performed.
>
>perldoc -f split
------------------------------
Date: Sat, 27 May 2000 18:44:00 -0700
From: "Jonathan K. Cohen" <jkcohen@uci.edu>
Subject: Re: perl and nanosleep()?
Message-Id: <8gptv6$9od$1@news.service.uci.edu>
Sir:
Consider using the usleep method of the Time:: Hires module. This allows you
to sleep in microseconds.
Jonathan Cohen
"force" <forcenoube@zipworld.com.au> wrote in message
news:8gnl1v$oru$1@nina.pacific.net.au...
> Hi,
>
> Does anyone know if it's possible to sleep() in perl for less than
> one millisecond? In particular, if there's an equivilant of nanosleep()
> in perl (or a perl module).
>
> Doing a syscall of nanosleep() will add too much overhead and isn't
> appropriate for this situation.
>
> Thanks.
>
> --
> Cheers.
------------------------------
Date: Sat, 27 May 2000 23:03:26 GMT
From: Elaine Ashton <elaine@chaos.wustl.edu>
Subject: Re: Perl problems under Solaris
Message-Id: <B555CC7C.4ED1%elaine@chaos.wustl.edu>
in article 39321f5d.1222499130@news.supernews.com, Mark McWiggins at
mark@IcanFixYourEmail.com quoth:
> It was indeed a problem with the Solaris libraries; patching the
> system solved the problem.
Any one in particular? I'd be curious to know the OS ver and the patch just
in case I see the same behaviour sometime.
e.
------------------------------
Date: Sat, 27 May 2000 20:22:22 -0700
From: stevel@coastside.net (Steve Leibel)
Subject: Re: Perl sockets and binary data
Message-Id: <stevel-2705002022220001@192.168.100.2>
In article <39302C21.8B9E3475@t-online.de>, Ulrich Ackermann
<UlleAckermann@t-online.de> wrote:
> R1CH wrote:
> > =
>
> > Hi,
> > I have a bunch of packet data (ie, just binary mess such as
> > =11
> > =1A ^^ 0=1A =05
> > =C8, F =1C^
> > that I need to send down a TCP stream to another computer. However, whe=
> n
> > I use
> > =
>
> > open (PACKET,"mypacket");
> > $packettosend =3D <PACKET>;
>
> @packettosend =3D <PACKET>; looks better to me for reading the whole fil=
> e
> "mypacket".
> Then just put the content of the array into your string-variable if
> needed.
> But maybe I do not understand you quite right, because I do not know,
> what this has to do with the sockets you where mentioning in your header
> =2E.. =
>
> =
>
> > $packettosend is always just the first couple of bytes. This makes me
>
> Because $packettosend is a string and just gets the first line (until \n
> normally).
>
>
The original poster should use read(), recv(), or sysread() to read a
number of bytes. The problem with $fred = <WAZOO> is that it will read up
to the first newline. Making the left-hand side an array doesn't help.
If the data is binary there may accidently be a newline sequence in
there. The standard way to read binary data is to prepend a fixed-length
header saying how many bytes to read. First you sysread() the
fixed-length header, then you read as many bytes as it says to read.
If this isn't clear I'll post an example.
Steve L
------------------------------
Date: Sat, 27 May 2000 17:16:46 +0100
From: "Alex Gough" <erebus@hushmail.com>
Subject: Re: Perl unusable as a programming language
Message-Id: <8gosde$chr$1@news.ox.ac.uk>
> > Not particularly. Scripting, if it has any meaning at all, means telling
> > a computer what you want it to do. Programming means telling a computer
> > what you want it to do. See the difference? Yup, it's just about the
> > impression you want to make on the reader. Nothing more.
>
> i disagree. there is a difference between sequencing events (scripting)
> and controlling hardware (programming in low level languages). lately
> i've been fond of saying that Perl programs information, and C programs
> computers.
I think it is best to adopt an operational definition here...
When I write a script, it is something to get a job done, move a few files
around or fire off a load of emails. Generally I use these just once, or
for one small task, and it can get quite tricky to adapt them to fulfil
another simillar task. I also wouldn't want anyone else to see the code in
some of my scripts and certainly wouldn't release them for general
consumption.
A program on the other hand is written to accomplish a range of tasks, be
easily adapted for unforeseen uses and should in general be something that
you would be proud to let someone else use.
The great thing about perl is that it is fantastic for both purposes.
Although almost everything I write using perl sits in the 'script' category,
this is because there are so many different problems which require a quick
and dirty solution.
There have been times though I've noticed that a group of my scripts do
roughly the same sort of thing or that the chap working away next to me
needs somthing to do almost, but not quite, what I spend my time doing.
When this happens, I sit myself down, think a bit and write a program (or
convince him to write one for me :).
It is hard to know where to draw the line between one and the other though,
in the end it boils down to calling a spade a spade and a shovel a shovel.
--
Alex Gough <alex (can be found at) rcon.org>
------------------------------
Date: 28 May 2000 01:25:37 GMT
From: simon@brecon.co.uk (Simon Cozens)
Subject: Re: Perl unusable as a programming language
Message-Id: <slrn8j0tch.be1.simon@justanother.perlhacker.org>
Alex Gough (comp.lang.perl.moderated):
>When I write a script, it is something to get a job done, move a few files
>around or fire off a load of emails. Generally I use these just once, or
>for one small task, and it can get quite tricky to adapt them to fulfil
>another simillar task. I also wouldn't want anyone else to see the code in
>some of my scripts and certainly wouldn't release them for general
>consumption.
>
>A program on the other hand is written to accomplish a range of tasks, be
>easily adapted for unforeseen uses and should in general be something that
>you would be proud to let someone else use.
By which definition, I don't think ever written a script. But then, I've
been well taught to generalise problems and write general solutions. If
it's something that belongs on the command line, I'll tend to use shell
constructs on the command line. But then, by your definition this:
perl -F: -lane '$i+=$F[3]; END{print $i}'
is a program. See, I don't think a program can accomplish a range of
tasks. They've all got one task in mind. sendmail is a program for
dispatching mail. Netscape Navigator's a program for retrieving and
viewing web pages. The above is a program for summing columns. I'm happy
for you to use it because I think it's the neatest way (in Perl) of
achieving that task. And as for the unforeseen uses, I can't foresee what
they would be. :)
--
..you could spend *all day* customizing the title bar. Believe me. I
speak from experience."
(By Matt Welsh)
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 3187
**************************************