[6463] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 88 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 11 14:33:25 1997

Date: Tue, 11 Mar 97 11:00:33 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 11 Mar 1997     Volume: 8 Number: 88

Today's topics:
     Re: (Q) HTTP.PL <rootbeer@teleport.com>
     Re: Calling a Perl Program from within HTML (Laurel Shimer)
     can i pass a filehandle through a socket? (felix k sheng)
     Controlling Output from LWP <mstearns@darkwing.uoregon.edu>
     Re: dupe checking and compressing in string <wkuhn@uconect.net>
     Re: dupe checking and compressing in string <rra@cs.stanford.edu>
     Re: FAQ or "manual" on using DBI with Oracle. (John D Groenveld)
     Graphics polls or non ? (Joonas Vuorinen)
     Re: help for beginner (Laurel Shimer)
     Re: help with printing to a socket (Nathan V. Patwardhan)
     Re: help with printing to a socket (Nathan V. Patwardhan)
     Help! Question about reading files <harry@bci.se>
     Re: Help! Question about reading files (Nathan V. Patwardhan)
     Re: How to delete a file? Or/and By date. (Tad McClellan)
     Interpreting this reg expression has me baffled (Laurel Shimer)
     keyword search script needed <kirby@nrs.mcgill.ca>
     Need Help installing Perl for Os2 (Erin McKean)
     Re: Numeric Output, format help. (Greg Hassan)
     operations with dates in PERL.... <gespinos@nic.mx>
     Re: Parsing a CSV file into 2 arrays... (Laurel Shimer)
     Re: Parsing a form with enctype=multipart (Abigail)
     Re: Perl "strict" usage <rootbeer@teleport.com>
     Running same perl script on different platforms <dmay@memh.ti.com>
     Re: Search Engine in Perl... <pcunnell@csfp.co.uk>
     Re: Starting with PERL: a question (The next Pele)
     TCP Server from manpage fails (Kester Habermann)
     Re: Who makes more $$ - Windows vs. Unix programmers? (Greg Hassan)
     Re: Who makes more $$ - Windows vs. Unix programmers? (Tim Smith)
     Re: Who makes more $$ - Windows vs. Unix programmers? (Tim Smith)
     Re: Why can't I subscript split? <merlyn@stonehenge.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 11 Mar 1997 10:32:29 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: John Alciere <jalciere@xyplex.com>
Subject: Re: (Q) HTTP.PL
Message-Id: <Pine.GSO.3.96.970311103029.695J-100000@kelly.teleport.com>

On Mon, 10 Mar 1997, John Alciere wrote:

> We are thinking of using perl to automate testing of an html/http-based
> user interface.  Has anyone had experience doing this?  Is there such a
> thing as "http.pl" -- or are there other perl libraries that will be
> useful for this application?

There are many perl modules which can help you, and modules are even nicer
than libraries. You'll find all of the really cool stuff on CPAN,
including modules which will retrieve web pages with the greatest of ease.

Hope this helps! 

    http://www.perl.com/CPAN/
    http://www.perl.org/CPAN/

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: Tue, 11 Mar 1997 07:54:15 -0700
From: autopen@quake.net (Laurel Shimer)
Subject: Re: Calling a Perl Program from within HTML
Message-Id: <autopen-1103970754150001@l90.d22.quake.net>

I'm not absolutely clear on what you want to do - but I think maybe this
is the sort of thing you do w/ Java Script.

Others- Is that the wrong track to suggest?

Laurel

In article <331A1D13.6F42@cdsnet.net>, thorsoft@cdsnet.net wrote:

> I need to include about 50 lines of html code into 10 sites.  I also
> need to pass a parameter to the cgi code so I know which 50 lines of
> code that is needed.  There are 4 different snippets of code each with a
> different graphic.  The cgi code would then look at the parameter and
> then generate the proper html code for inclusion into the page that
> called the cgi program.
> 
> Can I call a cgi program from an html page while the html page is
> loaded?  This is similar to a server side include, but some of the sites
> do not want to make their "html" files "shtml" for the server side
> includes to work.
> 
> Thanks,
> Rick

-- 
        The Reader's Corner: Mystery, Romance, Fantasy 
     Short stories, excerpts, themes and resources 
        http://www.autopen.com/index.shtml 
     Subscribe to our free StoryBytes publication
Current Mermaids Issue at http://www.autopen.com/mermaids.shtml


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

Date: 11 Mar 1997 15:54:45 GMT
From: felix@chance.em (felix k sheng)
Subject: can i pass a filehandle through a socket?
Message-Id: <slrn5iavrp.llo.felix@chance.em>
Keywords: perl5 filehandle socket

hello,

i was just wondering if it's possible in perl5 to pass a filehandle,
(in particular a filehandle that has been used by accept to attach to
an incoming connection) - over another filehandle to a waiting process.

i.e. if i wanted to create a server that upon startup shoots out 5
or so kids which then do nothing. the server sits on a port recieves
connect requests and hands them off to her waiting children.

is something like that possible? thanks for any info/pointers.

'lx


--- felix sheng                                       pager     800 979 2171
 programmer                                           tel       212 597 8069
 the new york times electronic media company          e    felix@nytimes.com


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

Date: Tue, 11 Mar 1997 06:31:16 -0800
From: Michael Stearns <mstearns@darkwing.uoregon.edu>
Subject: Controlling Output from LWP
Message-Id: <33256C5F.6155DAD@darkwing.uoregon.edu>

I am using the post example in lwpcook.pod to post a form and return a
page to my browser. (I don't know if what I am doing is unique, but I
have a form that posts to a script, which in turn uses LWP to post to
another script and then returns the info back through those two steps to
the original browser.) When I run the script, useragent.cgi, it returns:

--- HTTP::Response=HASH(0x1e3850) ---
RC: 200 (OK)
Message: OK

Date: Tue, 11 Mar 1997 13:04:46 GMT
Server: Apache/1.1.3
Content-Type: text/html
Client-Date: Tue, 11 Mar 1997 13:04:46 GMT
Title: Thank You

<html>
 <head>
  <title>Thank You</title>
 </head>
 <body>
  <center>
   <h1>Thank You For Filling Out This Form</h1>
 ..............

So I have a page with all this text on it, instead of a formatted html
page. 

I am assuming that I DON'T want some or all of the header info that is
getting returned, since my browser won't just give me the formatted
page. My basic problem is that I don't see where I can modify the LWP
module to affect this behavior. I have looked at the various parts that
come with it, but I can't figure out where the response is created. Can
anyone point me in the right direction?

Thanks,
Michael Stearns


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

Date: Tue, 11 Mar 1997 10:11:13 -0500
From: Bill Kuhn <wkuhn@uconect.net>
To: Bertrand Le Guen <b.leguen@ctr.renault.fr>
Subject: Re: dupe checking and compressing in string
Message-Id: <33257611.2239DE97@uconect.net>

Try this:

$LINE =~ s/(.)\1+/$1/g ;

-Bill
-- 
Bill Kuhn
Chief Developer
Wired Markets, Inc.
http://www.buyersindex.com


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

Date: 11 Mar 1997 08:30:44 -0800
From: Russ Allbery <rra@cs.stanford.edu>
To: Bertrand Le Guen <b.leguen@ctr.renault.fr>
Subject: Re: dupe checking and compressing in string
Message-Id: <qumsp22s85n.fsf@cyclone.stanford.edu>

[ Posted and mailed. ]

Bertrand Le Guen <b.leguen@ctr.renault.fr> writes:

> Could someone tell me how (or where to find the way to do it) to easily
> check a string for duplicate caracters and simplify it to only one
> occurence.

	$string =~ tr[\000-\377][\000-\377]s;

> in fact if
> $LINE="========AAAAAABBBBBBcccdddeeee******";
> i would like as result to get
> $LINE="=ABcde*";

cyclone:~> perl
$string = '========AAAAAABBBBBBcccdddeeee******';
$string =~ tr[\000-\377][\000-\377]s;
print "$string\n";

=ABcde*

-- 
Russ Allbery (rra@cs.stanford.edu)      <URL:http://www.eyrie.org/~eagle/>


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

Date: 11 Mar 1997 09:04:56 -0500
From: groenvel@tholian.cse.psu.edu (John D Groenveld)
Subject: Re: FAQ or "manual" on using DBI with Oracle.
Message-Id: <5g3oq8$485@tholian.cse.psu.edu>

In article <858044104.15638@dejanews.com>,
 <Tim.Middleton@health.wa.gov.au> wrote:
>Hi, I am using DBI version 0.75 and DBD version .44 , and Oracle 7.3.2
>and would like to know if there is a FAQ or list of commands such as
>ora_open, etc.
Besides 'perldoc Oraperl' and whats already available on the web, I dont know
of a FAQ. Alligator Descarte's site is helpful
(http://www.hermetica.com/technologia/DBI/), as are the DBI/DBD mailist
archives (http://www.coe.missouri.edu/~faq/lists/dbi.html 
http://www.rosat.mpe-garching.mpg.de/mailing-lists/).
The next issue of the Perl Journal (http://www.tpj.com/) will have an article
about DBI/DBD and a book is in the works.

>Please Email Me.
Its not very polite to send your post around the world and then ask for
responses via email--perhaps you could offer to post a summary, instead.

Good luck,
John
groenvel@cse.psu.edu


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

Date: 11 Mar 1997 17:55:40 GMT
From: tjvuorin@cc.helsinki.fi (Joonas Vuorinen)
Subject: Graphics polls or non ?
Message-Id: <5g46as$gd2@oravannahka.Helsinki.FI>

Somebody tell me how I can find poll source like ESPNET.sportzone.com have ?
Or any other source or shareware poll ?
Mail directly

Thanks,


--
Joonas Vuorinen
tjvuorin@cc.helsinki.fi


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

Date: Tue, 11 Mar 1997 08:44:38 -0700
From: autopen@quake.net (Laurel Shimer)
Subject: Re: help for beginner
Message-Id: <autopen-1103970844380001@l82.d22.quake.net>

In article <331C178D.5A85@lpt.fi>, Annika Tonts <tonts@lpt.fi> wrote:

> Hi!
>         I4m an artist and not quite technical person, but have used some
design
> programs. Now I4d like to make my new net pages. There will be some
> gif-animated pictures and an image map I already made. 
>         I`d like to use together with those pictures some texts, where any
> guest of my pages could write his own data (some words) and after see
> all the page with his own added data. I don`t need this data saved for
> me (like in guestbooks). I have seen some similar pages made by
> CGI-script, but do I need to use it in my case or can I do something
> like that by java also? 
>         How is it easier to start, if I have no experience in both of these
> programming languages? What else will I need?
> 
>         I`ll be very thankful for all good advices,
>                 Annika

Try Selena Sol's web site

http://www.eff.org/~erict/Scripts/

You will need to understand Unix chmod and other things. You may, as I
did, have to make some perl changes if you have a non-standard server.

Laurel

-- 
        The Reader's Corner: Mystery, Romance, Fantasy 
     Short stories, excerpts, themes and resources 
        http://www.autopen.com/index.shtml 
     Subscribe to our free StoryBytes publication
Current Mermaids Issue at http://www.autopen.com/mermaids.shtml


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

Date: 11 Mar 1997 15:31:59 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: help with printing to a socket
Message-Id: <5g3ttf$rkl@fridge-nf0.shore.net>

Rachel Polanskis (rachel@virago.org.au) wrote:

: When I run my script below, on port 7 (echo) I expected it
: to return whatever I print out.

Are you root?  

Also, you're not declaring the port as an int, which it should be.

: $port = "7";
^^^^^^^^^^^^^^
$port = 8007; or $port = 7; or whatever.

HTH!

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: 11 Mar 1997 15:36:27 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: help with printing to a socket
Message-Id: <5g3u5r$rkl@fridge-nf0.shore.net>

Nathan V. Patwardhan (nvp@shore.net) wrote:
: Rachel Polanskis (rachel@virago.org.au) wrote:

: : When I run my script below, on port 7 (echo) I expected it
: : to return whatever I print out.

: Are you root?  

OOPS.  Sorry to follow-up on my own posting, but the reason I asked if
you were root is because I wondered info you had also written a server
that was attempting to run on port 7, and thus would be a problem.  

Sorry for the lunacy.  I'm going to get my first cup of coffee - now :-)

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: 11 Mar 1997 16:02:36 GMT
From: "Harry Kas" <harry@bci.se>
Subject: Help! Question about reading files
Message-Id: <01bc2e35$7b9a85c0$de0264c3@bci>

Can somebody help me?

I have to read a textfile into an array (or variable) and must then be able
to compare character by character.
I have done something like this:


open (HTML,"test.txt");
  $i = 0;

  while (<HTML>) {
    $line[$i] = <HTML>;
    $i++;
  }
  close(INFO);


  for ($j=0; $j<$i ; $j++ ) {
    for ($x=0; $x < length($line[$j]) ; $x++ ) {
      print "($line[$j][$x])";       ## here I hope to see character by
character but I get only whole lines.
    }
  }
}

I get a whole line with $line[$j][$x] instead of the single character I
expected.

I have also tried to read a file with the getc command but that was not
working at all.
Can somebody help me? 

Btw I use Win 95.

-- 
Harry Kas - BCi Sweden
tel +46-8-540 650 60
fax +46-8-540 69318
harry@bci.se


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

Date: 11 Mar 1997 17:19:15 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Help! Question about reading files
Message-Id: <5g446j$690@fridge-nf0.shore.net>

Harry Kas (harry@bci.se) wrote:

: I have to read a textfile into an array (or variable) and must then be able
: to compare character by character.
: I have done something like this:

Here's one method:

$file = 'file.txt';
open(FILE, "$file") || die("file error: $!");
$all = <FILE>;
close(FILE);

@lines = split(//, $all); # split on each char (by spliting on "nothing").

for($i=0; $i<5; $i++) { ### print out five lines only - just to show you
		        ### that it's printing char by char
   print $lines[$i]; #should print out each character
}

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: Tue, 11 Mar 1997 07:40:59 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: How to delete a file? Or/and By date.
Message-Id: <bdn3g5.nq.ln@localhost>

Scott Tilton (sbt@tiac.net) wrote:
: Ok, I have searched in the few Perl 5 books that I have on how to do the
: following:

: I need to be able to search in a directory for any file with the .ord
: extension 

opendir(), readdir() and grep()


opendir(DIR, "/path/to/a/directory") || die "could not opendir  $!";
@ords = grep /\.ord$/, readir(DIR);
closedir(DIR);


: and delete them by date, or time.  I need to be able to delete
                     ^^^^^^^^^^^^^
On real Operating Systems there are several times associated with
a file. 


: them if they are older than the current date, or if possible if the file
: is older than like 3-4 hours or so.

stat(), localtime() and unlink()


: Is this possible in Perl?  

Yep.


: If so, could some one either show me an
: example, or point me in the right direction?

: Any help would be great!

: Please respond to mailto:sbt@tiac.net

Nope.


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Tue, 11 Mar 1997 10:30:18 -0700
From: autopen@quake.net (Laurel Shimer)
Subject: Interpreting this reg expression has me baffled
Message-Id: <autopen-1103971030180001@l82.d22.quake.net>

To paraphrase the great one ('lo we worship before your linguist's
throne') there are many ways to do the same thing. Still I find other
people's code very helpful to understand.

This morning I wrote a response to a posting by Stuart w/ the subj
"Parsing a CSV file into two Arrays'. I was able to figure out an
alternative method of doing what he wanted done (I hope he wasn't looking
for something more sophisticated - he won't get it from me) but in the
meantime I used his code as an example to increase my proficiency with
Perl. I wasn't able to successfully understand 2 techniques he was using
and wonder if anyone else will enlighten my ignorance.

Funny how it's easier to work on someone else's problem than my own...

Okay here are the bits I don't get (despite my 'Perl Reference Guide' and
the Camel book at my side)

> while (<NAMES>) {
>         #chomp;
>         push @fullnames, ($1||$+)
>             while /\s*"(([^"\\]|\\"|\\\\)*)"\s*|\s*([^",]+)\s*/g;
> }
> 

1) For some reason he doesn't need to use 'chomp'. I guess that has
something to do w/ this substitution (or what seems to be a substitution)
that is such a bear for me to interpret. But I don't understand where the
paragrah character would be removed.

2) My use of $1 is limited to passing arguments to subroutines, or
examining (hum - Think I've used it to examine something returned from
something but I forget how or what I did. )

The ref guide says 'Contains the subpatterns from the corresponding sets
of parenthesies in the last pattern successfully matched' - so I guess
this means that when the regular expression is evulated something, which
is a transformation of what's currently in $_,  will get shoved in here.

Do I have that vague idea right?

3) Now there is this $+ business. Ref guide says "last bracket matched by
the last search pattern". And the two bits $1 and $+ are 'or\'d' together.

I don't quite understand what might be or'd together, or why it is or'd
together, or how you would know what to expect when they are or'd together
or why you would want the result to be the value in your array.

?????

4) Okay now I get to the regular expression. 

while /\s*"(([^"\\]|\\"|\\\\)*)"\s*|\s*([^",]+)\s*/g;

a) while : okay so something is happening repeatedly w/ the current
contents of $_. 

    How does it know when to exit the while ?

b) /\s*

so is 's' being escaped? Why? Or does this mean something else? Is this an
's' like a substitution? Or something else? (All my substitutions so far
use match (=~) and I'm not even sure where to look to figure out what sort
of 's' this means.

I have the vague idea that this is eliminating all the double quotes
(something that had to be done in the problem - there were multiple double
quotes that needed to be cleaned out. I used =~ s/"//g to do that bit.

But this seems to do something more. At least I think so.

And somehow he is eliminating the paragraph return.

When I tried to use this expression without the while bit I failed
miserably so somehow the 2 parts are intertwined.

Laurel


-------- Original Post --------
In article <3324F2BC.6535@quake.net>, Stuart McClure <smcclure@quake.net> wrote:

> Can any of you gurus help out?
> 
> I want to read a line at a time from a text file and then strip the
> field (from within double quotes) as a comma as the field delimiter and
> push the first field into array1 and the second field into array2.
> 
> I can strip each field from the text file (or CSV) and push into a
> single array, but don't know how to distinguish between the first field
> and the second (to put into the second array).
> 
> Here's a sample CSV file:
> "Tom","Cruise"
> "Nicole","Kidman"
> 
> And a sample of the push code to an array.
> 
> open(NAMES, "names.txt") or die "Can't open names.txt: $! \n";
> while (<NAMES>) {
>         #chomp;
>         push @fullnames, ($1||$+)
>             while /\s*"(([^"\\]|\\"|\\\\)*)"\s*|\s*([^",]+)\s*/g;
> }
> 
> Thanks in advance for any help.
> 
> -- 
> Stuart McClure

-- 
        The Reader's Corner: Mystery, Romance, Fantasy 
         http://www.autopen.com/index.shtml 
     Subscribe to our free StoryBytes publication
 New: Fashion Challenges for the Time Traveling Heroine     http://www.autopen.com/romance.well.dressed.shtml


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

Date: 11 Mar 1997 16:07:12 GMT
From: "Peter Kirby" <kirby@nrs.mcgill.ca>
Subject: keyword search script needed
Message-Id: <01bc2e36$014f09c0$0215d884@Server.nrs>

If anyone can point me to a working keyword search script that will work in
a Win95 environment I would be very appreciative.

Thanks.

Peter Kirby


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

Date: 11 Mar 1997 17:10:55 GMT
From: emckean@enteract.com (Erin McKean)
Subject: Need Help installing Perl for Os2
Message-Id: <5g43mv$p6j@eve.enteract.com>


Hey, I hope my subject line is specific enough!

Here's my problem. I've had Perl4 for a year now,
I really love it and now I have to write a much
bigger program than ever before (an SGML filter)
so I thought "it's time to move to Perl5."
Went out, got the new Camel from the Perl Institute,
downloaded Ilya's Perl for OS2, unzipped it. . .and
I'm stuck.

What's got me stuck:

I can't find sh.exe, so I can't put it in the right place.
Where can I find it? Should I have it already? Heck, I don't
even know what it does & why. 

I don't know what/how/who to do a binary edit so I can
put in the right paths in perl.dll and perl_.exe. I'm
assuming a binary edit does not mean opening these
files with the trusty OS/2 system editor.

Any help is gratefully appreciated. Especially answers to
questions I don't know enough to ask!


Sincerely,

Erin McKean
emckean@enteract.com

Also, what is the advantage of "building" Perl as opposed
to just installing the binary? I think my limited skills
would argue against building Perl because of the time and
impassioned pleas for help to this newsgroup it would
take. . .but I'm willing to learn if it would make a big
difference in <something important here>.




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

Date: 11 Mar 1997 13:57:16 GMT
From: gwhassan@Coho.Stanford.EDU (Greg Hassan)
Subject: Re: Numeric Output, format help.
Message-Id: <5g3obs$irr@nntp.Stanford.EDU>

Scott Tilton (sbt@tiac.net) wrote:
: This is major problem, but I would like to fix this.

: In Perl, my output for a total is a price.  On certain calculations, the
: output looks like $00, or $0.0.  I would like to make the output for
: this variable $price to always have 2 digits after the decimal point. 
: Could someone help me with this?

: Thanks,
: Scott Tilton
: Please respond to: mailto:sbt@tiac.net
: -- 
: Virtual Web Works
: http://www.tiac.net/users/sbt
: A member of the HTML Writers Guild

just break it up into the seperate problems,
I would do something like so:

$pr=~s/(\.\d\d)\d/$1/g;        # has more then 2 num after decimal

if ($pr !~ /\$\d+\.\d\d/)
{
if (!/\./)     {$pr.="\.00";}  #doesnt have decimal
elsif (/\.\d/) {$pr.="0";}     #has one num after decimal
}

or maybe you could just take out the $ and do a sprintf("$%.2f",$pr);

--
========================================
              Greg Hassan
        The Independent Solution
 for High-End Web Development contact:
          gwhassan@prodigy.net	
  http://www.cs.buffalo.edu/~gwhassan/
========================================


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

Date: Mon, 10 Mar 1997 22:19:09 -0600
From: Gustavo Espinosa Tavitas <gespinos@nic.mx>
Subject: operations with dates in PERL....
Message-Id: <3324DD3D.29C1@nic.mx>

Hi!
I have this petite question:
*I have a date field of the form 'YYYY MMM DD' and I need to
add 30, 90, XX days to it. I get this date from the array that
localtime(time) returns.
*Now, this is what i've done this far:
-read the date field from file.
-initialize an array @timearray:
$sec=0,$min=0,$hour=0
$mday=DD,$mon=MM,$year=YYYY,
$wday,$yday,$idst ( i don't know what to do with these )
and then 
$initial_date=timelocal($sec,$min,$hour,
              $mday,$mon,$year,$wday,$yday,$idst)
now $initial_date has the date in seconds since 1970, 
and i just have to add the equivalent of XX days in seconds,right?
Wrong!!! timelocal just don't gives me anything i expect.
Can anyone explain me how can i make this work ...?
I'd Appreciate it.
Thanks.
Atte. 
Gustavo Espinosa 
mailto:gespinos@nic.mx


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

Date: Tue, 11 Mar 1997 10:05:43 -0700
From: autopen@quake.net (Laurel Shimer)
Subject: Re: Parsing a CSV file into 2 arrays...
Message-Id: <autopen-1103971005430001@l82.d22.quake.net>

Stuart

I found your regular expression very elegant but I couldn't quite figure
it out (regular expressions are my albatross) so I changed the technique
to a less elegant method that works for me.

I have a funny feeling that you might be happier stuffing the first and
last names into an associative or multi-dimensional array.

Still - is this what you are after?

Laurel
----------------
shellx 39% perl5
open(NAMES, "names.txt") or die "Can't open names.txt: $! \n";
while (<NAMES>) {
        chomp; # You do need the chomp in this case
        ($first, $last) = split /\,/;

        $first =~ s/"//g;
        $last =~ s/"//g;

        push (@firstnames, $first);
        push (@lastnames, $last);
}
print "The first array @firstnames\n";
print "The  last array @lastnames\n";

The first array Tom Nicole
The  last array Cruise Kidman
shellx 40%



In article <3324F2BC.6535@quake.net>, Stuart McClure <smcclure@quake.net> wrote:

> Can any of you gurus help out?
> 
> I want to read a line at a time from a text file and then strip the
> field (from within double quotes) as a comma as the field delimiter and
> push the first field into array1 and the second field into array2.
> 
> I can strip each field from the text file (or CSV) and push into a
> single array, but don't know how to distinguish between the first field
> and the second (to put into the second array).
> 
> Here's a sample CSV file:
> "Tom","Cruise"
> "Nicole","Kidman"
> 
> And a sample of the push code to an array.
> 
> open(NAMES, "names.txt") or die "Can't open names.txt: $! \n";
> while (<NAMES>) {
>         #chomp;
>         push @fullnames, ($1||$+)
>             while /\s*"(([^"\\]|\\"|\\\\)*)"\s*|\s*([^",]+)\s*/g;
> }
> 
> Thanks in advance for any help.
> 
> -- 
> Stuart McClure

-- 
        The Reader's Corner: Mystery, Romance, Fantasy 
     Short stories, excerpts, themes and resources 
        http://www.autopen.com/index.shtml 
     Subscribe to our free StoryBytes publication
Current Mermaids Issue at http://www.autopen.com/mermaids.shtml


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

Date: Tue, 11 Mar 1997 16:43:43 GMT
From: abigail@ny.fnx.com (Abigail)
Subject: Re: Parsing a form with enctype=multipart
Message-Id: <E6w14v.KzH@nonexistent.com>

On 11 Mar 1997 01:28:45 GMT, Tom Christiansen wrote in comp.lang.perl.misc:
++ 
++ Oye, ?nos explicas por donde en tu mensaje aparece la palabra "perl",
++ de la cual este newsgroup se trata? 
++ 
++ Pues, ?no?
++ 
++ Entonces sugiero que busques la respuesta a tu pregunta en un sitio que
++ mas pertenezca a lo de CGI, o sea, comp.infosystems.www.authoring.cgi.
++ Me imagino que alla tendrmas mas suerte que aca.
++ 
++ Pero te diri cuatro cosas (ok, una sola :-) -- Lo primero que debermas
++ hacer es adquirir CGI.pm, que ya entiende la tarea que has mencionado.
++ 

Odd. Isn't this the same poster who complained not so long ago about a
posting in French?



Abigail



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

Date: Tue, 11 Mar 1997 10:30:03 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Luigi Mattera <mattera@ssga.ssb.com>
Subject: Re: Perl "strict" usage
Message-Id: <Pine.GSO.3.96.970311102547.695I-100000@kelly.teleport.com>

On 10 Mar 1997, Luigi Mattera wrote:

> Does using "my" multiple times on a single variable cause slowdown? 

I don't know whether it slows your program, but it slows the programmer
who has to type all of those superfluous keywords. :-) Once a variable has
been marked as a 'my' variable by the compiler, there's no need to declare
it again. (Within a single scope, of course; but if it's in a different
scope, it's not really the same 'my' variable.)

Hope this helps!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: Tue, 11 Mar 1997 11:28:52 -0600
From: Derek May <dmay@memh.ti.com>
Subject: Running same perl script on different platforms
Message-Id: <33259654.66A4@memh.ti.com>

Is there a way to set up our scripts to check the current OS version
before looking for the perl executable?

We are currently running on HPUX machines with OS v9.07.  We are
installing new HPUX machines running OS 10.20.  On the old machines,
perl is located in /usr/local/bin, but on the new machines perl will
have to be installed somewhere else.  We would like to be able to use
the same scripts without having to make duplicate copies with a new
header line.

For example:
   #!/usr/local/bin/perl  on old machines
  must become
   #!/xxx/xxx/bin/perl   on new machines

Thanks,
Derek
-- 

=======================================================================
*  Derek May                             TI MSG ID: RGBY              *
*  Design Automation                     mailto:dmay@ti.com           *
*  Memory Products Development           http://www.memh.ti.com/~mcad *
*  Texas Instruments Inc. MS 657         Phone: (281) 274-3757        *
*  PO Box 1443, Houston, TX 77251        Fax:   (281) 274-2067        *
=======================================================================


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

Date: Tue, 11 Mar 1997 13:29:31 +0000
From: Paul Cunnell <pcunnell@csfp.co.uk>
Subject: Re: Search Engine in Perl...
Message-Id: <33255E3B.B38@csfp.co.uk>

Bruno Dickhoff wrote:
> 
> Hi...
> 
> I need a Perl-driven Full-Text-Retrieval system (CGI-Script),
> 
[...]
> 
> I have found a sample of perl-code, which does exactly this task, but
> unfortunately it seems to be written for Unix-Systems and does not
> work on the NT-Server...
> 
> Any hints?

Upgrade to Unix :-)

-- 
Paul Cunnell CSFB RDG (pcunnell@csfp.co.uk) +44 171 888 2946


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

Date: 11 Mar 1997 18:04:12 GMT
From: gt1535b@acmex.gatech.edu (The next Pele)
Subject: Re: Starting with PERL: a question
Message-Id: <5g46qs$c54@catapult.gatech.edu>

K.James (bss194@thunder) wrote:
: Ronald Fischer (rfi@uebemc.siemens.de) wrote:
: : Hugh Blandford <hugh@island.net.au> writes:

: Is there really a Llama for Perl 5? I bought mine recently and it's the 
: Perl 4 version.

Yes, and it's sort of greenish, whereas the first one was somewhere between
red and pink.

: --
: Keith James Ph.D. - k.james@bangor.ac.uk  PGP 2.6.2i  Key ID 469A9FA1
: Biodegradation Group                         *Encrypt and Survive*  
: School of Biological Sciences             Nightmare: Quake me up now!
: University of Wales, Bangor, UK                                     
: -------http://oracle.bangor.ac.uk/sbs/research/biodegradation/-------

--
<>< Daryl Bowen	<><
Georgia Institute of Technology
E-mail: gt1535b@prism.gatech.edu
Siemens Stromberg-Carlson Co-op


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

Date: 11 Mar 1997 18:18:20 GMT
From: kester@unix-ag.uni-kl.de (Kester Habermann)
Subject: TCP Server from manpage fails
Message-Id: <5g47lc$k66@sun.rhrk.uni-kl.de>

Hi,

I took the sample TCP-server (multi-threaded version) from the perlipc
manpage and the corresponding client. The server listens on a port and
prints a fortune  when the client connects  and  closes the connection
with the client.

On Solaris 2.5 and Linux 2.0.29-ELF the connection to the server fails
every second  time (this is  the case  when  using the client  or when
using telnet to connect to the server).

The example works  correct for me on  SunOS 4.1.4, HP-UX  9.04 and Aix
4.1.

I did all these tests with perl5.003.

Is   this a bug in  Solaris  an Linux or  is there  a way  to make the
TCP-server more generalized to work correct on most common systems.

I also  tried Net::TCP from CPAN, but  I  couldn't get  it  to work on
Solaris and Linux (I haven't tried the other platforms yet).


Thanks, Kester.

Code I used (from perlipc.1):

sample_server.pl:

#!/usr/bin/perl -Tw
require 5.002;
use strict;
BEGIN { $ENV{PATH} = '/usr/ucb:/bin' }
use Socket;
use Carp;

sub spawn;  # forward declaration
sub logmsg { print "$0 $$: @_ at ", scalar localtime, "\n" }

my $port = shift || 2345;
my $proto = getprotobyname('tcp');
socket(Server, PF_INET, SOCK_STREAM, $proto)        || die "socket: $!";
setsockopt(Server, SOL_SOCKET, SO_REUSEADDR,
                                    pack("l", 1))   || die "setsockopt: $!";
bind(Server, sockaddr_in($port, INADDR_ANY))        || die "bind: $!";
listen(Server,SOMAXCONN)                            || die "listen: $!";

logmsg "server started on port $port";

my $waitedpid = 0;
my $paddr;

sub REAPER {
    $SIG{CHLD} = \&REAPER;  # loathe sysV
    $waitedpid = wait;
    logmsg "reaped $waitedpid" . ($? ? " with exit $?" : '');
}

$SIG{CHLD} = \&REAPER;

for ( $waitedpid = 0;
      ($paddr = accept(Client,Server)) || $waitedpid;
      $waitedpid = 0, close Client)
{
    next if $waitedpid;
    my($port,$iaddr) = sockaddr_in($paddr);
    my $name = gethostbyaddr($iaddr,AF_INET);

    logmsg "connection from $name [",
            inet_ntoa($iaddr), "]
            at port $port";

    spawn sub {
        print "Hello there, $name, it's now ", scalar localtime, "\n";
        exec '/usr/games/fortune'
            or confess "can't exec fortune: $!";
    };

}

sub spawn {
    my $coderef = shift;

    unless (@_ == 0 && $coderef && ref($coderef) eq 'CODE') {
        confess "usage: spawn CODEREF";
    }

    my $pid;
    if (!defined($pid = fork)) {
        logmsg "cannot fork: $!";
        return;
    } elsif ($pid) {
        logmsg "begat $pid";
        return; # i'm the parent
    }
    # else i'm the child -- go spawn

    open(STDIN,  "<&Client")   || die "can't dup client to stdin";
    open(STDOUT, ">&Client")   || die "can't dup client to stdout";
    ## open(STDERR, ">&STDOUT") || die "can't dup stdout to stderr";
    exit &$coderef();
}
   

sample_client.pl:

#!/usr/bin/perl -w
require 5.002;
use strict;
use Socket;
my ($remote,$port, $iaddr, $paddr, $proto, $line);

$remote  = shift || 'localhost';
$port    = shift || 2345;  # random port
if ($port =~ /\D/) { $port = getservbyname($port, 'tcp') }
die "No port" unless $port;
$iaddr   = inet_aton($remote)               || die "no host: $remote";
$paddr   = sockaddr_in($port, $iaddr);

$proto   = getprotobyname('tcp');
socket(SOCK, PF_INET, SOCK_STREAM, $proto)  || die "socket: $!";
connect(SOCK, $paddr)    || die "connect: $!";
while ($line = <SOCK>) {
    print $line;
}

close (SOCK)            || die "close: $!";
exit;


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

Date: 11 Mar 1997 14:44:40 GMT
From: gwhassan@Coho.Stanford.EDU (Greg Hassan)
Subject: Re: Who makes more $$ - Windows vs. Unix programmers?
Message-Id: <5g3r4o$j1e@nntp.Stanford.EDU>

Giampaolo Tomassoni (tomassoni"@ftbcc".it) wrote:
: Future Programmer <futureprog@bridge.net.NOSPAM.PLEASE> wrote in article
: <5qsxov$gkm@skyway.bridge.net>...
: > Subject says it all. Based on your personal experience and statistics,
: > where a good programmer can make more money - in Windows or Unix arena?
: > Unix appeals more to me and is more advanced technically, but I am
: > afraid that it is losing the market share to Windows 95. I want to be in
: > the consulting field.
: > 

how about a thought as to what you like to do rather then what makes
more cash? :)

I don't feel that there should be a problem anywhere as there are
so many projects around the world that need to be done.  If you
have the skills, you should be able to find something you like.

I just have a natural aversion to windows for some reason.  Something
about the CS degree that does that to people...   

I've worked on a few projects using visual c++ and didnt enjoy it that
much.  I find using perl for windows isnt so bad though, probably due
to the fact that I just write them on my unix box and ftp them over. :)

-Greg

--
========================================
              Greg Hassan
        The Independent Solution
 for High-End Web Development contact:
          gwhassan@prodigy.net	
  http://www.cs.buffalo.edu/~gwhassan/
========================================


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

Date: 11 Mar 1997 07:55:37 -0800
From: tzs@halcyon.com (Tim Smith)
Subject: Re: Who makes more $$ - Windows vs. Unix programmers?
Message-Id: <5g3v9p$eqo$1@halcyon.com>

In article <5g1okc$n5e@asgard.actrix.gen.nz>,
John Bickers <jjbicker@atlantis.actrix.gen.nz> wrote:
>In article <5g0s9b$ld@sf18.dseg.ti.com>, Harold Stevens <wyrd@ti.com> wrote:
>
>> Thank you for injecting some sanity in an inane thread. I've been in the
>> business 25 years and seen language/OS fads come and go with abandon. It
>
>    Is this a record for both left and right text alignment without
>    inserted spaces or artificial filling?

No.  In fact, it is not very hard to make both the left and right
text align without artifical filling.  The hardest part is making
sure that you do not have a spelling error somewhere.  It is very
annoying to get to the end of a long post, that you have arranged
to fully justify without artificial aid, and then find you missed
a character somewhere.  You also have to be careful about how you
end each sentence.  Putting a single space after some periods and
a double space after others will not do, for example.

The key is the flexibility of English.  For example, on line four
of the previous paragraph, I originally typed "managed", but that
was one character short, and so I tried "arranged", and that fit.

Anyway, I've seen people do several dozen lines of text this way.
Often, what happens is the first three or four just happen to fit
on their own, and then the person starts making sure the rest fit
too.

Some people consider it acceptable to switch the length between
paragraphs, like I am doing right now, but some people consider
that to be cheating, or at least inelegant.

--Tim Smith


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

Date: 11 Mar 1997 07:44:56 -0800
From: tzs@halcyon.com (Tim Smith)
Subject: Re: Who makes more $$ - Windows vs. Unix programmers?
Message-Id: <5g3ulo$eh0$1@halcyon.com>

Tony Toews <ttoews@agt.net> wrote:
>The best money is made by the best people.  Those who have fun with
>computers. Who enjoy working with them.  
>
>The fact that you ask where the money tells me that you'll likely
>never be one of the best.

Once you get into the guts of it, pretty much any system can be fun.
Even DOS has hidden depths that can provide a truly interesting experience
(e.g., the book "Undocumented DOS" is full of cool things to play with).

I've managed to have fun in the following varied areas:

1. Unix system hacking.  This ranged from writing utility programs to
throwing out all the process, memory, and interrupt management code and
replacing it with my own from scratch implementation.

2. Macintosh driver programming, which then lead to Macintosh application
programming (the driver needed installation and management software).

3. Embedded systems.

4. Windows application programming.

5. Firmware for SCSI host adaptors.  Complete set of SCSI CAM drivers for
all major PC operating systems at the time (DOS, Windows, Netware, SCO Unix).

6. 3D video game programming for the Mattel Intellivision and the Commodore
VIC-20.

7. Windows 95 driver programming.

When one has a plethora of opportunities, all of which look like they will
be fun, and when one realizes one will probably jump around and get to them
all eventually anyway, why not start out with the one that will get you the
most money, and thus will make it easier to do that hopping around later?

--Tim Smith


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

Date: 11 Mar 1997 09:01:40 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Why can't I subscript split?
Message-Id: <8c3eu2e7tn.fsf@gadget.cscaper.com>

>>>>> "Honza" == Honza Pazdziora <adelton@fi.muni.cz> writes:

Honza> Use
Honza> 	sort { (split(':',$a))[4] cmp (split(':',$b))[4] } @passwd;

Honza> The split mustn't be $split and you have to index the list the split
Honza> returns.

Of course, if you have more than a dozen or so users in @passwd, you'll
probably NOT want to do it this way.... it'll be molasses slow.

Instead, invoke the (ta-da) Schwartzian Transform[1]...

	@sorted =
		map { $_->[0] }
		sort { $a->[1] cmp $b->[1] }
		map { [$_, (split /:/)[4]] }
		@passwd;

which basically takes the list, converts it into a list of tuples,
sorts on each tuple, then transforms those tuples back into the list.

For each element of @passwd, the split() is peformed only once.  Much
much nicer.

[1] No, I didn't invent the name.

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 538 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@ora.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: 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 88
************************************

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