[8822] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2440 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 28 11:07:20 1998

Date: Tue, 28 Apr 98 08:01:43 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 28 Apr 1998     Volume: 8 Number: 2440

Today's topics:
    Re: problem adding with a hash (never mind...) <eglamkowski@angelfire.com>
    Re: problem adding with a hash (never mind...) <andy@wonderworks.co.uk>
        problem adding with a hash <eglamkowski@angelfire.com>
    Re: problem adding with a hash <quentin@shaddam.amd.com>
    Re: Problem with Perl script (Probaply very simple) <beske@worldnet.att.net>
    Re: Redefined subroutines using mod_perl <pm@katz.cc.univie.ac.at>
    Re: Splitting a variable ??? tanr@vancpower.com
    Re: Statistics for comp.lang.perl.misc (Stefaan A Eeckels)
        unrecognizable switch (Jeff)
    Re: using perl as a script (I.J. Garlick)
    Re: using perl as a script <jdporter@min.net>
    Re: where are the examples in the newer (blue) camel bo <merlyn@stonehenge.com>
    Re: where are the examples in the newer (blue) camel bo <ljz@asfast.com>
    Re: where are the examples in the newer (blue) camel bo <tchrist@mox.perl.com>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 28 Apr 1998 09:55:41 -0400
From: the count <eglamkowski@angelfire.com>
Subject: Re: problem adding with a hash (never mind...)
Message-Id: <3545DFDD.FF2@angelfire.com>

Quentin Fennessy wrote:
> I do not understand why you have a problem.  I just ran
> your code and for this input I got 0.13 for a total:

I just figured it out and it has nothing to do with perl - I was
reading in *.txt for input, and outputting to sum.txt.  So, after
I ran the program, when I ran it a second time, it read in sum.txt
and added it in with the rest, which is not what I wanted it ;P

Duh.


> I fiddled with your code a bit, but these suggestions are
> just perlish style issues.  How about:
> 
> my %sum;
> while(<>) {
>         chomp;
>         next unless /^\d+/;  # I suggest hash-initiated comments
>                              # if you can control input file syntax.
>         ($id,$val) = split(/,/);  # named vars easier on my brain
>         $sum{$id} += $val;
> }
> 
> foreach my $key (sort keys %sum) {
>         print "$key $sum{$key}\n";
> }

I tried this, but oddly, it only printed the sums for those 
id's > 10000, missing 7000-9999.
*boggle*


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

Date: Tue, 28 Apr 1998 15:02:22 +0100
From: Andy Armstrong <andy@wonderworks.co.uk>
Subject: Re: problem adding with a hash (never mind...)
Message-Id: <cnIqdWAuFeR1Ewl6@wndrwrks.demon.co.uk>

In article <3545DFDD.FF2@angelfire.com>, the count
<eglamkowski@angelfire.com> writes
[snip]
>I tried this, but oddly, it only printed the sums for those 
>id's > 10000, missing 7000-9999.
>*boggle*

I guess the id's are all right aligned in 5 digit fields then...

*unboggle* :-)
-- 
http://www.wonderworks.co.uk --> Free RISC OS software
Andy Armstrong, WonderWorks


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

Date: Tue, 28 Apr 1998 08:40:56 -0400
From: the count <eglamkowski@angelfire.com>
Subject: problem adding with a hash
Message-Id: <3545CE58.506B@angelfire.com>

So, I've got this program which reads ascii files with lines of the 
format:

<id>,<value>

and I need to sum up all the values for each id.

So, I did:
while (<>) {
    chomp;
    @line = split(/,/);
    
    if ($line[0] =~ /(\d)+/) { # Ignore lines of text, i.e. comments.
	$sum{$line[0]} += $line[1];
    }
}

Now, when I print the values:
foreach $key (sort(keys %sum)) {
    print SUM "$key,$sum{$key}\n";
}

they are all off by a factor of three!  I've been using four input
files for testing, and I have the following id & values (each value
is really in a different file, but I put it all on one line for ease
of reference):

                                        actual         Perl's 
ID      val1    val2    val3    val4    total          total
7000	0.07	0.02	0	0.04	0.13		0.39

And this is consistently a problem for every single total Perl came up 
with.  Any idea what is going on here?


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

Date: 28 Apr 1998 08:08:36 -0500
From: Quentin  Fennessy <quentin@shaddam.amd.com>
Subject: Re: problem adding with a hash
Message-Id: <ximaf96um97.fsf@shaddam.amd.com>


I do not understand why you have a problem.  I just ran
your code and for this input I got 0.13 for a total:

    : qf:~/tmp; ./t3
    7000,0.07
    7000,0.02
    7000,0
    7000,0.04
    ^D
    7000,0.13	<-- output

I suspect your input file is not what you think it is.
Are there more lines with id=7000 than you think?

I fiddled with your code a bit, but these suggestions are
just perlish style issues.  How about:

my %sum;
while(<>) {
	chomp;
	next unless /^\d+/;  # I suggest hash-initiated comments
			     # if you can control input file syntax.
	($id,$val) = split(/,/);  # named vars easier on my brain
	$sum{$id} += $val;	
}

foreach my $key (sort keys %sum) {
	print "$key $sum{$key}\n";
}
	

-- 
Quentin Fennessy			AMD, Austin Texas
Secret hacker rule #11 - hackers read manuals


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

Date: Tue, 28 Apr 1998 08:17:11 -0400
From: Bryan Beske <beske@worldnet.att.net>
To: stevenf@pcdynamics.nl
Subject: Re: Problem with Perl script (Probaply very simple)
Message-Id: <6i4hdl$9lo@bgtnsc03.worldnet.att.net>

> #!/usr/local/bin/perl
>

    Try this instead:  &parse_form_data( \%form );


> &parse_form_data (*form);
> print "Content-type: text/html\n\n";
> print <<End_of_document;
>
> <html>
> Text1: $form{'text1'}<br>
> Text2: $form{'text2'}<br>
> Text3: $form{'text3'}<br>
> </html>
>
> End_of_document
> exit ();
>
>



> The problem is that I'm getting an : Internal Server Error 500
> This line : #!/usr/local/bin/perl is correct!

Possibly, possible not, to test do the following:

    /usr/local/bin/perl -v

If it is OK, then you should get the version of perl back.

I suspect that passing of a typglob instead of the pointer to the
variable is your problem. (The first suggestion)




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

Date: 28 Apr 1998 13:31:31 GMT
From: Peter Marksteiner <pm@katz.cc.univie.ac.at>
Subject: Re: Redefined subroutines using mod_perl
Message-Id: <6i4lnj$420a$1@www.univie.ac.at>

In comp.lang.perl.misc Chris_Schoenfeld@sonic.net wrote:
: I thought I was doing everthing right with mod_perl ala scoping etc...but I
: keep getting redefined sub warnings on all the subs in my script - what is up
: with that?

Send a HUP signal to your Apache after modifying scripts executed by
mod_perl.
 
-- 
Peter Marksteiner                       e-mail: Peter.Marksteiner@univie.ac.at
Vienna University Computer Center                   Tel: (+43 1) 4277 14055
Universitaetsstrasse 7, A-1010 Vienna, Austria      FAX: (+43 1) 4277 9140


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

Date: Tue, 28 Apr 1998 08:32:57 -0600
From: tanr@vancpower.com
Subject: Re: Splitting a variable ???
Message-Id: <6i4lq9$tc$1@nnrp1.dejanews.com>

Can you try substr?
Where is that variable come from?  If this is a date, try to put space between
them so you can split them.  like:

$aDate = "04 24 98 a";
($aMon, $aDate, $aYear, $aStr) = split(/\s/,$aDate);

I hope it help!

In article <6i3qmc$bk6$1@opal.southwind.net>,
  "Matthew Wagley" <rudedog@gcnet.com> wrote:
>
> I am wanting to split an input of a string say
>
> 042498a
>
> I want to split that out to 04  24  98  a   into separate variable or an
> array.  Can this be done?? I have tried finding it in Learning perl book and
> all over the net.  Last resource was here.  I appreciate your help or even a
> point in the right direction where this is documented on the net.
> Thanks.
> Matthew Wagley
>
>


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: 28 Apr 1998 09:26:17 GMT
From: Stefaan.Eeckels@ecc.lu (Stefaan A Eeckels)
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <6i47bp$igi$1@justus.ecc.lu>

In article <35459017.72CC@linguistik.uni-erlangen.de>,
	Christian Wetzel <cnwetzel@linguistik.uni-erlangen.de> writes:
> Greg Bacon:
> 
>> Top 10 Posters by OCR (minimum of five posts)
> 
> I always wonder what "OCR" means in this context?
Original Content Ratio - ie how much is quoted vs
original text.

-- 
Stefaan
-- 

PGP key available from PGP key servers (http://www.pgp.net/pgpnet/)
___________________________________________________________________
  "Don't worry about people stealing your ideas.  If your ideas
   are any good, you'll have to ram them down people's throats."
                                                -- Howard Aiken


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

Date: Tue, 28 Apr 1998 13:59:59 GMT
From: jeffmcc@mindspring.com (Jeff)
Subject: unrecognizable switch
Message-Id: <3545e006.8278383@news>

I have a script that takes input from a search form.  When the script
is called it uses another perl library cgi-lib.pl to parse through the
input.  The script was written on NT and it runs fine there, but when
I try to run it on UNIX, my system admin says that it's returning
"unrecognizable switch".  I've compiled it on the UNIX box and it
returns "cass.pl syntax OK".  I really don't know what's going on.
Has anyone had any problems with this error?  If I need to I can send
you the two scripts, just let me know.

TIA,
Jeff


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

Date: Tue, 28 Apr 1998 10:42:21 GMT
From: ijg@csc.liv.ac.uk (I.J. Garlick)
Subject: Re: using perl as a script
Message-Id: <Es4DqL.FK6@csc.liv.ac.uk>

In article <6i3ldp$85c$1@nnrp1.dejanews.com>,
phillip@javanet.com writes:
> Basically what I was wondering is is it possible to make a perl script that
> runs and ever 3 ours or so (or even several specified times like 7:30, 9:00,
> 12:00 and so on) to count how many new messages in the mail spool, and then
> in turn send a message to a specified e-mail address formatted like this.
> "You currently have # new messages in your inbox." Or would I have to use
> another language such as C or something. And if I could do this how would I
> go about learning how to do this. I really would like to know how as soon as
> possible.
> 

I am still very new to Perl but I think you will find that there are a couple
of modules on CPAN that will give you this info with very little scripting.

POP3.pm for POP3 mail servers for one.
There is also a whole host of Mail scripts in MailTools modules.

That's where I would look first (indeed that is where I did look first)
Plus it is generally much faster than Post and wait on this news group.



> Phillip
> phillip@javanet.com
> 
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/   Now offering spam-free web-based newsreading

-- 
Ian J. Garlick

ijg@csc.liv.ac.uk


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

Date: Tue, 28 Apr 1998 14:21:55 GMT
From: John Porter <jdporter@min.net>
Subject: Re: using perl as a script
Message-Id: <3545E766.46A2@min.net>

phillip@javanet.com wrote:
> 
> Basically what I was wondering is is it possible to make a perl script that
> runs and ever 3 ours or so (or even several specified times like 7:30, 9:00,
> 12:00 and so on) to count how many new messages in the mail spool, and then
> in turn send a message to a specified e-mail address formatted like this.
> "You currently have # new messages in your inbox." Or would I have to use
> another language such as C or something. And if I could do this how would I
> go about learning how to do this. I really would like to know how as soon as
> possible.

Perl is the best choice for this kind of applications.
Learn Perl. You'll be glad you did.

John Porter


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

Date: Tue, 28 Apr 1998 11:58:42 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
To: tchrist@mox.perl.com (Tom Christiansen)
Subject: Re: where are the examples in the newer (blue) camel book?
Message-Id: <8cu37egnud.fsf@gadget.cscaper.com>

>>>>> "Tom" == Tom Christiansen <tchrist@mox.perl.com> writes:

Tom> Randal pumps himself:
>> As I was shepherding the new Camel through the final months of writing
>> (as lead writer), I had to make some tradeoffs given the limited
>> resources we had.

Tom> Funny, I would have bet money that Larry was lead writer on the 
Tom> Camel.  And you know something?  I bet he would, too.

Tom> Larry's name isn't first on the author list out of some sense of
Tom> misplaced vanity.  It's because he did the most work, and also had
Tom> ultimate editorial control.

Tom> Please give him due credit next time.

Tom, stop making this a public battle.

I was *lead* writer on the project.  I did very little writing,
focussing my attention on project administration and herding the rest
of you.  I pitched the initial outline, created the timeline, decided
who was writing what chapters, in which order, and ultimately, *I* was
responsible for the timely delivery of the Camel-2 -- and thus I'm
also to "blame" for the task section and the real programs section
being omitted.

Certainly, Larry *wrote* the most of that book, and for that, he gets
his name first.  And I would certainly defer to his input on content
issues had there been a conflict (and there was none).  And had there
been a conflict, Steve Talbott and ORA would have looked to *me* first
to get it resolved.  Ask Steve or Tim on this one if you don't get it.
I have a mail folder with *every* message we did on the book as well,
and I can pull up ample evidence.

But stop rewriting history.  If you can't get this accurate, stop
saying it.  If you don't understand the definition or the
responsibilities of a "lead writer" in the technical writing industry,
stop using the term.  Hint: "it's not the guy with the most pages".

Tom, it's messages like these that make it appear that you hate me, or
that I hate you.  [To those watching in, I like Tom.  I think he's a
great guy, but he gets his history a little confused sometimes.]

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 126 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: 28 Apr 1998 10:08:39 -0400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: where are the examples in the newer (blue) camel book?
Message-Id: <ltbttmujh4.fsf@asfast.com>

Randal Schwartz <merlyn@stonehenge.com> writes:

> >>>>> "Tom" == Tom Christiansen <tchrist@mox.perl.com> writes:
> 
> Tom> Randal pumps himself:
> >> As I was shepherding the new Camel through the final months of writing
> >> (as lead writer), I had to make some tradeoffs given the limited
> >> resources we had.
> 
> Tom> Funny, I would have bet money that Larry was lead writer on the 
> Tom> Camel.  And you know something?  I bet he would, too.
> 
> Tom> Larry's name isn't first on the author list out of some sense of
> Tom> misplaced vanity.  It's because he did the most work, and also had
> Tom> ultimate editorial control.
> 
> Tom> Please give him due credit next time.
> 
> Tom, stop making this a public battle.
> 
> I was *lead* writer on the project.  [ ... ]
> 
> [ ... etc. etc. etc. ... ]

To *both* of you: is it really necessary to air this in public?

-- 
 Lloyd Zusman   ljz@asfast.com
 perl -e '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
 $t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
 $x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x\n"'


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

Date: 28 Apr 1998 14:22:50 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: where are the examples in the newer (blue) camel book?
Message-Id: <6i4onq$l8f$2@csnews.cs.colorado.edu>

Randal expounds:

:I was *lead* writer on the project.  I did very little writing,
:focussing my attention on project administration and herding the rest
:of you.  

BWAHAHAHAHA!

[Original set to Scott Adams for its obviously future inclusion
 in a Dilbert strip.]

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

    "Just because my fingers are in my ears doesn't mean I'm ignoring you."
    	--Larry Wall


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 2440
**************************************

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