[8219] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1837 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 9 11:07:34 1998

Date: Mon, 9 Feb 98 08:00:44 -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           Mon, 9 Feb 1998     Volume: 8 Number: 1837

Today's topics:
    Re: "Mastering Regular Expressions" <qdtcall@esb.ericsson.se>
    Re: Being Nice 2 Nice Beings [Was: Reading The FAQ's et <rootbeer@teleport.com>
        ca anybody explai me this from the perl faq? <jahnel@xarch.tu-graz.ac.at>
    Re: Can't log on to Active Messaging Library in NT time (Markus Laker)
    Re: Capturing file output (M.J.T. Guy)
        Fork/Threads patrick@cre8tivegroup.com
        getting all global groups in winnt4 (thomas foerg)
    Re: Good Perl editors <jerryp.usenet@connected.demon.co.uk>
        HELP - MULTIPLE LEVEL SORT? <jgrubb@gte.net>
    Re: Help with simple file search, please. <rootbeer@teleport.com>
    Re: help: how to remove html tags from a file with perl <rootbeer@teleport.com>
        How can I pattern match a dos formated string (ctrl-m c <bhanu@usl.edu>
    Re: How do you call an .HTM from a Perl script? (Lars Gregersen)
    Re: How to get a listing of the file that is linked? (Clay Irving)
    Re: HREF tag parsing <jdporter@min.net>
    Re: Humour a newbie time... :) <rootbeer@teleport.com>
    Re: Installing Linux and Perl? <barnett@houston.Geco-Prakla.slb.com>
        is one class per file necessary? <vladimir@cs.ualberta.ca>
    Re: Is Perl 5 year 2000 compliant? <rootbeer@teleport.com>
    Re: New Perl book reviews <jdporter@min.net>
    Re: Newbie:Perl Modules <rootbeer@teleport.com>
    Re: Passing Javascript variables to Perl CGI? <petcrows@bigfoot.com>
    Re: Perl documentation (was re: Perl Year 2000 ...) <tchrist@mox.perl.com>
    Re: Porting Unix Perl scripts to Win NT <keefner@kinetic.com>
    Re: Q: Using unpack or split to get fixed-length substr (Clay Irving)
    Re: Q: Using unpack or split to get fixed-length substr <rootbeer@teleport.com>
    Re: returning the date <tchrist@mox.perl.com>
    Re: sorting an associative array <rootbeer@teleport.com>
    Re: Tie-Dee-Perl (Cleanliness is next to Goodliness, or <tchrist@mox.perl.com>
    Re: Tie-Dee-Perl (Cleanliness is next to Goodliness, or (M.J.T. Guy)
        Two Perl programs -> One html output (real time) <bholness@nortel.ca>
    Re: Using flock? <rootbeer@teleport.com>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 09 Feb 1998 15:18:39 +0100
From: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: "Mastering Regular Expressions"
Message-Id: <ishg68vp34.fsf@godzilla.kiere.ericsson.se>

doswald@xmission.com (David Oswald) writes:

> I've been interested in ordering either "Mastering Regular
> Expressions" (O'Reilly & Assoc) or "Advanced Perl Programming"
> (O'Reilly & Assoc). There are no bookstores in my area that have
> either of these books, so I can't really look them over before
> buying. Thus I turn here for a recommendation.

I've just read both of them, and I definitely recommend the regexp
book. While "Advanced Perl" is quite good at describing many
non-trivial applications of Perl, it felt a bit ho-hum to me.
Personally, I get along well enough with man pages that the book
didn't give me all that much.

"Mastering Regular Expressions" on the other hand is one of the best
computer-related books I have ever read. I had absolutely no idea
there was that much to know about regular expressions! If you're going
to do serious Perl programming, you *need* this book. It's easy to
read, covers a subject which hasn't had very much written about it and
it's written with a mind-boggling attention to detail[1]. Very highly
recommended. 

-- 
		    Calle Dybedahl, UNIX Sysadmin
       qdtcall@esavionics.se  http://www.lysator.liu.se/~calle/

[1] For example, it points out the one case in which $`$&$' isn't
    equivalent to the string matched on. I would never in a million
    years have thought of it, but Jeffrey Friedl did, commenting that
    you will almost certainly never encounter it but that he thought
    that he should mention it just for completeness.


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

Date: Mon, 9 Feb 1998 06:04:26 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Ben Coleman <bcoleman@mindspring.com>
Subject: Re: Being Nice 2 Nice Beings [Was: Reading The FAQ's etc.: a teacher's perspective...]
Message-Id: <Pine.GSO.3.96.980209060334.21932B-100000@user2.teleport.com>

On Mon, 9 Feb 1998, Ben Coleman wrote:

> On Sun, 08 Feb 1998 14:38:07 -0800, Denis Goddard wrote:
> 
> >When a Wizard says, "RTFM, you moron"
> 
> Note that there are two parts to this:
> 
> "RTFM" - there's nothing wrong with this.  When the answer is already
> in the FAQ, or the distributed docs, etc, there's no need to require
> the Wizard to spend time composing Yet Another Rehashing Of The
> Answer.
> 
> "you moron" - this, of course, we could do without.

You are correct without a doubt.

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Mon, 09 Feb 1998 16:26:05 +0100
From: Jahnel Klaus <jahnel@xarch.tu-graz.ac.at>
Subject: ca anybody explai me this from the perl faq?
Message-Id: <34DF200D.CB3FB39A@xarch.tu-graz.ac.at>

I want to test an array
if there is a certain element in an aray but i realy dont  understand
this  procedere which s in the perlfaq.

#    @blues = qw/azure cerulean teal turquoise lapis-lazuli/;
#    undef %is_blue;
#   for (@blues) { $is_blue{$_} = 1 }
#Now you can check whether $is_blue{$some_color}. It might have been a
good idea to keep the blues all in a hash in the first #place.

So can anybody explain this to me
TIA KLAUS



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

Date: Mon, 09 Feb 1998 14:55:35 GMT
From: sneezy@contax.co.uk (Markus Laker)
Subject: Re: Can't log on to Active Messaging Library in NT timed job
Message-Id: <34e218cb.430512454@mahler>

"Eric Germann" <ekgermann@cctec.com> wrote:

> Also, LocalSystem has no access to the network, so if the XCH server is
> across the wire, you're out of luck

> Lutz Albers wrote in message <34D96346.19066389@muc.de>...

> >This is a guess, but I think that timed jobs are not running under your
> >account, but as LocalService or something else. The point is that these
> >accounts might not have a profile.
> >BTW, you don't need a profile if you have the name of a exchange server
> >and a valid username/password pair

I've found the problem, or at least the solution.  It wasn't to do
with accounts or profiles; I use an administrative account for my
Schedule service and that account has a mail profile of its own.

The solution, believe it or not, was to use the 'su' utility from the
Resource Kit to run my sendmail program under the same account that
the Schedule service already runs under.  Logically, that shouldn't
make any difference; in practice it does.  The sendmail.exe that comes
with MS Exchange 4.0 behaves in exactly the same way, so this isn't a
problem with my Perl code.  I think we've been dealing with a very
obscure bug in NT, MAPI or AML.

Thanks to everyone who made suggestions.  You confirmed that I hadn't
forgotten anything obvious and just needed to try something off-beat.

[Mailed and posted.  Follow-ups set to exclude c.l.p.m, where this is
no longer on topic.]

-- 
This email address is genuine but it will be changed as soon as
it starts to receive email spam.


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

Date: 9 Feb 1998 14:17:26 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Capturing file output
Message-Id: <6bn35m$bdj$1@lyra.csx.cam.ac.uk>

Paul Banks  <pbanks@ix.netcom.com> wrote:
>
>In c I would use fflush to flush the output, but that feature appears to
>be missing from perl.

It isn't missing from _my_ Perl.

Perhaps when you read the documentation, you missed $| in perlvar, and
$fh->autoflush and IO::Handle::flush.


Mike Guy


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

Date: Mon, 09 Feb 1998 09:24:57 -0600
From: patrick@cre8tivegroup.com
Subject: Fork/Threads
Message-Id: <6bn74t$92$1@nnrp2.dejanews.com>

Greetings all.  I've searched the archives for an answer to a problem I am
working on with no joy.

I am writing code for perl 5.004_04 to do a search of my web sites (on several
machines).  I'd like to do them all at the same time using one script.

This is the basic flow....

open a log file.
print an intro message to the log file.
concurrently examine all sites, writing results to the log file.
print concluding message to log file.
close log file.

I've tried fork() from the Camel book, but it forks the entire script, and not
just the code I want it to (I get the intro message multiple times). I know
threads are going to be part of 5.005,  but I want to "fake" implementation
now.

Hints, pointers, and sample code would be greatly appreciated :)

Patrick

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


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

Date: 9 Feb 1998 13:53:30 GMT
From: thomas.foerg@gebr-weiss.com (thomas foerg)
Subject: getting all global groups in winnt4
Message-Id: <6bn1oq$b1k$1@news.netway.at>

hi all.

i'm looking for a function in perl to get all global group of a domain.
avoiding any systemcommands.

would be glad to get any suggestions :-))

thaxs
thomas



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

Date: Mon, 9 Feb 1998 10:58:16 +0000
From: Jerry Pank <jerryp.usenet@connected.demon.co.uk>
Subject: Re: Good Perl editors
Message-Id: <338K6DAIFu30EwU4@connected.demon.co.uk>

In <comp.lang.perl.misc> 
Tom Christiansen <tchrist@mox.perl.com>, writes:
>In comp.lang.perl.misc, weyus@worldnet.att.net writes:
>:I am beginning to reacquaint myself with Perl and I was interested if
>:there were a preferred editor(s) that people out in Perl-land use for
>:coding.  
>
>Larry and I use vi -- or O'Reilly, depending on what kind of
>editor you mean.

In one of these recent  "which editor do you use..." threads, someone
suggested vim (Charityware. see http://www.vim.org/)

>From the helpfile intro:

"Vim stands for Vi IMproved.  It used to be Vi IMitation, but there are
so many improvements that a name change was appropriate.  Vim is a text
editor which includes almost all the commands from the Unix program "Vi"
and a lot of new ones.  It is very useful for editing programs and other
8-bit ASCII text.  All commands are given with the keyboard.  This has
the advantage that you can keep your fingers on the keyboard and your
eyes on the screen.  For those who want it, there is mouse support and a
GUI version with scrollbars and menus."

For the *nixically challenged there are ports for most operating
systems. Type :syntax on and you have a colour syntax highlighting for
63 'languages'.  Oh how did I ever do without this?

Goodbye notepad. Forever.

Welcome back Tom.
-- 
Jerry Pank                   mailto:jerryp@connected.demon.co.uk

In general, if you think something isn't in Perl, try it out, because it
usually is.  :-)
-- Larry Wall in <1991Jul31.174523.9447@netlabs.com>


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

Date: Mon, 09 Feb 1998 10:43:11 -0500
From: John Grubb <jgrubb@gte.net>
Subject: HELP - MULTIPLE LEVEL SORT?
Message-Id: <6bn86h$lvh$1@gte2.gte.net>

Can some one tell me how to perform multiple level sorts on a text data
file? I write to a pipe (|) delimited text file, including
$day|$month|$year|$time. I want to sort the entries by date, then time.
I am using the following to do a time-based sort, now, but I want to add
a date-based sort to it. Will I have to create a seperate TEMP file for
each date?:

     &GetFileLock ("$lock_file");

     open (USERFILE, "$auth_user_file") ||  &CgiDie ("Unable to open the

              user file. Please make note of
              this error and notify the Webmaster for this site.");

     while (<USERFILE>)
     {
          @database_fields = split (/\|/, $_);

          if ($_ =~ /^COMMENT:/)
          {
              $comment_row .= $_;
          }

          else
          {
              $sortable_row = "$database_fields[$field_num_time]~~" ;#
$field_num_time is pre-set to the 8th field (time).
              $sortable_row .= $_;
              push (@database_rows, $sortable_row);
          }
     }#End while (<USERFILE>)

     @sorted_temp_database = sort (@database_rows);

     foreach $database_row (@sorted_temp_database)
     {
          ($extra_event_time, $true_database_row) = split (/~~/,
$database_row);
          push (@final_sorted_database, $true_database_row);
     }

     close (USERFILE);

     open (TEMPFILE, ">$temp_file") || &CgiDie ("Unable to
              open the temp file.
              Please make note of this error and notify the
              Webmaster for this site.");

     print TEMPFILE "$comment_row";

     foreach $row (@final_sorted_database)
     {
          print TEMPFILE "$row";
     }

     close (TEMPFILE);

     rename ($temp_file, $auth_user_file);

     &ReleaseFileLock ("$lock_file");

     exit;




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

Date: Mon, 9 Feb 1998 06:10:47 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: email@business-links.co.uk
Subject: Re: Help with simple file search, please.
Message-Id: <Pine.GSO.3.96.980209060500.21932C-100000@user2.teleport.com>

On Sun, 8 Feb 1998 email@business-links.co.uk wrote:

> open (datafile, "file1.txt");

Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.
Also, it's a good idea to make filehandle names to be all caps.

> if ($a eq $find)	{@url=$link;}
> if ($b eq $find)	{@url=$link;}
> if ($c eq $find)	{@url=$link;}
> if ($d eq $find)	{@url=$link;}

You know that any one of those lines which succeeds is replacing @url
entirely, right? I'm suspecting that you really want something resembling
this: 

    if (   $a eq $find
	or $b eq $find
	or $c eq $find
	or $d eq $find	) {
	    push @url, $link;
    }

> 	print "Found1: ",$link,"<BR>";
> 	print "Found2: ",$found,"<BR>";

Why don't you use interpolation? There's nothing wrong with your code, but
it seems simpler to write it like this:

    print "Found1: $link<BR>Found2: $found<BR>";

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Mon, 9 Feb 1998 06:32:26 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Alex Dong Li <ali@genet.sickkids.on.ca>
Subject: Re: help: how to remove html tags from a file with perl?
Message-Id: <Pine.GSO.3.96.980209063031.21932G-100000@user2.teleport.com>

On Sun, 8 Feb 1998, Alex Dong Li wrote:

> I used the following code:
>       if ($line=~m/<[^>]+>/) {

That's not a good way to parse HTML. Use a module which parses HTML
instead. Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Mon, 09 Feb 1998 08:41:57 -0600
From: "Bhanu P. Suravarapu" <bhanu@usl.edu>
Subject: How can I pattern match a dos formated string (ctrl-m chars)
Message-Id: <34DF15B5.41C67EA6@usl.edu>

Hi,

I am using perl5

I get a document with the following statement.

$response = &www'request('GET', $url, *headers, *content, $Timeout);
 
Now the $content variable has the content in it but some sites have
the files in DOS format with the ctrl-m characters in them.

When I save that file using a browser it is something like
(the part of the document I am interested in)

<table border>^M
<tr>^M
<td>CATALOG #</td><td>DESCRIPTION</td><td>PRICE</td>^M
</tr>^M
<tr>^M
<td>BAY 3901</td><td>GLUCOMETER ELITE DIABETES CARE
SYSTEM</td><td>$130.00</td><
td><a href="./3901"><b><i>DETAILS</b></i></a></td> ^M
</tr>^M
<tr>^M
<tr>^M
<td>BMC 00860</td><td>ACCU-CHEK ADVANTAGE DIABETES CARE
KIT</td><td>$90.00</td><
td><a href="./00860"><b><i>DETAILS</b></i></a></td> ^M
</tr>^M
</table>

I am interested in getting the rows of this table using the first row
as the pattern to look for in a given table.
i.e, I need to get
<tr>^M
<td>BAY 3901</td><td>GLUCOMETER ELITE DIABETES CARE
SYSTEM</td><td>$130.00</td><
td><a href="./3901"><b><i>DETAILS</b></i></a></td> ^M
</tr>^M
<tr>^M
<tr>^M
<td>BMC 00860</td><td>ACCU-CHEK ADVANTAGE DIABETES CARE
KIT</td><td>$90.00</td><
td><a href="./00860"><b><i>DETAILS</b></i></a></td> ^M
</tr>^M

using the pattern

<table border>^M
<tr>^M
<td>CATALOG #</td><td>DESCRIPTION</td><td>PRICE</td>^M
</tr>^M

There is only one such table with the first row in the above given
pattern in a document.

Can this be done.

Thank you,

bhanu.
bhanu@usl.edu


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

Date: Mon, 09 Feb 1998 14:57:14 GMT
From: lg@kt.dtu.dk (Lars Gregersen)
Subject: Re: How do you call an .HTM from a Perl script?
Message-Id: <34df1868.4172597@130.228.3.8>

[p&m]
On 8 Feb 98 08:40:48 GMT, "Charles Wilkins" <thehelm@ibm.net> wrote:

>I am trying to call up HTM documents form my Perl scripts without using an
>anchor tag (hyperlink). Can anybody tell me how to do it?

What are you trying to do? You don't _call_ a htm document. Do you
want to upload or download a htm file? Is the file local or on the
internet? Maybe you want to have a module get the file for you or you
want to use ftp to upload the file(?). There is probably a module that
does what you want. Look at 
www.perl.com

I hope this helps!

  Lars

Lars Gregersen, M.Sc. Chem. Engng.
Department of Chemical Engineering, DTU, Denmark
E-mail:   lg@kt.dtu.dk
Homepage: http://www.gbar.dtu.dk/~matlg/


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

Date: 9 Feb 1998 09:46:40 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: How to get a listing of the file that is linked?
Message-Id: <6bn4sg$9vs@panix.com>

In <34DF946D.CCB74EB2@iris.eee.ntu.edu.sg> bz7347275@ntu.edu.sg writes:

>    I would like to know the time stamp of a file, but if it is
>symlinked, i got to cd to that
>    directory to check on that file.
>    How can i script perl in the way to check for the sym link then get
>the real time stamp
>    from the file?

With lstat -- see perlfunc:

  lstat - stat a symbolic link 

-- 
Clay Irving <clay@panix.com>                  I think, therefore I am. I think? 
http://www.panix.com/~clay/


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

Date: Mon, 09 Feb 1998 10:21:02 -0500
From: John Porter <jdporter@min.net>
Subject: Re: HREF tag parsing
Message-Id: <34DF1EDE.5DD0@min.net>

Don wrote:
> 
>[yadda]

I guess you've never heard of the HTML:: modules.

John Porter


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

Date: Mon, 9 Feb 1998 06:46:28 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Mr S A Penny <phuae@csv.warwick.ac.uk>
Subject: Re: Humour a newbie time... :)
Message-Id: <Pine.GSO.3.96.980209064005.21932K-100000@user2.teleport.com>

On 7 Feb 1998, Mr S A Penny wrote:

> Subject: Humour a newbie time... :)

Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.

    http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post

> is there a FAQ associated with this NG? if so where is it? 

That's good that you want to read the FAQ. Now, please don't misunderstand
this question that I'm about to ask. I'd like to help you, of course, but
I want also to help the many other people who have trouble finding the
FAQ. Can you please tell me where you looked for information about Perl
before you posted? Nearly every place that you might have looked should
have guided you to the FAQ. But maybe there are still a few which are
missing that pointer.

But if you go to a web search site like Yahoo and ask for 'perl faq',
you'll be sure to find it. Or you could try the perl.com and perl.org
websites. 

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

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Mon, 09 Feb 1998 09:06:25 -0600
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
Subject: Re: Installing Linux and Perl?
Message-Id: <34DF1B71.A817CCCA@houston.Geco-Prakla.slb.com>

David Hasbrouck wrote:
> 
> I am looking to install Linux and Perl on my own pc so I am able to test
> and debug Perl code before uploading to the server.
Good for you!  :-)

> I guess my question is, can this be done?
Yes

> Can I install Perl in a Linux environment?
Yes.

> If so, what 'distribution' of Linux?
Pick one.  I knew little (nothing really) about Linux when I started.  I
knew Unix pretty well, so Linux was only a mild side-step.

I have slakware 3.2 (2.0.29 kernel, I think) running at home, with perl
5.004_04 running on it.  It compiles and runs beautifully.  The
configure script looked for and found everything it needed with little
(or no?) intervention from me.

>  I checked out www.linux.org
Good place to look.

> and
> there are quite a few different choices...  If you could point me to a
> website to get further information regarding Linux.  I believe there is a
> slackware/free version somewhere..
All versions of Linux are the same.  The main differences involve how
the "distributor" decided to package the product.  I like slakware. 
Others are die hard RedHat fans.  Take your pick.

> 
> Thanks!
> 
> David Hasbrouck
> 
> -------------------==== Posted via Deja News ====-----------------------
>       http://www.dejanews.com/     Search, Read, Post to Usenet

HTH.

Dave

-- 
"Security through obscurity is no security at all."
		-comp.lang.perl.misc newsgroup posting

------------------------------------------------------------------------
* Dave Barnett               U.S.: barnett@houston.Geco-Prakla.slb.com *
* DAPD Software Support Eng  U.K.: barnett@gatwick.Geco-Prakla.slb.com *
------------------------------------------------------------------------


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

Date: 09 Feb 1998 08:08:49 -0700
From: Vladimir Alexiev <vladimir@cs.ualberta.ca>
To: perl-porters@perl.com
Subject: is one class per file necessary?
Message-Id: <om3ehs95og.fsf@tees.cs.ualberta.ca>

I'm writing a simple program that contains 7-8 classes of 20 lines
each. I'd like to keep it in one file, at least for the exploratory
stage. However, the following causes a ``Can't locate object method
"new" via package "Bar"'' error: 

  Bar->new;

  package Foo;
  sub new {}

  package Bar;
  @Bar::ISA='Foo';

When I move Foo and Bar to their separate classes Foo.pm and Bar.pm
and put the required "use" clauses, everything works ok.

What's the rationale for this, and is there a way to avoid it?


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

Date: Mon, 9 Feb 1998 06:28:52 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: ? the platypus {aka David Formosa} <dformosa@st.nepean.uws.edu.au>
Subject: Re: Is Perl 5 year 2000 compliant?
Message-Id: <Pine.GSO.3.96.980209062658.21932F-100000@user2.teleport.com>

On 9 Feb 1998, ? the platypus {aka David Formosa} wrote:

> The problem is that when multipal peaple give RTFM replies it gets some
> what repeadative.  A suggestion if you make a RTFM type reply why don't
> you set the message id to <rtfm.orginal-message-id> so only one reply
> will ever occour on the same newspool. 

The people in a newsgroup about Usenet itself can give you a lot of
reasons why that would be a Bad Thing to do. But if a thread seems too
repetitive to you, just kill the thread in your newsreader. Hope this
helps! 

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Mon, 09 Feb 1998 09:23:03 -0500
From: John Porter <jdporter@min.net>
Subject: Re: New Perl book reviews
Message-Id: <34DF1147.43F5@min.net>

Andy Lester wrote:
> 
> I've put up a page of Perl book reviews.  There are probably no
> surprises for regular readers of c.l.p.m., but I've had requests
> from newbie friends of mine, so there it is.
> 
> URL is http://ChicagoMusic.com/perl/

? What is this page trying to say about "Effective Perl"?
Very vague.

John Porter


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

Date: Mon, 9 Feb 1998 06:34:01 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Mike Ware <Mike.ware@gbjha.zeneca.com>
Subject: Re: Newbie:Perl Modules
Message-Id: <Pine.GSO.3.96.980209063254.21932H-100000@user2.teleport.com>

On Mon, 9 Feb 1998, Mike Ware wrote:

> Subject: Newbie:Perl Modules

Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.

    http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post

> however when I try to write a script which uses a module e.g the
> file:copy.pm I am returned the error "Unable to locate copy.pm in @INC"
> 
> even if I push the path onto the INC array at the beginning of the script.

'use' happens at compile time, but the push happens at runtime. Use 'use
lib' instead of push. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Mon, 09 Feb 1998 09:13:29 -0600
From: Jonathan Higbee <petcrows@bigfoot.com>
To: petcrows@bigfoot.com
Subject: Re: Passing Javascript variables to Perl CGI?
Message-Id: <887036700.559611909@dejanews.com>

In article <886603945.855572489@dejanews.com>,
  petcrows@bigfoot.com wrote:
>
> Greetings.
>
> I would like to log to a file all the referring http pages that
> access my site as well as the user's host name. The HTTP_REFERER
> variable is not available in Perl CGI on my ISPs server, but the
> Javascript document.referrer does work ok.
>
> Thus how to I pass JScript document.referrer to a Perl CGI, and if I
> wanted to pass other JScript items how can that be done?

Here is the solution I have come up with thus far (using cookies)...

First the javascript & then the perl:

[I put the script in the header of the html file.]

<SCRIPT LANGUAGE="JavaScript">
<!----------

var from = document.referrer // page the user is comming from

<!-- This part of a script and many more are available online from -->
<!-- The JavaScript Source!! http://javascriptsource.com -->

netscapeTest = parseInt(navigator.appVersion)
explorerTest = navigator.appName.indexOf("Microsoft") + 1

function netscapeThree() {
   if (navigator.javaEnabled()) {
      userDomain = java.net.InetAddress.getLocalHostName()
      return (userDomain.toString())
   }
   else {
      return null
   }
}

function netscapeFour() {
   if (navigator.javaEnabled()) {
      baseAddress = java.net.InetAddress.getLocalHost()
      userDomain = baseAddress.getHostName()
      return (userDomain.toString())
      }
   else {
      return null
   }
}

if ((explorerTest == "0") && (netscapeTest == "3")) {  domainName =
netscapeThree() } else if ((explorerTest == "0") && (netscapeTest ==
"4")) {  domainName = netscapeFour() } else {  domainName = "Explorer"; 
domainName = netscapeFour() //	domainName = "using Internet Explorer? 
Then I don\'t know what your IP address is." } //alert('Are you really '
+ domainName + ' ?')

var host = domainName;

// var here =
"http://www.ieighty.net/~jhigbee/filter_page_for_journal.htm" //previous
page

// alert("From:"+from);//remove this line to use the script for real
//alert("Here:"+here);//remove this line to use the script for real
// else history.back()
// else document.location.replace('dogma.htm'); //Page to go to if OK

write_cookie ("Birdage_referrer_cookie",from);
write_cookie ("Birdage_host_cookie",host);

alert (host);

/******************************************************************************
function write_cookie (name, value);
function write_cookie (name, value, path);

write_cookie creates a cookie with the name, value, and path given in the
parameters.  If no path is supplied, write_cookie uses the document's
default cookie path.  Each cookie is set with an expiration time of 1
year.
*************************************************************************
*****/

function write_cookie (name, value, path)
{
// Build the expiration date string:
   var expiration_date = new Date ();
   var Month = expiration_date . getMonth();
   var Day = expiration_date . getDay();
   var Year = expiration_date . getYear();

// alert (expiration_date);
// alert (Month);
// alert (Day);
// alert (Year);

  Day = 1; // The getDay() function does not work properly - therefore
just set it to one and increment the Month 2 times

   Month = eval(Month) + 2;

//   alert (Month);

  if (Month == 12) {  // The Month value starts from 0	Month = 0;  //
set the expiration date to be the 1st day of whichever month is 2 months
away from the current  Year = Year + 1;  // month. Thus the month is
incremented by 2, but the day is set to 1.  }  if (Month > 12) {  Month =
1;  Year = Year + 1;  }

//   alert (Month);
//   alert (Year);

//   expiration_date . setYear (expiration_date . getYear () + 1);

//   alert (expiration_date);
   expiration_date . setMonth (Month);  // Expire cookie after a month
   expiration_date . setDate (Day);
   expiration_date . setYear(Year);

//   alert (expiration_date);

   expiration_date = expiration_date . toGMTString ();

//   alert (expiration_date);

// Build the set-cookie string:  var cookie_string = escape (name) + "="
+ escape (value) + "; expires=" + expiration_date;  if (path != null)
cookie_string += "; path=" + path;

// Create/update the cookie:
   document . cookie = cookie_string;
}

/******************************************************************************
                        function read_cookie (key)
                        function read_cookie (key, skips)

  read_cookie searches through the current document's cookie string
(i.e., the  concatenation of all cookies readable by the current
document) for a cookie	whose name is identical to key.  If read_cookie
finds a matching cookie, it  returns a string containing the value of
cookie.  If read_cookie cannot find a  match, it returns null instead.

  An optional skips parameter may be supplied if there is a need to
select among  multiple cookies with the same name.  If a skips parameter
is supplied,  read_cookie will skip that many occurrences of matching
cookies and then return  the next one it finds, or null if there aren't
any more.

******************************************************************************/

function read_cookie (key, skips)  {  // Set skips to 0 if parameter was
omitted:  if (skips == null)  skips = 0;

  // Get cookie string and separate into individual cookie phrases:  var
cookie_string = "" + document . cookie;  var cookie_array = cookie_string
 .. split ("; ");

  // Scan for desired cookie:  for (var i = 0; i < cookie_array . length;
++ i)  {  var single_cookie = cookie_array [i] . split ("=");  if
(single_cookie . length != 2)  continue;  var name  = unescape
(single_cookie [0]);  var value = unescape (single_cookie [1]);

                                        // Return cookie if found:
                                        if (key == name && skips -- == 0)
                                                return value;
                                }

                                // Cookie was not found:
                                return null;
                        }

// JavaScript ends ---------->
</SCRIPT>

To call the program I used: <!--#exec cgi="logger.pl"-->
in the body of the page.

Perl...

logger.pl:

#!/usr/local/bin/perl

require 'cookie.lib';

$mainlog = "main.log";
$shortdate = `date +"%D %T %Z"`;
chop ($shortdate);
#print "Content-type: text/plain\n\n";

&GetCookies();

$referrer_cookie_name = 'Birdage_referrer_cookie';
$host_cookie_name = 'Birdage_host_cookie';

$referrer_value = $Cookies{$referrer_cookiename};
$host_value = $Cookies{$host_cookie_name};


open (MAINLOG, ">>$mainlog");
print MAINLOG "Time: $shortdate\n";
print MAINLOG "User: $ENV{'REMOTE_IDENT'}\n";
print MAINLOG "Host: $ENV{'REMOTE_HOST'}\n";
print MAINLOG "Addr: $ENV{'REMOTE_ADDR'}\n";
print MAINLOG "With: $ENV{'HTTP_USER_AGENT'}\n";
print MAINLOG "Page: $ENV{'DOCUMENT_URI'}\n";
#print MAINLOG "From1: $ENV{'HTTP_REFERER'}\n\n";
print MAINLOG "From: $referrer_value";

#print $testing;
close (MAINLOG);
exit;

cookie.lib is downloadable from
http://www.worldwidemart.com/scripts/cookielib.shtml

If you have a better solution let me know.

Jonathan Higbee
http://www.ieighty.net/~jhigbee/birds.htm
petcrows@bigfoot.com

p.s. After a great deal of searching I finally found a non-cryptic
tutorial on perl associative arrays at:
http://www2.ec-lille.fr/~seguy/english/perl/index.html

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: 9 Feb 1998 14:49:42 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Perl documentation (was re: Perl Year 2000 ...)
Message-Id: <6bn526$or7$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, mwang@alhena.ibk.ml.com (Michael Wang) writes:
:It would be helpful to have a man page for each perl functions, like
:C does. Because sometimes people just want to find the syntax. 

These exist, but are not automatically installed.  The splitman program
in the pod directory can be coerced into producing such.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com
    last|perl -pe '$_ x=/(..:..)...(.*)/&&"'$1'"ge$1&&"'$1'"lt$2'
    That's gonna be tough for Randal to beat...  :-)
            --Larry Wall in  <1991Apr29.072206.5621@jpl-devvax.jpl.nasa.gov>


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

Date: Mon, 09 Feb 1998 14:41:41 GMT
From: "Craig A. Keefner" <keefner@kinetic.com>
To: William van Zwanenberg <will@willz.demon.co.uk>
Subject: Re: Porting Unix Perl scripts to Win NT
Message-Id: <34DF143F.B4B88482@kinetic.com>

there can be differences but for the most part all of my Solaris
scripts work the same on my IIS machine and vice versa.
perl.com has links to Win32 code and there are some good faqs
available for win32.

Craig

William van Zwanenberg wrote:

> This has probably been covered by this newsgroup a thousand times already
> but can anyone advise as to good web sites that I might look at that will
> teach me how to go about porting some Perl CGI scripts that have been
> written for a unix based Web server (Sun Solaris machine running Apache
> Web Server) to an Windows NT server running Internet Information server?
>





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

Date: 9 Feb 1998 09:35:57 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Q: Using unpack or split to get fixed-length substrings?
Message-Id: <6bn48d$8t4@panix.com>

In <x5lnvlhtw5.fsf@beagle.bmc.uu.se> Morten Stig Andersen <Morten.Andersen@molbio.uu.se> writes:

>Can someone please help me with this:

>I want to break ascii strings into fixed-length substrings as efficient
>as possible. I have a string like

>my $string = "aaabbbcccd";

>If my fixed-length is three, I want it split into a list of substrings
>like: ("aaa", "bbb", "ccc", "d")

>I've tried 

>@array = split(/(\w{3})/, $string);    # Spits out empty fields as well
>@array = split(/(?:\w{3})/, $string);  # @array is empty

>and other variants that didn't work. The split manual page tells me to
>use unpack, but I can only get one element out here:

>@array = unpack "a3", $string;         # @array now equals ("aaa");

Give it the rest of the format:

  @array = unpack "a3a3a3a3", $string;

Now print each element of @array:

  @array = unpack "a3a3a3a3", $string;
  foreach (@array) {
    print "$_\n";
  }

output:

  aaa
  bbb
  ccc
  d

-- 
Clay Irving <clay@panix.com>                  I think, therefore I am. I think? 
http://www.panix.com/~clay/


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

Date: Mon, 9 Feb 1998 06:39:46 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Morten Stig Andersen <Morten.Andersen@molbio.uu.se>
Subject: Re: Q: Using unpack or split to get fixed-length substrings?
Message-Id: <Pine.GSO.3.96.980209063842.21932J-100000@user2.teleport.com>

On 9 Feb 1998, Morten Stig Andersen wrote:

> I want to break ascii strings into fixed-length substrings as efficient
> as possible. I have a string like
> 
> my $string = "aaabbbcccd";
> 
> If my fixed-length is three, I want it split into a list of substrings
> like: ("aaa", "bbb", "ccc", "d")

Is this what you need?

    my $string = "aaabbbcccd";
    my @list = ($string =~ /(.{1,3})/g);

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 9 Feb 1998 14:50:31 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: returning the date
Message-Id: <6bn53n$ova$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    Andrew Johnson <ajohnson@gpu.srv.ualberta.ca> writes:
:but using all four digits in the year,
:printf "Today is %02d/%02d/%04d",++$mon,$dd,$yy+1900;
:is probably a better way to go.

I don't think you should use MM/DD/YYYY either.  Is that really MM/DD
or DD/MM?  ISO says DD/MM/YYYY, but as you see, that has the same problem.

Personally, I've always like 23-Apr-1998, or the Spanish style of
23-IV-1998.  But the former is surely offensive to someone, and the
latter is surely offensive to someone else. :-(

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


You are unlucky enough to bump into all my rough edges.  --Andrew Hume


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

Date: Mon, 9 Feb 1998 06:34:52 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Hans Van Lint <hvanlint@lodestar.be>
Subject: Re: sorting an associative array
Message-Id: <Pine.GSO.3.96.980209063418.21932I-100000@user2.teleport.com>

On Mon, 9 Feb 1998, Hans Van Lint wrote:

> Subject: sorting an associative array

These days, we call them "hashes". Have you seen the FAQ? Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 9 Feb 1998 14:50:09 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Tie-Dee-Perl (Cleanliness is next to Goodliness, or Perl-White Code)
Message-Id: <6bn532$ot8$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, stampes@xilinx.com (Jeff Stampes) writes:
:As more readable alternatives to && and ||, Perl provides ``and'' and
:``or'' operators (see below). 

I think this one was something we didn't think through.  Consider:

    unlink $a, $b, $c || die;
    $a = $b || $c;

    unlink $a, $b, $c or die;
    $a = $b or $c;

In both cases, one is wrong.  But it's a different one.  Also, the "or"
doesn't stand out very well.  I'm starting to learn back toward having
people learn precedence.  You can't use either one without knowing
precedence, so making another operator with another precedence just
changes where the problem shows up and makes everything harder.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com
    Perl is designed to give you several ways to do anything, so
    consider picking the most readable one.
            --Larry Wall in the perl man page


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

Date: 9 Feb 1998 15:14:05 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Tie-Dee-Perl (Cleanliness is next to Goodliness, or Perl-White Code)
Message-Id: <6bn6ft$dc3$1@lyra.csx.cam.ac.uk>

Jason Christian  <jason@primal.ucdavis.edu> wrote:
>On 4 Feb 1998, Craig Berry wrote:
>
>>   open NUMBERS, "< numbers.txt" or die "Can't open numbers.txt: $!";
>>   $numbers = <NUMBERS>;
>>   close NUMBERS;
>
>Following the age-old advice to lurk before posting, I did manage to
>avoid breaking cplm rule number one, which reads "never say 'open'
>without saying 'die'," or something like that.  That rule is more about
>practicality than simply cleanliness:  it is nice to know what broke.
>
>But how about closing files?  Being sloppy, I confess that in the
>privacy of my own home I occasionally leave doors open; it may be the
>case that I do this occasionally in a Perl script.  What is the cost of
>this sloppiness?

The reasons for an explicit close and test of the result are much the
same as for open   -   you catch errors which would otherwise
be ignored.    Possible errors on close are more obscure, so there's
a tendency not to bother.    But because they are more obscure, they
are also more subversive.

Here are some cases:

i)   If you get an I/O error on reading, the read will return undef,
     as if at eof.    The actual error will only be reported by close
     so if you don't check, you'll operate on a truncated input with
     perhaps disastrous consequences.    Such errors more commonly
     happen on pipes or sockets, but real disc I/O errors do happen
     sometimes.     And nfs network connections can fail.

ii)  If you get an I/O error on writing, the print (or whatever)
     will return false.    And when did you last (deliberately) test
     the result of a print?    But you'll get told on the close.

iii) If the filehandle was opened with  open FH, "|cmd"  or
     open FH, "cmd|" ,  the only way you'll find out if the command
     succeeded is by checking the close.   Also, until the filehandle
     is closed (implicitly or explicitly), the child process will
     hang around as a "zombie".    That's rather more embarassing
     than the memory tied up by an open filehandle.

So I _always_ check the result of close in production scripts.
In jiffy one-offs, I'm a bit lazier.


Mike Guy


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

Date: Mon, 09 Feb 1998 15:44:16 +0000
From: Ben Holness <bholness@nortel.ca>
Subject: Two Perl programs -> One html output (real time)
Message-Id: <34DF2450.6AB1@nortel.ca>

Hi all,

Does anyone know how I can merge two perl scripts to one html output:

I have two perl scripts, p1.pl and p2.pl, each which contain print
statements that print to the web page in real time.

Each of them can be run separately, by clicking on the /cgi-bin/p1.pl or
/cgi-bin/p2.pl links, but I would like the following to happen:

When the user clicks on /cgi-bin/p1.pl, the output of p1.pl is displayed
as normal on the screen, followed by an <hr> break (which I can add at
the end of the p1.pl file), followed by the output of p2.pl

I have tried running p2.pl from p1.pl, using the system command, but
this does not seem to work.

Any ideas?

Cheers,

Ben
-- 
  _____________________________________
 /                                     \
|        *-=Ben Holness=-*              |
|                                       |
|    Dept. 7e24 % bholness@nortel.ca    |
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-|
| ESN: 590-4957 % PSTN: (01628) 434957	|
|=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=|


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

Date: Mon, 9 Feb 1998 06:47:55 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Mikael Skogstrom <mikael@techtalk.se>
Subject: Re: Using flock?
Message-Id: <Pine.GSO.3.96.980209064703.21932L-100000@user2.teleport.com>

On Mon, 9 Feb 1998, Mikael Skogstrom wrote:

> I know you're supposed to use FLOCK to lock a file from beeing used by
> more than one script at a time. But I really haven't understood why;
> shouldn't the OS take care of it, so that no more than one program can
> write at a time? 

Whether or not the OS should, on many systems it doesn't. And it's a
little late to change that now! :-)

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

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 1837
**************************************

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