[12675] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 84 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 8 22:07:15 1999

Date: Thu, 8 Jul 1999 19:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 8 Jul 1999     Volume: 9 Number: 84

Today's topics:
    Re: $variable (Abigail)
        [1] 988?? <kuryk@home.com>
    Re: Accessing POP mail? (Sean Dowd)
    Re: Accessing POP mail? (Sean Dowd)
        apache webserver question <Gened@ohinter.net>
    Re: apache webserver question (elephant)
    Re: Checking if a url is valid <ysgan@hotmail.com>
        Has anyone thought of this before? <john@dlugosz.com>
        Help!  My pingecho to Linux is going pong! <rwilliamson@uno.gers.com>
        How can I disconnect an NT resource handle w/ Perl? <smontgomery@digitialblaze.net>
        OLE & Excel hemant_gandhi@my-deja.com
    Re: open+0 <jeffp@crusoe.net>
    Re: open+0 (Andrew Allen)
    Re: open+0 <tchrist@mox.perl.com>
    Re: output from cgi to webpage (Abigail)
    Re: Perl - problem with 'open' (John Stanley)
        Perl and Microsoft access database <jammekk@cam.org>
    Re: Perl Debugger recommendation sought <kevinp@COMPANY.com>
    Re: Perl Debugger recommendation sought <kevinp@COMPANY.com>
        perl upgrade breaks old modules <astrodud@yahoo.com>
        perl upgrade breaks old modules <astrodud@yahoo.com>
    Re: perl upgrade breaks old modules <sugalskd@netserve.ous.edu>
    Re: Problem with my program (Ronald J Kimball)
    Re: Problem with my program <anonymous@web.remarq.com>
        Reading who files into a variable.. (Chih-Hsin Wen)
    Re: Reading who files into a variable.. <tchrist@mox.perl.com>
    Re: Reading who files into a variable.. (Abigail)
    Re: Summing Array to Hash elements RABM@prodigy.net
    Re: tie() handle and write() <rick.delaney@home.com>
    Re: URL <michboy@my-deja.com>
    Re: Yikes, confusion for my newbie self (Abigail)
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 8 Jul 1999 20:19:27 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: $variable
Message-Id: <slrn7oajg8.vka.abigail@alexandra.delanet.com>

Raj (technology@workmail.com) wrote on MMCXXXVII September MCMXCIII in
<URL:news:37852D88.56A66012@workmail.com>:
!! Hi,
!! If i click on a hyperlink on my CGI/Perl page, a flag value should be
!! written to flatfile.

That's nice. Why don't you do it then?

!! I used a Hidden form field whose value i'd set in JavaScript function.

That's silly. JS doesn't always work. But that of course has nothing
to do with Perl.

!! then I set this modified form field value to a $variable
!! and tried to write that $variable to a file.
!! 
!! The problem is the $variable is not getting updated after returned from
!! JavaScript fn. ? any help please.... TIA,

fn. ? What is fn. ? And what interaction do you have between Javascript
and Perl? Javascript runs on the client side, while your CGI/Perl thingy
runs on the server side. In between are a browser and an httpd that use
HTTP to communicate.

It looks like you have to restudy the concept of the web.

And this group is just for Perl questions. Javascript and CGI are discussed
elsewhere.


Abigail
-- 
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


------------------------------

Date: Fri, 09 Jul 1999 01:56:43 GMT
From: "bam bam biggie" <kuryk@home.com>
Subject: [1] 988??
Message-Id: <vFch3.15361$UK2.11129@news.rdc1.md.home.com>

i am trying to figure out what the debug info  is.
i keep getting [1] 988
                     [2] 989
errors?!?!


i don't know what is wrong....my command line execution looks like

 ./email.pl?from=joe@aol.co&subject=test&text=this is a test
my code looks like the below code
###############code is below########################
#!/usr/bin/perl -d

if ($ENV{'REQUEST_METHOD'} eq 'GET') {
 @pairs = split(/&/, $ENV{'QUERY_STRING'});
} elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
 read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
 @pairs = split(/&/, $buffer);
} else {
 die "Did not recognize METHOD as POST or GET!";
}

foreach $pair (@pairs) {
 ($name, $value) = split(/=/, $pair);
 $name =~ tr/+/ /;
 $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
 $value =~ tr/+/ /;
 $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
 $value =~ s///g;
 print "$value\n";
 print "$name\n";
 if ($Form{$name} && $value) {
  $Form{$name} = "$Form{$name}, $value";
 }elsif ($value) {
  push(@Field_Order,$name);
  $Form{$name} = $value;
 }
}

print "$Form{'from'}\n";
print "$Form{'subject'}\n";
print "$Form{'text'}\n";

$from = $Form{'from'};
$from =~ s/@/\@/;                            #change email @  to \@
$subject = $Form{'subject'};
$text = $Form{'text'};

print "$Form{'from'}\n";
print "$Form{'subject'}\n";
print "$Form{'text'}\n";

open(MAIL, '| /usr/lib/sendmail -t -oi');
print MAIL <<EOF;
To: myname\@mydomain.com
From: $from
Subject: $subject
$text
EOF
close MAIL;

print "Well done\n";

exit;




------------------------------

Date: Fri, 09 Jul 1999 00:22:00 GMT
From: dowd@spam-free.home.com (Sean Dowd)
Subject: Re: Accessing POP mail?
Message-Id: <dowd-0807991923000001@c37191-a.mckiny1.tx.home.com>

In article <FEJKuL.JnG@csc.liv.ac.uk>, ijg@connect.org.uk (I.J. Garlick) wrote:

> Can someone please tell me what the fascination with the POP3Client on
> CPAN is? Graham Barr wrote a perfectly good module that ships with Perl as
> standard.
> 
> Net::POP3
> 
> I have never seen the need for yet another module. Plus you don't need to
> install it as it should already be there. (This is a God send if you don't
> control your server as many don't).


There are a few reasons it still exists.

1. I'm pretty sure it was part of CPAN before Net::POP3.  I looked and
didn't find anything.  That's why I wrote and contributed it.

2. There are a lot of people using it, partly due to 1.

3. It has a better (I think) API than just a raw interface to the RFC.


> Before amyone asks, yes I did look at POP3Client.pm but came to the
> conclusion it didn't offer anything really significant over POP3.pm


I'm curious.  What is it about having 2 modules that bothers you?


------------------------------

Date: Fri, 09 Jul 1999 00:28:59 GMT
From: dowd@spam-free.home.com (Sean Dowd)
Subject: Re: Accessing POP mail?
Message-Id: <dowd-0807991929590001@c37191-a.mckiny1.tx.home.com>

In article <37846318@newsread3.dircon.co.uk>, Jonathan Stowe
<gellyfish@gellyfish.com> wrote:

> I think that Net::POP3 is actively supported whereas POP3Client isnt.

Huh?  What exactly does "actively supported" mean?

No offense, but that line reminds me of b.s. I used to hear about perl
itself.  I find it pretty ironic.  Or maybe it's just a sign of the state
of perl.


------------------------------

Date: Thu, 08 Jul 1999 21:03:23 -0400
From: Gene Dolgin <Gened@ohinter.net>
Subject: apache webserver question
Message-Id: <37854A5B.B19624BE@ohinter.net>

I am looking into making a perl program, and this question has come to
mind:
Is it possible to setup apache in a way, that when any file from a
specific dir is accessed, the request is forwarded to a perl program?

-gene



------------------------------

Date: Fri, 9 Jul 1999 11:29:01 +1000
From: e-lephant@b-igpond.com (elephant)
Subject: Re: apache webserver question
Message-Id: <MPG.11effb6991c0c369989b24@news-server>

Gene Dolgin writes ..
>Is it possible to setup apache in a way, that when any file from a
>specific dir is accessed, the request is forwarded to a perl program?

yes .. but the answer has nothing to do with perl and everything to do 
with apache .. a product that comes with copious amounts of documentation 
 .. read it

followup set

-- 
 jason - remove all hyphens for email reply -


------------------------------

Date: Fri, 9 Jul 1999 09:49:53 +0800
From: "Victor Gan" <ysgan@hotmail.com>
Subject: Re: Checking if a url is valid
Message-Id: <3785555b.0@news.cyberway.com.sg>

The following works at the command line, but not as a CGI.
Any idea what's wrong?
It keeps returning 500 when run as a CGI script, regardless of the URL.

#!/usr/local/bin/perl

use LWP::Simple;

$url = "http://www.hotmail.com";

$return = getprint $url;

if ($return eq "503" ) {
  print "Content-type:text/html\n\n";
  print $return;
  print "fail\n";
}
elsif ($return eq "500") {
  print "Content-type:text/html\n\n";
  print $return;
  print "fail\n";
}
else {
  print "Content-type:text/html\n\n";
  print $return;
  print "ok!\n";
}


Martin Quensel <martin@adoma.se> wrote in message
news:3783506D.707F133B@adoma.se...
>
>
> Victor Gan wrote:
> >
> > I'm trying to check if a given url such as http://www.hotmail.com
> > is valid using a Perl CGI script.
> >
> > Is there a way to do this?
> Yes.
> Take a look at LWP::Simple.
>
> Best regards
> Martin Quensel




------------------------------

Date: Thu, 8 Jul 1999 20:06:40 -0500
From: "John M. Dlugosz" <john@dlugosz.com>
Subject: Has anyone thought of this before?
Message-Id: <3C273388F3D57815.B4E19C7020E7157A.76E33851B3F6778A@lp.airnews.net>

Consider case of wanting to interpolate a function.  Given something like

    "the result is " . prettyup ($x) . ", or so\n"

we know it can be written using the reference trick:

    "the result is ${\prettyup($x)}, or so\n"

But how about using a tie to a hash and putting the functionality into the
FETCH method, so you can simply say,

    "the result is $prettyup{$x}, or so\n"

?

--John





------------------------------

Date: Thu, 8 Jul 1999 18:51:11 -0700
From: "Rusty Williamson" <rwilliamson@uno.gers.com>
Subject: Help!  My pingecho to Linux is going pong!
Message-Id: <bAch3.538$VX3.24879@news.connectnet.com>

Hi!

I'm using pingecho to determine if a server is responding before I start
sending commands to it and this is working great for all of my UNIX servers
(DG/DGUX, Sequent/DYNIX, IBM/AIX, etc.) except for two Linux boxes.
Although both respond to a ping at the UNIX prompt, the pingecho within my
Perl script fails no matter how much I bump the timeout value.  Does anyone
know what could be going wrong or have any experience with this?

Thanks!
Rusty





------------------------------

Date: Thu, 8 Jul 1999 18:25:12 -0600
From: "Sean Montgomery" <smontgomery@digitialblaze.net>
Subject: How can I disconnect an NT resource handle w/ Perl?
Message-Id: <Nkbh3.148$0X3.1872@newsfeed.slurp.net>

I have an application where I am using Perl to copy files from a source
server to several remote servers on a weekly basis.  Sometimes, a file
doesn't copy successfully because the file on the remote computer is in use.
If that happens I'd like for my Perl script to close the open filehandle on
that
remote server and attempt the copy again.

Is there a way to do this with Perl?  The equivalent NT procedure would
include selecting the server in Server Manager, looking at the "In Use" list
and selecting "Close Resource".  Another comparable is in the Microsoft SDK
(NetFileClose).

Thank you in advance for your help.

Sean Montgomery




------------------------------

Date: Fri, 09 Jul 1999 01:24:06 GMT
From: hemant_gandhi@my-deja.com
Subject: OLE & Excel
Message-Id: <7m3ivc$soi$1@nnrp1.deja.com>

Hi all,
I am processing excel file thru a perl program. reading the excel file
and loading it in the database. can any one tell me how to find out the
number of sheets in the excel file ?


Thanks,
Hemant.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


------------------------------

Date: Thu, 8 Jul 1999 20:24:45 -0400
From: evil Japh <jeffp@crusoe.net>
Subject: Re: open+0
Message-Id: <Pine.GSO.3.96.990708202050.11903A-100000@crusoe.crusoe.net>

> open+0;print<0>

  open FH;
is the same as
  open FH, $FH;
if $FH is lexical variable.

  open+FH;
is the same as
  open FH;
 .  That + is used to separate 'open' from 'FH'.

  open+0; ==> open 0; ==> open 0, $0;

$0 is the name of the perl program being run (more or less).

  open+0; # opens the current file

  print<0>;

prints the contents of the file pointed to by the filehandle 0.

  open+0;print<0>;

is the same as

  open FH, $0;
  print <FH>;

except it's idiomatically obfuscated.


-- 
Jeff Pinyan (jeffp@crusoe.net)
www.crusoe.net/~jeffp

Crusoe Communications, Inc.
732-728-9800
www.crusoe.net



------------------------------

Date: 9 Jul 1999 00:13:25 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: open+0
Message-Id: <7m3er5$o7b$1@fcnews.fc.hp.com>

Jan Egil Hagen (janha@nntp.ifi.uio.no) wrote:

: I was reading <URL:http://www.nyx.net/~gthompso/self_perl.txt>, and
: came across this wonderfully incomprehensible program:

: open+0;print<0>

: Does anybody have any idea why it works,

Yes, because people on this newsgroup (and Perlites in general) are
sick, twisted, perverse individuals.

: and what it is happening?

That's all waiting for you to discover in the
documentation. "perlfunc", "perlop", and "perlvar" might be two places
to start.

Andrew


------------------------------

Date: 8 Jul 1999 19:16:56 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: open+0
Message-Id: <37854d88@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, evil Japh <jeffp@crusoe.net> writes:
:  open FH;
:is the same as
:  open FH, $FH;
:if $FH is lexical variable.
	   ^^^^^^^
Nope.

--tom
-- 
    If you want to program in C, program in C.  It's a nice language.  I
    use it occasionally...   :-)
            --Larry Wall in <7577@jpl-devvax.JPL.NASA.GOV>


------------------------------

Date: 8 Jul 1999 20:23:30 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: output from cgi to webpage
Message-Id: <slrn7oajns.vka.abigail@alexandra.delanet.com>

qingshan@my-deja.com (qingshan@my-deja.com) wrote on MMCXXXVII September
MCMXCIII in <URL:news:7m36g6$oc8$1@nnrp1.deja.com>:
`` 
`` The webpage calls a cgi script, sometimes it should update that page.
`` But sometimes there shouldn't be any change.  If I don't output
`` anything from the script, there will be a "no data" popup window.
`` If I output "Status =Status:304 Not Modified", the page will be
`` overwriten with blank.  Is there anyway I can leave the original page
`` untouched, if I want to.

Yes. RTFRFC.

This group isn't about HTTP issues.


Abigail
-- 
echo "==== ======= ==== ======"|perl -pes/=/J/|perl -pes/==/us/|perl -pes/=/t/\
 |perl -pes/=/A/|perl -pes/=/n/|perl -pes/=/o/|perl -pes/==/th/|perl -pes/=/e/\
 |perl -pes/=/r/|perl -pes/=/P/|perl -pes/=/e/|perl -pes/==/rl/|perl -pes/=/H/\
 |perl -pes/=/a/|perl -pes/=/c/|perl -pes/=/k/|perl -pes/==/er/|perl -pes/=/./;


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


------------------------------

Date: 9 Jul 1999 00:07:59 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Perl - problem with 'open'
Message-Id: <7m3egv$af6$1@news.NERO.NET>

In article <7m3326$p8j$1@bbnews1.unisys.com>,
Paul Glidden <paul.glidden@unisys.com> wrote:
>I am assuming the file is an executable, in which case you can not open the
>file to receive output from the file.  Much like C++ the open command is to
>get the contents of a file.
 ...
>Each of these things would be described in great detail in a perl book or
>the perl documentation.

As is the use of open to execute commands with the file handle attached
to the input or output of the command. From the "open" function as
posted here not too long ago:

    If the filename begins with `'|'', the filename is interpreted as a
    command to which output is to be piped, and if the filename ends
    with a `'|'', the filename is interpreted as a command which pipes
    output to us. See the section on "Using open() for IPC" in the
    perlipc manpage for more examples of this.




------------------------------

Date: Thu, 08 Jul 1999 20:44:55 -0400
From: Jamal Mekkati <jammekk@cam.org>
Subject: Perl and Microsoft access database
Message-Id: <37854607.65AD@cam.org>

Hi ,

Do you know the procedure on how to access Microsoft Access database
from perl ? or any link I can refer to ? or a perl sample code ?

This is for a web application.

Thanks for your help./JM


------------------------------

Date: Fri, 09 Jul 1999 10:23:38 +1000
From: Kevin Powe <kevinp@COMPANY.com>
Subject: Re: Perl Debugger recommendation sought
Message-Id: <37854109.63021A7B@COMPANY.com>

> > I've had a look at the ActiveState Perl Debugger, but I couldn't drill
> > down through objects with enough ease for it to be suitable. I need
> > something that can deal with objects easily, allows the setting of
> > breakpoints in multiple files for execution, and allows watching on
> > the contents of structures as well.
> 
> dosen't ActiveState's PD do all that? **boggled**

It well might, but if it does, then I'm still in the process of finding
out how. It was possible to drill down through arrays to specific
elements by setting watches on $array[index], but watches on @array just
give me its size.

As for objects, I'm messing around with some of my own code at the
moment, as opposed to our system that is being developed, and seeing if
I can get things working that way, but initially I couldn't get the
Debugger to play nice with objects.

-- 

****************************************************
  Kevin Powe     Mincom Software Engineer
                     "When you reach an impasse, 
                      adapt and you will go through"
****************************************************
  If these were Mincom's opinions, they'd make more
  sense. To reply to me directly, guess who I work
  for. (your time starts... NOW!)
****************************************************


------------------------------

Date: Fri, 09 Jul 1999 11:20:20 +1000
From: Kevin Powe <kevinp@COMPANY.com>
Subject: Re: Perl Debugger recommendation sought
Message-Id: <37854E53.8FC55623@COMPANY.com>

> > I've had a look at the ActiveState Perl Debugger, but I couldn't drill
> > down through objects with enough ease for it to be suitable. I need
> > something that can deal with objects easily, allows the setting of
> > breakpoints in multiple files for execution, and allows watching on
> > the contents of structures as well.
> 
> dosen't ActiveState's PD do all that? **boggled**

That would be... Dump Variable. Duh.

*shakes head at own stupidity*

-- 

****************************************************
  Kevin Powe     Mincom Software Engineer
                     "When you reach an impasse, 
                      adapt and you will go through"
****************************************************
  If these were Mincom's opinions, they'd make more
  sense. To reply to me directly, guess who I work
  for. (your time starts... NOW!)
****************************************************


------------------------------

Date: Fri, 09 Jul 1999 00:19:59 GMT
From: astrodud <astrodud@yahoo.com>
Subject: perl upgrade breaks old modules
Message-Id: <7m3f76$rgr$1@nnrp1.deja.com>

Hi. I am inexperienced with this, but I am simply upgrading my
perl-5.004 RPM to perl-5.00503. It seems to work fine, and after
fiddling with @INC, it includes everything fine, but my old
PDL modules (which I can't get by without) return with this error
when they try to load. Does anyone know if I can do anything or
do I have to recompile PDL and all of its dependent modules?

(4)% plotEbvDistribs.pl Ia
Can't load
'/usr/lib/perl5/site_perl/5.005/i386-linux/auto/PDL/Core/Core.so' for
module PDL::Core:
/usr/lib/perl5/site_perl/5.005/i386-linux/auto/PDL/Core/Core.so:
undefined symbol: Perl_markstack_ptr at
/usr/lib/perl5/5.00503/i386-linux/DynaLoader.pm line 169.

 at /usr/lib/perl5/site_perl/5.005/PDL.pm line 12
BEGIN failed--compilation aborted at
/usr/lib/perl5/site_perl/5.005/PDL.pm line 12.
BEGIN failed--compilation aborted at plotEbvDistribs.pl line 3.



Thanks. please email me at astrodud@yahoo.com


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


------------------------------

Date: Fri, 09 Jul 1999 00:19:04 GMT
From: astrodud <astrodud@yahoo.com>
Subject: perl upgrade breaks old modules
Message-Id: <7m3f5e$rgj$1@nnrp1.deja.com>

Hi. I am inexperienced with this, but I am simply upgrading my
perl-5.004 RPM to perl-5.00503. It seems to work fine, and after
fiddling with @INC, it includes everything fine, but my old
PDL modules (which I can't get by without) return with this error
when they try to load. Does anyone know if I can do anything or
do I have to recompile PDL and all of its dependent modules?

(4)% plotEbvDistribs.pl Ia
Can't load
'/usr/lib/perl5/site_perl/5.005/i386-linux/auto/PDL/Core/Core.so' for
module PDL::Core:
/usr/lib/perl5/site_perl/5.005/i386-linux/auto/PDL/Core/Core.so:
undefined symbol: Perl_markstack_ptr at
/usr/lib/perl5/5.00503/i386-linux/DynaLoader.pm line 169.

 at /usr/lib/perl5/site_perl/5.005/PDL.pm line 12
BEGIN failed--compilation aborted at
/usr/lib/perl5/site_perl/5.005/PDL.pm line 12.
BEGIN failed--compilation aborted at plotEbvDistribs.pl line 3.



Thanks. please email me at astrodud@yahoo.com


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


------------------------------

Date: 9 Jul 1999 01:39:33 GMT
From: Dan Sugalski <sugalskd@netserve.ous.edu>
Subject: Re: perl upgrade breaks old modules
Message-Id: <7m3jsl$d0l$1@news.NERO.NET>

astrodud <astrodud@yahoo.com> wrote:
: Hi. I am inexperienced with this, but I am simply upgrading my
: perl-5.004 RPM to perl-5.00503. It seems to work fine, and after
: fiddling with @INC, it includes everything fine, but my old
: PDL modules (which I can't get by without) return with this error
: when they try to load. Does anyone know if I can do anything or
: do I have to recompile PDL and all of its dependent modules?

Perl 5.005's not binary compatible with 5.004. You'll need to rebuild PDL. 

				Dan


------------------------------

Date: Thu, 8 Jul 1999 21:15:10 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Problem with my program
Message-Id: <1dun5wz.yw66ivj2p3e6N@p46.block2.tc2.state.ma.tiac.com>

theoddone33 <eoddonetha@akefilesqua.com> wrote:

> #!/usr/bin/perl -w
> print "theoddone33\'s condump analyzer v0.5\n";
> print "---------------------------------------\n";
> while(<>) {
> unless(/:/) { #discard if line has a semicolon.  This indicates talking

I think that the following is cleaner:

next if /:/;

but that's a style issue, and your way works fine.


>   if(/\brailed\b/) { #discard if not a rail death
>    $killed = $killer = $_; #just to be safe
>    $killed =~ s/(^.*)\bwas railed by .*/$1/; #get victim's name
>    chomp($killed);
>    chop($killed); #dump the extra space
>    $deaths{$killed}++;
>    $killer =~ s/^.* was railed by (.*$)/$1/; #get killer's name
>    chomp($killer);
>    $frags{$killer}++;
>   }

Replace this whole section with:

if (($killed, $killer) = /^(.*) was railed by (.*)\./) {
  $deaths{$killed}++;
  $frags{$killer}++;
}

You don't need to do any substitution, you just want to extract specific
bits from the string.


> }
> }
> #print results
> foreach $a (keys %deaths) {

Somewhere you need to initialize the hash values for players who had
either no kills or no frags.  This would be one place to do it.

$frags{$a} ||= 0;
$deaths{$a} || = 0;

[Note that $a is not a very descriptive name.]

> print "$a had $frags{$a} frags and $deaths{$a} deaths\n";
> }
> print "frag keys are:\n";
> foreach $b (keys %frags) {
> print "$b  \n";
> }

> Okay, enter problem.  On first inspection, the keys in %frags and %deaths
> appear to be the same.  When the second foreach prints them out, they look
> identical.

Look closer.  You forgot to remove the periods from the keys in %frags.
I fixed that in your original code and it worked fine, so you were very
close.

-- 
 _ / '  _      /       - aka -
( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
    /                                http://www.tiac.net/users/chipmunk/
        "It's funny 'cause it's true ... and vice versa."


------------------------------

Date: Thu, 08 Jul 1999 17:52:09 -0800
From: theoddone33 <anonymous@web.remarq.com>
Subject: Re: Problem with my program
Message-Id: <931485131.22390@www.remarq.com>

Thanks a bundle.  Clean code is code that's a lot easier to
fix.  Sorry you had to wade through all that, but I'm glad
somebody took the time to do it.  If any of you are
interested, I'll give you a URL when I'm through with the
program.  Don't be surprised if you see a "Special thanks"
in the documentation with your name on it.

theoddone33



**** Posted from RemarQ - http://www.remarq.com - Discussions Start Here (tm) ****


------------------------------

Date: 9 Jul 1999 00:08:31 GMT
From: ccwen@bu.edu (Chih-Hsin Wen)
Subject: Reading who files into a variable..
Message-Id: <7m3ehv$aj9$1@news1.bu.edu>

	  Does anyone know how I can read an entire file into a variable? I
	  don't want to process just one line at a time, rather I'm hoping to
	  be able to read the whole file (a perl script) and eval() it. I
	  suppose I could just do something like $var = `more < file`; but I'd
	  rather use some other convention..any help would be good..

	  Scott Wen
nke


------------------------------

Date: 8 Jul 1999 18:15:59 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Reading who files into a variable..
Message-Id: <37853f3f@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    ccwen@bu.edu (Chih-Hsin Wen) writes:
:	  Does anyone know how I can read an entire file into a variable? I
:	  don't want to process just one line at a time, rather I'm hoping to
:	  be able to read the whole file (a perl script) and eval() it. I
:	  suppose I could just do something like $var = `more < file`; but I'd
:	  rather use some other convention..any help would be good..

It's the FAQ.  I'm sure you checked there first, right?

    NAME
	perlfaq5 - Files and Formats ($Revision: 1.38 $, $Date:
	1999/05/23 16:08:30 $)

    DESCRIPTION
	This section deals with I/O and the "f" issues: filehandles,
	flushing, formats, and footers.

	...

      How can I read in an entire file all at once?

	The customary Perl approach for processing all the lines in a
	file is to do so one line at a time:

	    open (INPUT, $file)         || die "can't open $file: $!";
	    while (<INPUT>) {
		chomp;
		# do something with $_
	    } 
	    close(INPUT)                || die "can't close $file: $!";

	This is tremendously more efficient than reading the entire file
	into memory as an array of lines and then processing it one
	element at a time, which is often -- if not almost always -- the
	wrong approach. Whenever you see someone do this:

	    @lines = <INPUT>;

	You should think long and hard about why you need everything
	loaded at once. It's just not a scalable solution. You might
	also find it more fun to use the the standard DB_File module's
	$DB_RECNO bindings, which allow you to tie an array to a file so
	that accessing an element the array actually accesses the
	corresponding line in the file.

	On very rare occasion, you may have an algorithm that demands
	that the entire file be in memory at once as one scalar. The
	simplest solution to that is:

	    $var = `cat $file`;

	Being in scalar context, you get the whole thing. In list
	context, you'd get a list of all the lines:

	    @lines = `cat $file`;

	This tiny but expedient solution is neat, clean, and portable to
	all systems that you've bothered to install decent tools on,
	even if you are a Prisoner of Bill. For those die-hards PoBs
	who've paid their billtax and refuse to use the toolbox, or who
	like writing complicated code for job security, you can of
	course read the file manually.

	    {
		local(*INPUT, $/);
		open (INPUT, $file)     || die "can't open $file: $!";
		$var = <INPUT>;
	    }

	That temporarily undefs your record separator, and will
	automatically close the file at block exit. If the file is
	already open, just use this:

	    $var = do { local $/; <INPUT> };

      How can I read in a file by paragraphs?

	Use the `$/' variable (see the perlvar manpage for details). You
	can either set it to `""' to eliminate empty paragraphs
	(`"abc\n\n\n\ndef"', for instance, gets treated as two
	paragraphs and not three), or `"\n\n"' to accept empty
	paragraphs.

	Note that a blank line must have no blanks in it. Thus `"fred\n
	\nstuff\n\n"' is one paragraph, but `"fred\n\nstuff\n\n"' is
	two.


Yes, I know I haven't applied the patches yet.

--tom
-- 
If you want to see useful Perl examples, we can certainly arrange to have
comp.lang.misc flooded with them, but I don't think that would help the
advance of civilization.  :-) --Larry Wall in <1992Mar5.180926.19041@netlabs.com>


------------------------------

Date: 8 Jul 1999 20:15:27 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Reading who files into a variable..
Message-Id: <slrn7oaj8o.vka.abigail@alexandra.delanet.com>

Chih-Hsin Wen (ccwen@bu.edu) wrote on MMCXXXVIII September MCMXCIII in
<URL:news:7m3ehv$aj9$1@news1.bu.edu>:
@@ 	  Does anyone know how I can read an entire file into a variable? I
@@ 	  don't want to process just one line at a time, rather I'm hoping to
@@ 	  be able to read the whole file (a perl script) and eval() it.

Just 'do' or 'require' the file. That's of course mentioned in the
manual, but that would be a silly place to look.



Abigail
-- 
perl -wle 'print "Prime" if (0 x shift) !~ m 0^\0?$|^(\0\0+?)\1+$0'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


------------------------------

Date: 08 Jul 1999 20:49:13 -0400
From: RABM@prodigy.net
Subject: Re: Summing Array to Hash elements
Message-Id: <uyagqk5py.fsf@prodigy.net>

>>>>> "LR" == M J T Guy <mjtg@cus.cam.ac.uk> writes:

    LR> Larry Rosler <lr@hpl.hp.com> wrote:
    >> In article <u4sjg0w8o.fsf@prodigy.net> on 07 Jul 1999 21:24:23 -0400, 
    >> RABM@prodigy.net <RABM@prodigy.net> says...
    >> ...
    >>> my %word;
    >>> while( <DATA> =~ m/(.+)/g) {
    >>> $word{$1}++;
    >>> }
    >> 
    >> That is a very strange way to do, in essence, chomp().  And I don't know 
    >> why the '/g' is there.  How many times can that regex match on one line, 
    >> anyhow?

For that matter I guess the 'm/' is not needed either.  I guess it stems
back from when I was a kid and wanted an MG midget. :-)

-- 
Vinny


------------------------------

Date: Fri, 09 Jul 1999 01:48:14 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: tie() handle and write()
Message-Id: <378554A7.9D167244@home.com>

[posted & mailed]

Jenda Krynicky wrote:
> 
> print TIEDHANDLE ... calls Modulename::PRINT.
> printf TIEDHANDLE ... calls Modulename::PRINTF.
> but what with write()?
> 
> It doesn't seem to call Modulename::WRITE. Nor Modulename::PRINT.
> I tried even SYSWRITE just in case ... nothing.

Tied handles are still incomplete.  One of the missing methods is
WRITE.  Well, actually WRITE is there but it is called when you use
syswrite().  

Someone was obviously trying to right an old wrong there but this will
surely just lead to confusion when (if) a method for write() is ever
added.  What's it going to be called?  FORMWRITE?

> So how, if at all, is this possible?

If you don't mind losing the indirect object syntax, you can add your
own method that uses formline, etc and just forego write() completely.

-- 
Rick Delaney
rick.delaney@home.com


------------------------------

Date: Fri, 09 Jul 1999 01:02:15 GMT
From: Steven W. Peters <michboy@my-deja.com>
Subject: Re: URL
Message-Id: <7m3hmi$sb8$1@nnrp1.deja.com>

In article <3785362A.E718994@workmail.com>,
  Raj <technology@workmail.com> wrote:
> How can we encode the parameters passed as querystring in the URL.
> http://abc.xyz.com/Page2.pl?param1=xxx&param2=xxx
> instead of...
> http://abc.xyz.com/Page2.pl?param1=val1&param2=val2
> Any clue please!!!!
>
> Raj

Just use the POST method on your form instead...  Otherwise the way
that you retrieve the information from the form in your script is
likely not to be accurate since you are basically changing what the
user entered into the box.  Unless there's some way to change the
values of the form after assigning them to the variables and before
showing the URL in the browser, which is unlikely.

Steve

--
Steven W. Peters
Webdesigner
Novice Visual Basic & Perl programmer


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


------------------------------

Date: 8 Jul 1999 20:38:04 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Yikes, confusion for my newbie self
Message-Id: <slrn7oakj5.vka.abigail@alexandra.delanet.com>

Cayce Collins (cayce@thurston.com) wrote on MMCXXXVII September MCMXCIII
in <URL:news:7m3bks$adr$1@quark.scn.rain.com>:
;; Here's the code:
;; 
;; if(/^($input_for{'username'})(\s*)First:(\w*)(\s*)Last:(\w*)(\s*)Time:(\S*)(
;; \s*)Date:(\S*)(\s*)Problem:(\$

This isn't valid. I bet it won't compile. And why are you capturing white
space and other irrelevant stuff that you aren't using?

;;                 $test=1;
;;                 $username=$input_for{'username'};
;;                 $user=$3." ".$5;
;;                 $time=$7;
;;                 $thedate=$9;
;;                 $theproblem=$11;
;;         }
;; 
;; Here's the line from the txt file:
;; 
;; jdoe First:John Last:Doe Time:8:51am Date:07/08/99 Problem:User Had to
;; Re-install.
;; 
;; How do I get the "Problem: ..." to display, it will only show up as "User"
;; on the web page, how do I get the whole sentance?


Uhm, djee. How about 'print "Problem: $theproblem";' ? Or would that
be too obvious?


Abigail
-- 
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
         / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / 
         % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
         BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


------------------------------

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". 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 V9 Issue 84
************************************


home help back first fref pref prev next nref lref last post