[23087] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5308 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 1 18:10:40 2003

Date: Fri, 1 Aug 2003 15:10:09 -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           Fri, 1 Aug 2003     Volume: 10 Number: 5308

Today's topics:
    Re: No Question - Just Posting some Code I'm Proud of <nobull@mail.com>
    Re: No Question - Just Posting some Code I'm Proud of <skuo@mtwhitney.nsc.com>
    Re: No Question - Just Posting some Code I'm Proud of <usenet@dwall.fastmail.fm>
    Re: No Question - Just Posting some Code I'm Proud of <mikeflan@earthlink.net>
    Re: No Question - Just Posting some Code I'm Proud of (Tad McClellan)
    Re: No Question - Just Posting some Code I'm Proud of (Greg Bacon)
    Re: No Question - Just Posting some Code I'm Proud of (Greg Bacon)
    Re: No Question - Just Posting some Code I'm Proud of <krahnj@acm.org>
    Re: No Question - Just Posting some Code I'm Proud of <Juha.Laiho@iki.fi>
    Re: No Question - Just Posting some Code I'm Proud of <mikeflan@earthlink.net>
    Re: No Question - Just Posting some Code I'm Proud of <mikeflan@earthlink.net>
    Re: No Question - Just Posting some Code I'm Proud of <mikeflan@earthlink.net>
    Re: No Question - Just Posting some Code I'm Proud of <scriptyrich@yahoo.co.uk>
    Re: No Question - Just Posting some Code I'm Proud of (Greg Bacon)
    Re: question from perl noob <syscjm@gwu.edu>
    Re: question from perl noob <spamblock@junkmail.com>
    Re: Sorting question <bdonlan@bd-home-comp.no-ip.org>
    Re: splicing two arrays (matija)
    Re: splicing two arrays (matija)
    Re: splicing two arrays (matija)
    Re: splicing two arrays (Greg Bacon)
    Re: Web development and Perl 6 <cwilbur@mithril.chromatico.net>
    Re: Web development and Perl 6 <emschwar@ldl.fc.hp.com>
    Re: Web page with frames... <mgarrish@rogers.com>
    Re: Web page with frames... <emschwar@ldl.fc.hp.com>
    Re:  <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 01 Aug 2003 19:04:09 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: No Question - Just Posting some Code I'm Proud of
Message-Id: <u94r11dzl2.fsf@wcl-l.bham.ac.uk>

gbacon@hiwaay.net (Greg Bacon) writes:

>         for ($_->[-1]) {
>            s/\(historical\)/(hist)/g;
>            s/\(abandoned\)/(aban)/g;
 [snip]
>            s/Junior/Jr/g;
>            s/Mountain/Mtn/g;
>         }

Greg, I'm curious.  Is this use of for() in place of =~ something you
usually recommend?  This is the first time I can ever recall seeing
anyone else suggest it.  I'd concluded it was just my own personal
affectation. :-)

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Fri, 1 Aug 2003 11:34:24 -0700
From: Steven Kuo <skuo@mtwhitney.nsc.com>
Subject: Re: No Question - Just Posting some Code I'm Proud of
Message-Id: <Pine.GSO.4.21.0308011127130.20923-100000@mtwhitney.nsc.com>

On 1 Aug 2003, Brian McCauley wrote:

> gbacon@hiwaay.net (Greg Bacon) writes:
> 
> >         for ($_->[-1]) {
> >            s/\(historical\)/(hist)/g;
> >            s/\(abandoned\)/(aban)/g;
>  [snip]
> >            s/Junior/Jr/g;
> >            s/Mountain/Mtn/g;
> >         }
> 
> Greg, I'm curious.  Is this use of for() in place of =~ something you
> usually recommend?  This is the first time I can ever recall seeing
> anyone else suggest it.  I'd concluded it was just my own personal
> affectation. :-)
> 



Hope I'm not butting in on a personal conversation here...  

I've seen this style advocated by Nathan Torkington (aka gnat).  See
http://prometheus.frii.com/~gnat/yapc/2001-idioms/slide026.html

The last few slide of the presentation (pg 24+) contain similarly
interesting idioms.

-- 
Cheers,
Steven



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

Date: Fri, 01 Aug 2003 18:38:59 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: No Question - Just Posting some Code I'm Proud of
Message-Id: <Xns93CA9506D2E28dkwwashere@216.168.3.30>

Brian McCauley <nobull@mail.com> wrote:

> "David K. Wall" <usenet@dwall.fastmail.fm> writes:
> 
>> # I still use the 2-argument open() because I'm used to it :-)
>> open WPIN, "bran2.csv" or die "Can't create $file: $!";
> 
> I still think the error message could be improved :-(
> 
> open WPIN, "<bran2.csv" or die "Can't read bran2.csv: $!";

Oops.  I didn't even read the error message.  I plead guilty.

> The reason I dislike the 2-argument open is because I think it's

I meant to ask about that...

> illogical.  The file access mode and the file name are logically
> two orthogonal arguments.  Merging them never made much sense.  I
> used Perl for a long time before we got the 3-arg open and I
> always felt vaguely uncomforatble without it.

Reasonable.  Makes much more sense to me than something like scalar 
and list context did at first.  :-)
 
> I also dislike bareword filehandles because.... er... they're just
> not nice.  They are, in fact, symrefs! (Waves hands in air and
> runs off screeming).

Heh.  I hadn't thought of it that way.  I bet you REALLY hate the 
single-argument open. 

    $FILE = "/etc/motd";
    open FILE or die "can't open $FILE: $!";
    while (<FILE>) {
        # whatever
    }

At the very least you prompted me to reread perlopentut and the 
filehandle section of perldata.


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

Date: Fri, 01 Aug 2003 18:52:15 GMT
From: Mike Flannigan <mikeflan@earthlink.net>
Subject: Re: No Question - Just Posting some Code I'm Proud of
Message-Id: <3F2AB76B.99789539@earthlink.net>



Greg Bacon wrote:

> You were close.  See below for that and other improvements.  Note that
> mine inverts the order of the repeated locations in the output.

Hey, I appreciate all the work.  Your script certainly works, so
now I need to spend a few hours figuring it out.  To help me get
started, I'm going to ask just a few questions here, even before
I study it a whole lot.

I sure hope you did that array-of-arrays the other guys were
talking about, cause I want to learn that.  On a quick scan
I'm guessing you did.

If I don't attend a good Perl class, it's going to be years before
I start thinking Perl  :-)


>     #! /usr/local/bin/perl
>
>     # This file takes a CSV file,
>     # removes offending characters from the name fields
>     # and gives the 6 digit names field unique names.
>     # It also shortens the long name field a little.
>
>     use strict;
>     use warnings;
>
>     my $file = "bran2.csv";
>     my (@temp, $temp);
>
>     open WPIN, "<", $file or die "$0: open $file: $!";
>
>     while (<WPIN>) {
>        my $fields = 8;
>        my $count  = tr/,//;
>
>        if ($count != $fields-1) {
>           my $commas = $count == 1 ? "comma" : "commas";
>           warn "$0: $file:$.: $count $commas -- bad line?\n";
>        }

Nice feature that I didn't have.  Checks that only separators
have commas.  I'll figure out that
my $commas = $count == 1 ? "comma" : "commas";
line eventually.  It's just the ==1 that confuses me.


>
>        chomp;
>        push @temp => [ split /,/, $_, $fields ];
>     }
>
>     my %saw;
>     for (@temp) {
>         # Replace bad characters
>         $_->[2] =~ tr/()#.:\/?'&!//d;

What is "$_->[2]"?
I know $_ is the default array, but what does ->[2] do?
Oh wait - that just references the 2nd item in the array,
which is the 3rd column in the A of A, right?  Surely
it's something like that.


>
>         for ($_->[-1]) {
>            s/\(historical\)/(hist)/g;
>            s/\(abandoned\)/(aban)/g;
>            s/National Recreation Area/NRA/g;
>            s/Cemetery/Cem/g;
>
>            s/(\s*) \b North \b (\s*)/${1}N${2}/gx;
>            s/(\s*) \b South \b (\s*)/${1}S${2}/gx;
>            s/(\s*) \b East  \b (\s*)/${1}E${2}/gx;
>            s/(\s*) \b West  \b (\s*)/${1}W${2}/gx;
>
>            s/High School/HS/g;
>            s/Community College/College/g;
>            s/Campground/Campgr/g;
>            s/Post Office/PO/g;
>            s/Junior/Jr/g;
>            s/Mountain/Mtn/g;
>         }
>
>         if ($saw{ $_->[2] }++) {
>            $_->[2] =~ s{^ (.{0,4}) (..)? (.*) $} {
>                $1 . sprintf("%02d", $saw{ $_->[2] }) . $3
>            }ex;
>         }
>     }

Ouch, no good questions here.  I just need to dive into
hash stuff.  This is going to take a few days.


>
>     # print to the wpout.txt file
>     open WPOUT, ">", "WPout.txt" or die "$0: open WPout.txt: $!";
>
>     for (@temp) {
>         print WPOUT join("," => @$_), "\n";;
>     }
>
>     close WPOUT or warn "$0: close WPout.txt: $!";
>
>     __END__
>
> : My next step is to push $lat and $long together and
> : print a file of records that have the same $lat . $long
> : Probably pretty easy, but I may have to do brute force
> : way if I don't get smart on hashes real soon.
>
> The trick there will be defining what you mean by the same latitude
> and longitude.  If it's as simple as the text in their respective
> records being identical, then you could do the following in your
> processing loop:
>
>     push @{ $latlon{ $_->[3], $_->[4] } }, [ @$_ ];
>
> Then print matches with
>
>     for (keys %latlon) {
>         next unless @{ $latlon{$_} } > 1;
>
>         my($lat,$lon) = split /$;/o;
>         print "At $lat, $lon:\n";
>
>         for (@{ $latlon{$_} }) {
>             print "  - $_->[2]\n";
>         }
>     }
>

Yep, identical text is what I want.  I'm sure what you have will
work, I just haven't tried it yet.


Thanks so much.


David Wall's suggestion of the regex appears to be good.


>



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

Date: Fri, 1 Aug 2003 13:54:11 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: No Question - Just Posting some Code I'm Proud of
Message-Id: <slrnbildqj.4nv.tadmc@magna.augustmail.com>

Mike Flannigan <mikeflan@earthlink.net> wrote:
> 
> I'm just posting some code I wrote and asking for any advice
> you might have. 

> Keep in mind I hadn't even
> heard of Perl until about 50 days ago.


Your program is very nice, taking that into consideration.

Congratulations.


> Believe it or not, I'm kinda proud of this code.  


Hubris can be virtuous.    :-)

(have you read the very last bit of "perldoc perl" yet?)


> If anybody has any suggestions, I want them.


Stand by...


> use strict;
> use warnings;


I like you a lot already.


> my $file = "bran2.csv";


I prefer to use single quotes except when I _need_ one of the
two extra things that double quotes give you (interpolation
and backslash escapes).

It helps me ignore scanning long strings for interpolated variables
when I do debugging.

   my $file = 'bran2.csv';


> my (@temp, $temp);


1) what is $temp there for? I don't see you using it anywhere...

2) it is a red flag to me when I find myself choosing those
   particular names. Sometimes I really want an intermediate
   "temp" thingie, but most of the time I can rearrange things
   so as to not need it at all. And I can _always_ at least
   think up a more-descriptive name.

3) I almost never use the same name from multiple namespaces
   like that. It confuses me, and I'm already easily enough
   confused thank you very much.


> while (<WPIN>) {
>    my ($wp1, $deg1, $name1, $lat, $long, $date, $time, $name2) = split
> /,/, $_, 8;
>    push @temp, ($wp1, $deg1, $name1, $lat, $long, $date, $time, $name2);
> 
> }


There is a whole bunch of temp vars that you do not need:

   push @fields, split  /,/, $_, 8;  # "fields" is better than "temp"

you might even like to replace the entire while block above with:

   push @fields, split( /,/, $_, 8 ) while <WPIN>;




>     $temp[$turn+5] =~ s/\(historical\)/\(hist\)/g;
>     $temp[$turn+5] =~ s/\(abandoned\)/\(aban\)/g;
>     $temp[$turn+5] =~ s/National Recreation Area/NRA/g;


Typing essentially the same thing over and over is yet another
red flag that often indicates that there might be some better way.

Using the aliasing feature of foreach() is handy for that,
even when used with a one-element list:

   foreach ( $temp[$turn+5] ) {
      s/\(historical\)/\(hist\)/g;  # changes are made back in $temp[$turn+5]
      s/\(abandoned\)/\(aban\)/g;
      s/National Recreation Area/NRA/g;
      # ...
   }



>         substr ($temp[$turn-8], 4, 2, "0$rep") if ($rep < 10);
>         substr ($temp[$turn-8], 4, 2, "$rep")if ($rep > 9);

Treating strings as if they were numbers is a path to madness.

Do you _want_

   $rep = -1;

to become

   $rep = '0-1';

??

A negative number of repetitions isn't going to happen of course,
but if you get used to using such false cleverness, it will
bite you someday.

Use sprintf() to zero-pad numbers:

   $rep = sprintf "%02d", $rep;



>     if ($printout =~ /\n$/) {print WPOUT ("$printout")}
                                            ^         ^ useless quotes

See this Perl FAQ:

   What's wrong with always quoting "$vars"?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Fri, 01 Aug 2003 19:11:51 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: No Question - Just Posting some Code I'm Proud of
Message-Id: <vilernqvip2804@corp.supernews.com>

In article <u94r11dzl2.fsf@wcl-l.bham.ac.uk>,
    Brian McCauley  <nobull@mail.com> wrote:

: gbacon@hiwaay.net (Greg Bacon) writes:
: 
: >         for ($_->[-1]) {
: >            s/\(historical\)/(hist)/g;
: >            s/\(abandoned\)/(aban)/g;
:  [snip]
: >            s/Junior/Jr/g;
: >            s/Mountain/Mtn/g;
: >         }
: 
: Greg, I'm curious.  Is this use of for() in place of =~ something you
: usually recommend?  This is the first time I can ever recall seeing
: anyone else suggest it.  I'd concluded it was just my own personal
: affectation. :-)

It's not just in place of =~ (although that is a nice benefit with
operators that default to $_) but for aliasing in general.  Further down
the thread, someone cited gnat, and I picked up this idiom (or trick or
whatever you want to call it) from tchrist.  When I write code, I like
to eliminate repetition as much as possible.  (XPers call this Once And
Only Once.)

Perl 6 will have a general aliasing mechanism that I could have used
to alias the fields of interest rather than big, ugly dereferencing
of array indices.

Greg
-- 
The glory and mystery of global commerce has been observed for thousands of
years, but it is no less wondrous to see in our everyday lives how it is
that people pursuing their self-interest in peace can only promote the
interest of society.                -- Lew Rockwell


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

Date: Fri, 01 Aug 2003 19:14:49 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: No Question - Just Posting some Code I'm Proud of
Message-Id: <vilf19if2n8354@corp.supernews.com>

In article <Xns93CA8BD544059dkwwashere@216.168.3.30>,
    David K. Wall <usenet@dwall.fastmail.fm> wrote:

: [...]
: 
: I don't see a need to remember the spaces since you're not really
: doing anything with them.

Yes, it looks nicer your way.

Greg
-- 
The price of empire is terror.  The price of occupation is terror.  The
price of interventionism is terror.  As Barry Goldwater used to say, it
is as simple as that.
    -- Pat Buchanan


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

Date: Fri, 01 Aug 2003 19:19:56 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: No Question - Just Posting some Code I'm Proud of
Message-Id: <3F2ABD9D.9FFEF23E@acm.org>

Mike Flannigan wrote:
> 
> I'm just posting some code I wrote and asking for any advice
> you might have.

Ok, you asked for it.  :-)


> It may not work perfectly, but it's got me
> fooled into thinking it does.  Keep in mind I hadn't even
> heard of Perl until about 50 days ago.
> 
> Believe it or not, I'm kinda proud of this code.  That's only
> because I know how much improved it is over my first
> draft.  If anybody has any suggestions, I want them.

It looks pretty good for someone with only 50 days experience.


> # This file takes a CSV file,
> # removes offending characters from the name fields
> # and gives the 6 digit names field unique names.
> # It also shortens the long name field a little.
> 
> use strict;
> use warnings;
> 
> my $rep = 1;
> my $file = "bran2.csv";
> my (@temp, $temp);
> open WPIN,"<$file" or die "Can't create $file: $!";
                                   ^^^^^^
Opening a file for reading does not "create" the file, it has to already exist.


> while (<WPIN>) {
>    my ($wp1, $deg1, $name1, $lat, $long, $date, $time, $name2) = split
> /,/, $_, 8;
>    push @temp, ($wp1, $deg1, $name1, $lat, $long, $date, $time, $name2);
> }

You usually don't need to load the entire file into memory unless you are
modifying the original file which you are not doing.  You are separating
the records and fields and putting all the fields into one array while it
might make more sense to separate the fields in the next for loop or use
an array of arrays to hold the records and fields.


> # Replace bad characters
> for (my $turn = 10; $turn <= $#temp; $turn+=8) {
>     $temp[$turn] =~ tr/()#.:\/?'&!//d;
>     $temp[$turn+5] =~ s/\(historical\)/\(hist\)/g;
>     $temp[$turn+5] =~ s/\(abandoned\)/\(aban\)/g;
>     $temp[$turn+5] =~ s/National Recreation Area/NRA/g;
>     $temp[$turn+5] =~ s/Cemetery/Cem/g;
>     $temp[$turn+5] =~ s/ North / N /g;
>     $temp[$turn+5] =~ s/ North$/ N/g;
>     $temp[$turn+5] =~ s/^North /N /g;

You can use the \b word boundary zero width assertion to simplify that.

      $temp[$turn+5] =~ s/\bNorth\b/N/g;


>     $temp[$turn+5] =~ s/ South / S /g;
>     $temp[$turn+5] =~ s/ South$/ S/g;
>     $temp[$turn+5] =~ s/^South /S /g;
>     $temp[$turn+5] =~ s/ East / E /g;
>     $temp[$turn+5] =~ s/ East$/ E/g;
>     $temp[$turn+5] =~ s/^East /E /g;
>     $temp[$turn+5] =~ s/ West / W /g;
>     $temp[$turn+5] =~ s/ West$/ W/g;
>     $temp[$turn+5] =~ s/^West /W /g;
>     $temp[$turn+5] =~ s/High School/HS/g;
>     $temp[$turn+5] =~ s/Community College/College/g;
>     $temp[$turn+5] =~ s/Campground/Campgr/g;
>     $temp[$turn+5] =~ s/Post Office/PO/g;
>     $temp[$turn+5] =~ s/Junior/Jr/g;
>     $temp[$turn+5] =~ s/Mountain/Mtn/g;

If you have to modify a single scalar multiple times you can for loop to simplify it.

for ( $scalar ) {
    s/1//;
    s/2//;
    s/etc.//;
    }


> }
> 
> # Rename duplicate name1's

You should declare $rep here instead of way up there at the beginning.

my $rep = 1;

> for (my $turn = 10; $turn <= $#temp; $turn+=8) {
>     next if ($temp[$turn] ne $temp[$turn-8]);
>     $rep++;
>     if (length $temp[$turn-8] > 3){
>         substr ($temp[$turn-8], 4, 2, "0$rep") if ($rep < 10);
>         substr ($temp[$turn-8], 4, 2, "$rep")if ($rep > 9);

You can use sprintf to add leading zeros.

          substr( $temp[ $turn - 8 ], -2 ) = sprintf '%02d', $rep;


>         $rep = 1 if ($temp[$turn] ne $temp[$turn+8]);
>     }
>     else {
>         $temp[$turn-8] =~ s/^(.{0,4})$/${1}0$rep/ if ($rep < 10);
>         $temp[$turn-8] =~ s/^(.{0,4})$/${1}$rep/ if ($rep > 9);

You could use concatenation to simplify that.

          $temp[ $turn - 8 ] .= sprintf '%02d', $rep;


>         $rep = 1 if ($temp[$turn] ne $temp[$turn+8]);
>     }
> }
> 
> # print to the wpout.txt file
> open WPOUT,">WPout.txt" or die "Can't create WPout.txt: $!";
> 
> foreach my $printout ( @temp ) {
>     if ($printout =~ /\n$/) {print WPOUT ("$printout")}
>     else {print WPOUT ("$printout,")}
> }
> 
> close (WPOUT);
> 
> __END__
> 
> If anybody feels like messing with this, here is some
> good data to put in 'bran2.csv' to test it:
> 
> [snip data]


Here is one way to do it using an array of arrays:

#!/usr/bin/perl

# This file takes a CSV file,
# removes offending characters from the name fields
# and gives the 6 digit names field unique names.
# It also shortens the long name field a little.

use strict;
use warnings;

# use names instead of numbers to access array fields
use constant NAME1 => 2;
use constant NAME2 => 7;

my $old_file = 'test11.txt';
my $new_file = 'test13.txt';

open WPIN, $old_file or die "Cannot open $old_file: $!";
my @data = map [ split /,/, $_, 8 ], <WPIN>;
close WPIN;

# Replace bad characters
for my $line ( @data ) {
    $line->[ NAME1 ] =~ tr|()#.:/?'&!||d;

    for ( $line->[ NAME2 ] ) {
        s/\(historical\)/\(hist\)/g;
        s/\(abandoned\)/\(aban\)/g;
        s/National Recreation Area/NRA/g;
        s/Cemetery/Cem/g;
        s/\bNorth\b/N/g;
        s/\bSouth\b/S/g;
        s/\bEast\b/E/g;
        s/\bWest\b/W/g;
        s/High School/HS/g;
        s/Community College/College/g;
        s/Campground/Campgr/g;
        s/Post Office/PO/g;
        s/Junior/Jr/g;
        s/Mountain/Mtn/g;
        }
    }

# Rename duplicate name1's
my $rep = 1;
for my $line ( 1 .. $#data ) {
    next if $data[ $line ][ NAME1 ] ne $data[ $line - 1 ][ NAME1 ];
    $rep++;
    if ( length $data[ $line - 1 ][ NAME1 ] > 3 ) {
        substr( $data[ $line - 1 ][ NAME1 ], -2 ) = sprintf '%02d', $rep;
        }
    else {
        $data[ $line - 1 ][ NAME1 ] .= sprintf '%02d', $rep;
        }
    $rep = 1 if $data[ $line ][ NAME1 ] ne $data[ $line + 1 ][ NAME1 ];
    }

# print to the wpout.txt file
open WPOUT, ">$new_file" or die "Cannot open $new_file: $!";
print WPOUT join ',', @$_ for @data;
close WPOUT;

__END__



John
-- 
use Perl;
program
fulfillment


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

Date: Fri, 01 Aug 2003 19:22:01 GMT
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: No Question - Just Posting some Code I'm Proud of
Message-Id: <bgeejg$ohg$1@ichaos.ichaos-int>

Mike Flannigan <mikeflan@earthlink.net> said:
>Greg Bacon wrote:
>>        if ($count != $fields-1) {
>>           my $commas = $count == 1 ? "comma" : "commas";
>>           warn "$0: $file:$.: $count $commas -- bad line?\n";
>>        }
>
>Nice feature that I didn't have.  Checks that only separators
>have commas.  I'll figure out that
>my $commas = $count == 1 ? "comma" : "commas";
>line eventually.  It's just the ==1 that confuses me.

With this I can help you; the line

my $commas = $count == 1 ? "comma" : "commas";

is just a shorthand for writing

my $commas;
if ($count == 1) {
	$commas="comma";
} else {
	$commas="commas";
}

So, assign $commas to singular or plural form depending on the amount of
commas seen. Even though I often advocate against use of the ?: -construct,
here I admit it is the more readable form.
-- 
Wolf  a.k.a.  Juha Laiho     Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
         PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)


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

Date: Fri, 01 Aug 2003 19:36:51 GMT
From: Mike Flannigan <mikeflan@earthlink.net>
Subject: Re: No Question - Just Posting some Code I'm Proud of
Message-Id: <3F2AC1DF.C114312F@earthlink.net>



Tad McClellan wrote:

>
> Hubris can be virtuous.    :-)
>
> (have you read the very last bit of "perldoc perl" yet?)
>

I have now.

> I prefer to use single quotes except when I _need_ one of the
> two extra things that double quotes give you (interpolation
> and backslash escapes).
>
> It helps me ignore scanning long strings for interpolated variables
> when I do debugging.
>
>    my $file = 'bran2.csv';

Done.  Thanks alot.


>
> > my (@temp, $temp);
>
> 1) what is $temp there for? I don't see you using it anywhere...
>
> 2) it is a red flag to me when I find myself choosing those
>    particular names. Sometimes I really want an intermediate
>    "temp" thingie, but most of the time I can rearrange things
>    so as to not need it at all. And I can _always_ at least
>    think up a more-descriptive name.
>
> 3) I almost never use the same name from multiple namespaces
>    like that. It confuses me, and I'm already easily enough
>    confused thank you very much.

I got rid of $temp and changed temp to working everywhere else.
To answer your question, I was following the lead of somebody
else.  I saw them do it, so I did too.

Good thing they didn't jump off a cliff  :-)


> > while (<WPIN>) {
> >    my ($wp1, $deg1, $name1, $lat, $long, $date, $time, $name2) = split
> > /,/, $_, 8;
> >    push @temp, ($wp1, $deg1, $name1, $lat, $long, $date, $time, $name2);
> >
> > }
>
> There is a whole bunch of temp vars that you do not need:
>
>    push @fields, split  /,/, $_, 8;  # "fields" is better than "temp"
>
> you might even like to replace the entire while block above with:
>
>    push @fields, split( /,/, $_, 8 ) while <WPIN>;

Pretty cool.  I like it.


>
>
> >     $temp[$turn+5] =~ s/\(historical\)/\(hist\)/g;
> >     $temp[$turn+5] =~ s/\(abandoned\)/\(aban\)/g;
> >     $temp[$turn+5] =~ s/National Recreation Area/NRA/g;
>
> Typing essentially the same thing over and over is yet another
> red flag that often indicates that there might be some better way.
>
> Using the aliasing feature of foreach() is handy for that,
> even when used with a one-element list:
>
>    foreach ( $temp[$turn+5] ) {
>       s/\(historical\)/\(hist\)/g;  # changes are made back in $temp[$turn+5]
>       s/\(abandoned\)/\(aban\)/g;
>       s/National Recreation Area/NRA/g;
>       # ...
>    }

Thanks.  Great idea.


>
> >         substr ($temp[$turn-8], 4, 2, "0$rep") if ($rep < 10);
> >         substr ($temp[$turn-8], 4, 2, "$rep")if ($rep > 9);
>
> Treating strings as if they were numbers is a path to madness.
>
> Do you _want_
>
>    $rep = -1;
>
> to become
>
>    $rep = '0-1';
>
> ??
>
> A negative number of repetitions isn't going to happen of course,
> but if you get used to using such false cleverness, it will
> bite you someday.
>

I guess you are saying hard code it with functions.  If not,
then I'm not up to you yet in that area.


>
> Use sprintf() to zero-pad numbers:
>
>    $rep = sprintf "%02d", $rep;
>
> >     if ($printout =~ /\n$/) {print WPOUT ("$printout")}
>                                             ^         ^ useless quotes
>
> See this Perl FAQ:
>
>    What's wrong with always quoting "$vars"?
>

I see.  Thanks for the warning.



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

Date: Fri, 01 Aug 2003 19:57:59 GMT
From: Mike Flannigan <mikeflan@earthlink.net>
Subject: Re: No Question - Just Posting some Code I'm Proud of
Message-Id: <3F2AC6D3.4808CA8D@earthlink.net>


Juha Laiho wrote:

> With this I can help you; the line
>
> my $commas = $count == 1 ? "comma" : "commas";
>
> is just a shorthand for writing
>
> my $commas;
> if ($count == 1) {
>         $commas="comma";
> } else {
>         $commas="commas";
> }

OK.  I was confused partly because I was thinking
$commas could basically never be less than 7.  That was
faulty thinking on my part.  It certainly could be.

This is the 2nd time this expansion of script has helped
me understand an expression.  The first time was with
the union, intersection, difference example in the perlfaq.
The line was:
push @{ $count{$element} > 1 ? \@intersection : \@difference }, $element;

Wouldn't it be nice if somebody wrote a perl module
that would break one liners down to easily readable
script  :-)


Mike




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

Date: Fri, 01 Aug 2003 20:32:45 GMT
From: Mike Flannigan <mikeflan@earthlink.net>
Subject: Re: No Question - Just Posting some Code I'm Proud of
Message-Id: <3F2ACEF9.EAB4FFF0@earthlink.net>



"John W. Krahn" wrote:

> >         $temp[$turn-8] =~ s/^(.{0,4})$/${1}0$rep/ if ($rep < 10);
> >         $temp[$turn-8] =~ s/^(.{0,4})$/${1}$rep/ if ($rep > 9);
>
> You could use concatenation to simplify that.
>
>           $temp[ $turn - 8 ] .= sprintf '%02d', $rep;

I'm kinda surprised that worked, but it did.  I knew the sprintf
part would work, but the .= I was wary of.


> use strict;
> use warnings;
>
> # use names instead of numbers to access array fields
> use constant NAME1 => 2;
> use constant NAME2 => 7;
>
> my $old_file = 'test11.txt';
> my $new_file = 'test13.txt';
>
> open WPIN, $old_file or die "Cannot open $old_file: $!";
> my @data = map [ split /,/, $_, 8 ], <WPIN>;
> close WPIN;
>
> # Replace bad characters
> for my $line ( @data ) {
>     $line->[ NAME1 ] =~ tr|()#.:/?'&!||d;
>
>     for ( $line->[ NAME2 ] ) {
>         s/\(historical\)/\(hist\)/g;
>         s/\(abandoned\)/\(aban\)/g;
>         s/National Recreation Area/NRA/g;
>         s/Cemetery/Cem/g;
>         s/\bNorth\b/N/g;
>         s/\bSouth\b/S/g;
>         s/\bEast\b/E/g;
>         s/\bWest\b/W/g;
>         s/High School/HS/g;
>         s/Community College/College/g;
>         s/Campground/Campgr/g;
>         s/Post Office/PO/g;
>         s/Junior/Jr/g;
>         s/Mountain/Mtn/g;
>         }
>     }
>
> # Rename duplicate name1's
> my $rep = 1;
> for my $line ( 1 .. $#data ) {
>     next if $data[ $line ][ NAME1 ] ne $data[ $line - 1 ][ NAME1 ];
>     $rep++;
>     if ( length $data[ $line - 1 ][ NAME1 ] > 3 ) {
>         substr( $data[ $line - 1 ][ NAME1 ], -2 ) = sprintf '%02d', $rep;
>         }
>     else {
>         $data[ $line - 1 ][ NAME1 ] .= sprintf '%02d', $rep;
>         }
>     $rep = 1 if $data[ $line ][ NAME1 ] ne $data[ $line + 1 ][ NAME1 ];
>     }
>
> # print to the wpout.txt file
> open WPOUT, ">$new_file" or die "Cannot open $new_file: $!";
> print WPOUT join ',', @$_ for @data;
> close WPOUT;
>
> __END__
>

Thanks.  That is going to help me figure of the A of A routine.



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

Date: Fri, 01 Aug 2003 21:58:33 +0000
From: Rich <scriptyrich@yahoo.co.uk>
Subject: Re: No Question - Just Posting some Code I'm Proud of
Message-Id: <bgek6s$c1s$1@news8.svr.pol.co.uk>

Mike Flannigan wrote:

> # This file takes a CSV file,
> # removes offending characters from the name fields
> # and gives the 6 digit names field unique names.
> # It also shortens the long name field a little.
> 
> use strict;
> use warnings;
> 
> my $rep = 1;
> my $file = "bran2.csv";
> my (@temp, $temp);
> open WPIN,"<$file" or die "Can't create $file: $!";
> 
> while (<WPIN>) {
>    my ($wp1, $deg1, $name1, $lat, $long, $date, $time, $name2) = split
> /,/, $_, 8;

Hi Mike

You've already got a lot of useful info from other folks, but one thing
stands out - if you're really parsing a CSV file, you've got to assume you
may get entries such as:

  value1,"val,ue2",value3,""val,ue4""

If you use split /,/ you would get this unlovely list of strings:

  value1
  "val
  ue2"
  value3
  ""val
  ue4""

When you would have expected:

  value1
  val,ue2
  value3
  "val,ue4"

So, always use modules such as Text::CSV for parsing CSV files, since they
handle a number of subtle issues that might not be immediately obvious, but
will bite you at some point. 

I do appreciate that this probably won't happen in the case you're outlining
here though.

Cheers,
-- 
Rich
scriptyrich@yahoo.co.uk


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

Date: Fri, 01 Aug 2003 21:15:44 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: No Question - Just Posting some Code I'm Proud of
Message-Id: <vilm40t7vh3pa3@corp.supernews.com>

In article <3F2AB76B.99789539@earthlink.net>,
    Mike Flannigan  <mikeflan@earthlink.net> wrote:

: Greg Bacon wrote:
: 
: [...]
:
: I sure hope you did that array-of-arrays the other guys were
: talking about, cause I want to learn that.  On a quick scan
: I'm guessing you did.

Yes.  I'm building an array of arrays with

    push @temp => [ split /,/, $_, $fields ];

This makes each slot in @temp be a reference to an array whose thingy
(Perl parlance for the referent or, to be imprecise, what a reference
"points to") is an array containing the fields from some record in your
input.

As you gain more experience with references, the underlying mechanics
become transparent in your mental model, so you'll begin thinking in
terms of records instead of "let's see, I have a reference to an array
containing the fields from some record".  This is what psychologists
call chunking.

: [...]
:
: Greg Bacon wrote:
:
: >     while (<WPIN>) {
: >        my $fields = 8;
: >        my $count  = tr/,//;
: >
: >        if ($count != $fields-1) {
: >           my $commas = $count == 1 ? "comma" : "commas";
: >           warn "$0: $file:$.: $count $commas -- bad line?\n";
: >        }
: 
: Nice feature that I didn't have.  Checks that only separators
: have commas.

No, I'm making sure that each input record is well-formed, i.e., that
each has seven commas and, thus, eight fields.

:               I'll figure out that
: my $commas = $count == 1 ? "comma" : "commas";
: line eventually.  It's just the ==1 that confuses me.

There I'm being, as the Aussies say, a pedantic git.  I'm making the
noun agree with the number: 1 comma but 2 commas.

: >     for (@temp) {
: >         # Replace bad characters
: >         $_->[2] =~ tr/()#.:\/?'&!//d;
: 
: What is "$_->[2]"?
: I know $_ is the default array, but what does ->[2] do?
: Oh wait - that just references the 2nd item in the array,
: which is the 3rd column in the A of A, right?  Surely
: it's something like that.

Right.  At the first iteration, we've effectively done this

    $_ = [ 'Datum', 'WGS84', 'WGS84', 0, 0, 0, 0, 0 ];

which means $_ is a reference to an array with those values.  An 
equivalent way to write this (you'll see it written the following way
much more often) is

    $_ = [ qw/ Datum WGS84 WGS84 0 0 0 0 0 / ];

Naked square brackets are the anonymous array reference constructor
(see the perlref manpage), and qw// splits on whitespace (see the
perlop manpage).

Given that value of $_, $_->[2] means the value at index 2 (i.e., the
third value assuming $[ is 0 -- which it almost always is) of $_'s
thingy: 'WGS84' in this case.  The perlref manpage explains all this.

: >         if ($saw{ $_->[2] }++) {
: >            $_->[2] =~ s{^ (.{0,4}) (..)? (.*) $} {
: >                $1 . sprintf("%02d", $saw{ $_->[2] }) . $3
: >            }ex;
: >         }
: 
: Ouch, no good questions here.  I just need to dive into
: hash stuff.  This is going to take a few days.

That code keeps up with duplicates.  You weren't explicit about how
duplicates are supposed to be renamed, so that's my best guess at a
general approach (i.e., one that works for names of any length).

$saw{ $_->[2] }++ will only be true when the current record's name
is one we've already seen.  $_->[2] is the third column, remember,
so at any time, $saw{$name} tells us the number of times we've seen
$name.

In the substitution, I'm inserting the number.  The sprintf "%02d"
saves you from doing the zero padding by hand as you did in your
code.  As I said earlier, doing it this way produces different
output, so you may need to play with the code.

: [...]
: 
: Yep, identical text is what I want.  I'm sure what you have will
: work, I just haven't tried it yet.

I tried it quickly by doubling the last line of the input, and I
saw the result I expected.  Read the perlvar manpage to learn why
I'm splitting on the $; magic variable's value.

: David Wall's suggestion of the regex appears to be good.

I agree.

Hope this helps,
Greg
-- 
Between a balanced republic and a democracy, the difference is like that
between order and chaos.
    -- Chief Justice John Marshall


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

Date: Fri, 01 Aug 2003 14:42:05 -0400
From: Chris Mattern <syscjm@gwu.edu>
Subject: Re: question from perl noob
Message-Id: <3F2AB47D.3000901@gwu.edu>

boblehue wrote:
> Hi and tnx Garry!
> 
> I tryed your code but it did not give me the result i wanted.
> 
> With your code : 29498.282425,
> 
> With origninal code : 29498.2824251624
> 
> Result i'm looking for : 29498.28
> 
> I get closer with your code but not quite!
> 
> And i'm suposed to use the INT operator, multiplication, and division.
> 
And just why are you limited to those functions?

I smell homework.

                Chris Mattern



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

Date: Fri, 1 Aug 2003 14:59:37 -0700
From: "David Oswald" <spamblock@junkmail.com>
Subject: Re: question from perl noob
Message-Id: <vilop4q8k5sb47@corp.supernews.com>


"boblehue" <boblehue@online.no> wrote in message
news:NdpWa.17188$Hb.287897@news4.e.nsc.no...
> Hi
>
> I'm tryng to learn a little perl and have a problems with decimal's.
>
> This asignment is to rewrite this code to not print more the two decimals
> with the use of INT operator, multiplication, and division.
>

This takes me back to week one of high school Computer Science on the old
Franklin Ace 1000's (Apple II+ clones).

If we were doing it in BASIC (why not?), here's an example snippet that
should illustrate what your teacher hoped you would figure out on your own.

let X = 1234.56789
print "Here's the wrong answer: ";X
X = int ( X * 100 ) / 100
print "Here's the right answer: ";X
end


The output of the above example will be:
Here's the wrong answer: 1234.56789
Here's the right answer: 1234.56

What you did:
Multiply by one hundred, thus shifting the decimal place to the right two
places.
Chop off everything to the right of the decimal place.
Divide by 100, moving the decimal place back to the left two places, where
it originally was.

Now in Perl:

my $x = 1234.56789;
print "Here is the wrong answer: $x\n";
$x = int ( $x * 100 ) / 100 ;
print "Here is the right answer: $x\n";

Remembering back to my old BASIC days, the most common use of int() was in
conjunction with rnd(1), in which case you could derive a random number
between zero and whatever you need as follows:

let X = int(rnd(0)*500)+1
rem X is now a pseudorandom number between 1 and 500.

Why am I telling you all this in BASIC?  I guess just for fun, and because
your question reminds me of Mr. Secrest's High School Comp. Sci. class in
1985.  ...and also because the other day I was using Perl to write a BASIC
intrepreter just to see if I could do it.  ...didn't bother finishing, I was
mostly just interested in thinking through the process of using hashes to
hold BASIC lexicon, hashes for namespace, and thinking through how to parse
it all.  It was a fun exercise, but nothing more because first, someone
already wrote a perfectly good BASIC module for Perl, and second, who would
want to use a perfectly good language (Perl) to mimick a perfectly lousy one
(BASIC)?

Dave




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

Date: Fri, 01 Aug 2003 14:02:37 -0400
From: bd <bdonlan@bd-home-comp.no-ip.org>
Subject: Re: Sorting question
Message-Id: <pan.2003.08.01.18.02.35.741255@bd-home-comp.no-ip.org>

On Thu, 31 Jul 2003 19:34:17 +0800, Derek Fountain wrote:

> I have a set of names, each of which has an associated size value. I want to
> list these names in size order.
> 
> The obvious way is to create a hash where the sizes are the keys and the
> associated names are the values, then sort the keys. The problem with that
> is that in my data two names might have the same size, so one would replace
> the other in my hash.
> 
> How do I do this?

Other way. Make a hash %foo with the name as the key and the size as the
value, then:
foreach my $name (sort { $foo{$a} <=> $foo{$b} } keys %foo) {
  # Stuff
}

-- 
Freenet distribution not available
The first requisite for immortality is death.
		-- Stanislaw Lem



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

Date: 1 Aug 2003 13:52:47 -0700
From: mpapec@yahoo.com (matija)
Subject: Re: splicing two arrays
Message-Id: <ab28ebc3.0308011252.6b31a614@posting.google.com>

On Thu, 31 Jul 2003 18:14:14 GMT, Uri Guttman <uri@stemsystems.com> wrote:
>  MP> Now, simple grep does a right thing,
>  MP> @arr1 = grep exists $h{$_}, @arr1;
>
>  MP> but it leaves me with @arr2 where corresponding elements to @arr1
>  MP> should also be removed(when removing n-th from @arr1, remove n-th
>  MP> from @arr2 too).
>
>grep on the indexes and not on the values. then slice both arrays.
>
>my @indexes = grep $h{$arr1[$_]}, @arr1 ;
>
>@arr1 = @arr1[@indexes] ;
>@arr2 = @arr2[@indexes] ;

Tnx, it appears that perl6 will handle this in its own way.


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

Date: 1 Aug 2003 13:53:48 -0700
From: mpapec@yahoo.com (matija)
Subject: Re: splicing two arrays
Message-Id: <ab28ebc3.0308011253.ee3773b@posting.google.com>

On Thu, 31 Jul 2003 18:34:36 GMT, Steve Grazzini <grazz@pobox.com>
wrote:

>> I ended up with simultaneous array rotation and I'm curios
>> now if there is a better way? :)
>
>How about:
>
>  for my $i (0..$#arr1) {
>    next unless exists $h{$arr1[$i]};
>    splice @arr1, $i, 1;
>    splice @arr2, $i, 1;
>  }

Unfortunately this doesn't work as expected as arrays continuously
shrink so when $i reaches initial $#arr1, real @arr1 is far smaller.

>Or is that the "simultaneous rotation"?

Nope, something like
 push @arr1, (shift @arr1);
 push @arr2, (shift @arr2);


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

Date: 1 Aug 2003 13:55:25 -0700
From: mpapec@yahoo.com (matija)
Subject: Re: splicing two arrays
Message-Id: <ab28ebc3.0308011255.3a9808c0@posting.google.com>

On Thu, 31 Jul 2003 18:34:28 -0000, gbacon@hiwaay.net (Greg Bacon)
wrote:
>: Now, simple grep does a right thing,
>: @arr1 = grep exists $h{$_}, @arr1;
>
>I can do that in one line!
>
>    @$_ = grep exists $h{$_}, @$_ for \(@arr1, @arr2);
>
>Whee!

Nice, but not exactly what I need.
btw how about,

for (undef,
  grep exists $h{ $_->[0] },
  map [ $arr1[$_], $arr2[$_] ], 0..$#arr1)
{
  @arr1 = @arr2 = (), next if !$_;
  push @arr1, $_->[0];
  push @arr2, $_->[1];
}

Doesn't use additional vars but it's kinda slow.

>: but it leaves me with @arr2 where corresponding elements to @arr1
>: should also be removed(when removing n-th from @arr1, remove n-th
>: from @arr2 too).
>
>Oh, that's a different problem.  Is there a reason you're using
parallel
>arrays rather than a list of lists?

I have no real reason except I started coding in such way with two
arrays (@arr1 has cgi-form names and @arr2 corresponding sql column
names).


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

Date: Fri, 01 Aug 2003 21:21:51 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: splicing two arrays
Message-Id: <vilmffh6db344c@corp.supernews.com>

In article <ab28ebc3.0308011255.3a9808c0@posting.google.com>,
    matija <mpapec@yahoo.com> wrote:

: On Thu, 31 Jul 2003 18:34:28 -0000, gbacon@hiwaay.net (Greg Bacon)
: wrote:
:
: [...]
:
: >Oh, that's a different problem.  Is there a reason you're using
: >parallel arrays rather than a list of lists?
: 
: I have no real reason except I started coding in such way with two
: arrays (@arr1 has cgi-form names and @arr2 corresponding sql column
: names).

When I find myself starting to write parallel arrays, I almost always
combine them to make arrays of arrays.  See the perllol manpage for the
mechanics.  Doing it that way makes eliminating corresponding elements
trivial.

Greg
-- 
The right most valued by all civilized men is the right to be left alone.
    -- Justice Louis Brandeis


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

Date: Fri, 01 Aug 2003 18:10:58 GMT
From: Charlton Wilbur <cwilbur@mithril.chromatico.net>
Subject: Re: Web development and Perl 6
Message-Id: <8765lhtfxw.fsf@mithril.chromatico.net>

"Alan J. Flavell" <flavell@mail.cern.ch> writes:

> I see several "fundamental" problems (from elementary problem solving
> techniques right up to principles of reliable software engineering),
> but very few of them are specific to Perl.  The only reason that they
> _seem_ specific to Perl is often that the novice has not yet noticed
> that CGI is not identical to Perl, nor vice versa - or thinks that
> their elementary HTML problem ipso facto becomes a Perl problem when
> they use Perl to generate their HTML.  Sigh.

It's entirely possible for a newbie programmer to have problems that
stem from an incomplete or incorrect understanding of Perl, and these
can properly be addressed here -- though if it's a serious
misunderstanding, there's only so much that can be done on Usenet.  

It's also possible for a newbie programmer to have problems that stem
from an incomplete or incorrect understanding of whatever protocol
they're trying to use, be it CGI, HTML, XML, or the like.  This
*might* be properly addressed here, but there are better fora for it.  

> > In neither of these cases is an exchange on
> > Usenet likely to be all that helpful.
> 
> There's certainly truth in what you say.  But what to do?  If
> someone with at least a vague competence doesn't step up to the
> plate, then there's a sheer endless supply of clue-impaired dabblers
> who are only too ready to fill the vacuum with their own confused
> answers.  If those are the only answers that get seen, it's
> understandable that the newcomer would believe them - and in many
> cases, go forth and propagate them elsewhere.  It's very
> frustrating.

Right - which is why the appropriate behavior is to post guidelines
(see Tad's posting guidelines) and for clueful people to correct
incorrect posts and direct posters of off-topic questions elsewhere.
The original poster who asked the off-topic question feels insulted?
Too bad.  The person who posted the incorrect reply feels hurt?  Hard
cheese.  Life sucks; wear a helmet.

And in those cases in which Usenet is not providing the answers and
support that the querent wants, it's *his* (or *her*) responsibility,
not anyone else's, to realize this and seek out other forms of
support, be they books, classes, tutoring, or a programmer/mentor on
retainer.

Charlton


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

Date: Fri, 01 Aug 2003 12:16:56 -0600
From: Eric Schwartz <emschwar@ldl.fc.hp.com>
Subject: Re: Web development and Perl 6
Message-Id: <etooez96y5j.fsf@wormtongue.emschwar>

"Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de> writes:
> Even from a selfish point of view, that wouldn't be so bad. I might some
> day be in the situation where I have use for a good webhoster. I am sure
> I'll get very sick if all I have is some mod_php crap.

Speaking of mod_*, what is it about mod_php vs. mod_perl that makes
people happy to install the former, but not the latter?  I'm just now
starting to play with mod_perl on my personal server, and I don't see
how some of the complaints I've heard (stuff like, "one rogue process
can swamp the server", and so on) are any more valid about mod_perl
than mod_php or mod_ruby, or mod_lunch (sorry, it's about that time).

Is there a real difference, or is it just a matter of what people are
used to?

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: Fri, 01 Aug 2003 20:30:21 GMT
From: "mgarrish" <mgarrish@rogers.com>
Subject: Re: Web page with frames...
Message-Id: <x5AWa.70466$rsJ.24595@news04.bloor.is.net.cable.rogers.com>


"Tintin" <me@privacy.net> wrote in message
news:bgdhvn$mh84m$1@ID-172104.news.uni-berlin.de...
>
> The one thing you are forgetting are all the Usenet archives like Google
> Groups.  Having the so called "trite answers" at least helps some newbies
in
> the future how have the common decency to search before they post.
>

I'd like to hear your explanation of what good Jurgen's answer does anyone
(newbie or not). Someone posting an off-topic question isn't an invitation
to show what a jerk you can be. Either don't answer at all, or show a little
civility and point the person in the right direction. It shows more
character to help someone than to write a post that just strokes your own
ego.

Matt




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

Date: Fri, 01 Aug 2003 15:21:43 -0600
From: Eric Schwartz <emschwar@ldl.fc.hp.com>
Subject: Re: Web page with frames...
Message-Id: <eto65lh6plk.fsf@wormtongue.emschwar>

"mgarrish" <mgarrish@rogers.com> writes:
> I'd like to hear your explanation of what good Jurgen's answer does anyone
> (newbie or not).

It tells them their question is not a Perl question.  It also tells
them that non-Perl-related questions aren't welcome here.

> Someone posting an off-topic question isn't an invitation
> to show what a jerk you can be. Either don't answer at all, or show
> a little civility and point the person in the right direction. It
> shows more character to help someone than to write a post that just
> strokes your own ego.

Go for it.  Nobody's stopping you.

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


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

Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: 
Message-Id: <3F18A600.3040306@rochester.rr.com>

Ron wrote:

> Tried this code get a server 500 error.
> 
> Anyone know what's wrong with it?
> 
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {

(---^


>     dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
 ...
> Ron

 ...
-- 
Bob Walton



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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 5308
***************************************


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