[12451] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6051 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 18 20:28:33 1999

Date: Fri, 18 Jun 99 17:00:20 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 18 Jun 1999     Volume: 8 Number: 6051

Today's topics:
    Re: Afraid to ask about Y2K! <flavell@mail.cern.ch>
    Re: Afraid to ask about Y2K! (Lee)
    Re: Afraid to ask about Y2K! (Jerome O'Neil)
    Re: Afraid to ask about Y2K! (Andrew Allen)
        Beginner program <amirs@uclink4.berkeley.edu>
        case problem with HTTP::Request phil@demoserver.com
    Re: changing directories <ywong@andrew.cmu.edu>
    Re: changing directories <rootbeer@redcat.com>
    Re: Database Management Problem <forman@cybersource.com>
    Re: e-mail client <rootbeer@redcat.com>
    Re: Is Perl4 Y2K compliant? <bachrach@*God-I-hate-spam*bigfoot.com>
    Re: Is Perl4 Y2K compliant? <dwb1@home.com>
        Match diff with '\s*' vs ' ' <pautler@hawaii.edu>
    Re: Neet Perl Obfucation Program (Jerome O'Neil)
        Perl and dialog <storm@hi-line.net>
        Perl Module query j_raff@my-deja.com
    Re: Perl Module query <jeffp@crusoe.net>
    Re: Perl Module query <rootbeer@redcat.com>
    Re: problems with eval <rootbeer@redcat.com>
    Re: Recommend a simple Online database? <rra@stanford.edu>
    Re: Recommend a simple Online database? <tchrist@mox.perl.com>
    Re: Recommend a simple Online database? <cassell@mail.cor.epa.gov>
    Re: Relocation error in Socket.so <rootbeer@redcat.com>
    Re: s/\s/ /g does not work for me... why??!! <rootbeer@redcat.com>
    Re: s/\s/ /g does not work for me... why??!! <unclelui@grin.net>
        sleeping vs stopping and restarting (Gregory Snow)
    Re: Variable substitution problem <tchrist@mox.perl.com>
    Re: Variable substitution problem <tchrist@mox.perl.com>
        Where is IO::Socket module? <seongbae@students.uiuc.edu>
    Re: Where is IO::Socket module? <rra@stanford.edu>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Sat, 19 Jun 1999 00:04:26 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Afraid to ask about Y2K!
Message-Id: <Pine.HPP.3.95a.990619000313.16126B-100000@hpplus01.cern.ch>


On Fri, 18 Jun 1999, Chris Nandor wrote:

> Probably.  But c'est la vie.  I don't have an opinion on whether the
> standard library should return years since 1900 or years since 0.  I
> support Perl using the standard library which happens to return years
> since 1900.

Quite.  I dimly remember, in about 1968, reading some operating system
source code that says "Warning, this code will not work in 2100", and
thinking that was pretty obvious.  Indeed, this code is not working
today, since the platform on which it ran has long since been laid to
rest, but at least the programmer (MJTG, do you know who it was by any
chance? - maybe even yourself)  had thought about it. 

[Supplementary question, why did it say 2100 and not 2000.  No, that's
too easy for clpm denizens.]

-- 

          The British attitude is essentially that it is better to have 
          100% of nothing than 25% of something. - D.Hansen, uk.railway








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

Date: Fri, 18 Jun 1999 17:38:33 -0500
From: rlb@intrinsix.ca (Lee)
Subject: Re: Afraid to ask about Y2K!
Message-Id: <B390349996689A6CBF@0.0.0.0>

In article <pudge-1806991606350001@192.168.0.77>,
pudge@pobox.com (Chris Nandor) wrote:

># Yet, wouldn't there be fewer Y2K problems in C and Perl programs
># if localtime() returned the full four digit year?
>
>Probably.  But c'est la vie.  I don't have an opinion on whether the
>standard library should return years since 1900 or years since 0.  I
>support Perl using the standard library which happens to return years
>since 1900.

We're almost 30 years too late to make substantive design changes to
localtime(). But even in the libraries, it would be nice to have something
between localtime() and strftime(). A humantime() function, perhaps, that
returned "real" years, and didn't zero-index days of the week and months of
the year.

In Perl, I *expect* to find the imaginary humantime() function. This is one
of the few times it has left me disappointed.

Lee




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

Date: 18 Jun 1999 23:05:18 GMT
From: jeromeo@atrieva.com (Jerome O'Neil)
Subject: Re: Afraid to ask about Y2K!
Message-Id: <7kejbe$bbf$1@brokaw.wa.com>

In article <B390349996689A6CBF@0.0.0.0>,
	rlb@intrinsix.ca (Lee) writes:
> In Perl, I *expect* to find the imaginary humantime() function. This is one
> of the few times it has left me disappointed.

How do you feel about localtime() called in scalar context?


-- 
Jerome O'Neil, Operations and Information Services
Atrieva Corporation, 600 University St., Ste. 911, Seattle, WA 98101
jeromeo@atrieva.com - Voice:206/749-2947 
The Atrieva Service: Safe and Easy Online Backup  http://www.atrieva.com


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

Date: 18 Jun 1999 23:40:29 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: Afraid to ask about Y2K!
Message-Id: <7keldd$7e7$1@fcnews.fc.hp.com>

Lee (rlb@intrinsix.ca) wrote:
: In Perl, I *expect* to find the imaginary humantime() function. This is one
: of the few times it has left me disappointed.

Something other than POSIX::strftime?

Andrew


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

Date: Fri, 18 Jun 1999 16:32:45 -0700
From: Amir Schricker <amirs@uclink4.berkeley.edu>
Subject: Beginner program
Message-Id: <376AD71D.98EE1369@uclink4.berkeley.edu>

I have the following problem:

I have a long text file with a thousands of short lines in it. About
every 15 lines or so there are the following two consecutive lines:

Maximum at   x
mean = y

where x and y are some numbers.

I want to write a Perl script to go and extract those numbers (x and y)
from only those lines.

I'm a Perl newcomer, I just started reading this Programming Perl
(Oreilly) book this morning, with not that much help. I've gotten as far
as being able to isolate just those two lines from the file, with a
while loop and two if ($line =~ /pattern/) statements, but now I need to
extract just the numbers out. Any ideas how?

If possible, please email me as well as replying to the newsgroup as I
can't check the newsgroup that often. Thanks in advance.


Amir




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

Date: Fri, 18 Jun 1999 21:51:25 GMT
From: phil@demoserver.com
Subject: case problem with HTTP::Request
Message-Id: <7kef0q$tj5$1@nnrp1.deja.com>

Hello,

I am using HTTP::Request module to connect with a custom HTTP
application. The problem I am seeing is that even though my code has
this:

my $req = HTTP::Request->new(GET => $url);
$req->referer("http://www.yahoo.com");
$req->header("Client-ip" => "204.71.200.68");

The actual request made looks like this when I snoop packets:
Client-Ip: 204.71.200.68

Why is the "I" in Client-Ip getting switched to uppercase? Any way to
avoid this?? It is crashing my app!

Thanks!
Phil


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


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

Date: Fri, 18 Jun 1999 18:02:57 -0400
From: interface <ywong@andrew.cmu.edu>
Subject: Re: changing directories
Message-Id: <Pine.SOL.3.96L.990618180217.13257B-100000@unix7.andrew.cmu.edu>


Never mind, I figured it out.  There was a[n embarrasingly stupid] error
in my test script.


Yishan Wong				    www.contrib.andrew.cmu.edu/~ywong
--------------------------------o			  sciscita proximitas



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

Date: Fri, 18 Jun 1999 16:07:02 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: changing directories
Message-Id: <Pine.GSO.4.02A.9906181605220.5420-100000@user2.teleport.com>

On Fri, 18 Jun 1999, interface wrote:

> "chdir" and "system" calls to change the dir seem to launch a separate
> process, change the dir _in_ that process, and then return, leaving
> the script sitting where it used to.

A child process can't change the directory of the parent process. But the
built-in chdir should be changing the directory - or you can find out why
not.

    chdir $somewhere 
	or die "Can't chdir: $!";

Once you've changed, that working directory will be inherited by any
subprocesses you start. Cheers!

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



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

Date: Fri, 18 Jun 1999 16:36:22 -0700
From: Tim Forman <forman@cybersource.com>
Subject: Re: Database Management Problem
Message-Id: <376AD7F6.D05BB63D@cybersource.com>

Of course there is more than one way to do it, and I didn't spend a lot of time
exploring
this, but for the delete you could try:

sub DeleteCarFromDatabase
{

open(DB,"<" . "$cardatabase") || die " Cannot open $cardatabase \n";

open (NEWFILE, ">foo2.txt") || die "Can't open a new file\n";

while (<DB>)
  {
   $db = $_;
   ($db_id,$make,$model,$year,$miles,$price,$etc,$image)=split("::",$db);

   if($db_id != $id){
      print (NEWFILE "$db");
   }#end if

  }
 close(NEWFILE);
 close(DB);
`mv foo2.txt foo.txt`;
}

There is probably a better way to alter a file while it's open, but I made a
tempfile called
foo2.pl and then moved the file with the deleted records to the old filename(foo
for me).
This worked for me, but I'm sure it has flaws.  I spent more time writing the
message than
the code.

Tim

Matt wrote:

> Hi,
>
> I'm using a plain old text file delimited by colons :::: and certain
> routines just aren't working out.  Here's some of my code and an
> explanation.
>
> THIS ROUTINE ADDS A RECORD TO THE DATABASE
>
> sub AddCarToDatabase
> {
>  open (DBW, ">> $cardatabase") || print "Content-type: text/html\n\n Can't
> write to $cardatabase ($!)";
>  $newrecord =
> $id."::".$make."::".$model."::".$year."::".$miles."::".$price."::".$etc."::"
> .$image."\n";
>  print DBW $newrecord;
>  close(DBW);
>
>  &DisplayCars;
> }
>
> The above routine will make the text file look like this (as an example):
>
> 1300::ford::mondeo::1119::342322::255252::pw/pw CD/AM/FM!::ford0002.jpg
> 1301::ford::mondeo::1119::342322::255252::pw/pw CD/AM/FM!::ford0002.jpg
> 1302::ford::mondeo::1119::342322::255252::pw/pw CD/AM/FM!::ford0002.jpg
>
> Now, the adding of cars works great!  Until I try to delete or sort
> one...here's the code for delete:
> Note: on the matching I used :+ so that it would work with any combination
> of delimitation by colons.
>
> sub DeleteCarFromDatabase
> {
>  open (DB, "<$cardatabase") || print "Content-type: text/html\n\n Can't read
> $cardatabase ($!)";
>  while (<DB>)
>   {
>    $db .= $_;
>   }
>    $db =~ s/$id:+.*:+.*:+.*:+.*:+.*:+.*:+.*\n//;    # in ActiveState this
> WORKS!!!   In UNIX it seems not to!!!!
>  close(DB);
>
>  open (DBW, ">$cardatabase") || print "Content-type: text/html\n\n Can't
> write to $cardatabase ($!)";
>  print DBW $db;
>  close(DBW);
>
>  &DisplayCars;
> }
>
> THIS ROUTINE SORTS THE RECORDS BY ID
>
> sub SortByID
> {
>  open (DB, "< $cardatabase") || print "Content-type: text/html\n\n Can't
> read $cardatabase ($!)";
>  @db_lines = <DB>; # READ THE DATABASE INTO AN ARRAY - EACH LINE ITS OWN
> ELEMENT
>  @sorted = sort(@db_lines);  # SORT THE LINES - IN THIS CASE BY THE ID SINCE
> IT COMES FIRST
>  close(DB);
>
>  open (DBW, "> $cardatabase") || print "Content-type: text/html\n\n Can't
> write to $cardatabase ($!)";
>  print DBW @sorted; # OVERWRITE ALL CONTENTS OF DATABASE WITH NEW SORTED
> DATABASE
>  close(DBW);
>
>  &DisplayCars;
> }
>
> My PROBLEM is that after I try to delete or sort the database it doesn't
> delete or sort but it adds records.  Probably because it takes each part of
> the text file line by line, and if it finds an extra \n somewhere it turns
> that into something like this:
>
> 1300::ford::mondeo::1119::342322::255252::pw/pw CD/AM/FM!::ford0002.jpg
> 1301::ford::mondeo::1119::342322::255252::pw/pw CD/AM/FM!::ford0002.jpg
> 1302::ford::mondeo::1119::342322::255252::pw/pw CD/AM/FM!::ford0002.jpg
> 1301::::::::::::::
>
> And thus I get a text database looking like that.  If I try to delete 1301
> it adds a record with 1301 and those extra colons.  If I sort them I just
> get a bunch of colons (no 1301 in front).
>
> Any help appreciated.  My PERL coding and coding in general SUCKS and needs
> lots of work.  Open to criticism, just not flames.
>
> -Matt






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

Date: Fri, 18 Jun 1999 15:53:35 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: e-mail client
Message-Id: <Pine.GSO.4.02A.9906181548120.5420-100000@user2.teleport.com>

On Fri, 18 Jun 1999, GiN wrote:

> Hi, i'm working on a e-mail client
> but i have some problems with the protocol i think

Perhaps you should check the docs, FAQs, and newsgroups about the
protocol, if you really want to implement it.

>         print S "HELO $host\n";

You should probably be using a module to do this. A properly-written
module will follow the protocol already, so nearly all of your work is
done for you. Have you looked on CPAN?

>         print S "X-Mailer: Mozilla 4.6 [en] (Win98; I)\n";

Hehehe!

>         print S "To: <$ercpt>\n";
>         print S "@mesg";

Hmmm....

Of course, if you're going to be sending spam, you should probably redo
this in Intercal. Cheers!

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



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

Date: Fri, 18 Jun 1999 22:24:29 GMT
From: "bachrach V2.0" <bachrach@*God-I-hate-spam*bigfoot.com>
Subject: Re: Is Perl4 Y2K compliant?
Message-Id: <xGza3.766$yE1.54201@monger.newsread.com>

Daniel W. Burke wrote in message ...
>
>Hopefully I can wade through all these messages to see the response...
>but, can perl4 be considered "Y2K Compliant"?  I imagine so, but we have
>an aweful lot of scripts at work that run off perl4/oraperl...
>I don't think anyone else has thought to ask at work wether or not we
should
>take the time to make sure all the scripts work with perl 5, and just
update
>the darn things, but I figured better I better ask :)


Okay, maybe there's just something I'm missing, but how can a programming
language itself by Y2K compliant? I mean, when you make a program that has
some sort of a date feature, you store it as either a 2 or 4 digit number.
Each program that you wrote in perl then would have to be Y2K complaint at
your end - either you made it correctly or not. How exactly would a language
itself be or not be Y2K compliant? Perl itself isn't executable, it's the
compilers, interpreters, and programs you make with it that are or are not
Y2K compliant.

--
Do something good with your life:
http://www.vjnews.com/iranpetition.htm

Get free stock in an internet company (I ain't kidding)
http://www.tradehall.com/cgi-bin/trader/hs.cgi?run=invest
and if you could be so kind as to put in refrence number 10235784 I'd
*really* apreciate it





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

Date: Fri, 18 Jun 1999 23:46:05 GMT
From: "Daniel W. Burke" <dwb1@home.com>
Subject: Re: Is Perl4 Y2K compliant?
Message-Id: <Pine.LNX.3.96.990618191749.24304A-100000@cc569157-a.warn1.mi.home.com>

On Fri, 18 Jun 1999, bachrach V2.0 wrote:

> Okay, maybe there's just something I'm missing, but how can a programming
> language itself by Y2K compliant? I mean, when you make a program that has
> some sort of a date feature, you store it as either a 2 or 4 digit number.
> Each program that you wrote in perl then would have to be Y2K complaint at
> your end - either you made it correctly or not. How exactly would a language
> itself be or not be Y2K compliant? Perl itself isn't executable, it's the
> compilers, interpreters, and programs you make with it that are or are not
> Y2K compliant.
> 
I can't speak for anyone else, but my concern is for the built-in functions
and or variables the language has.  As a result of my seeking if perl4 is
"Y2K Compliant" I've learned about the odd-ness (well, I think it's odd) of
how localtime() returns the year, and was able to fix 2 scripts this morning.

I think the problem is, that too many people have asked :)
I tried looking around for my answer, and found some Y2K info about perl in
general, but it did not mention what version it was referring to, just v5, or
perl in general... and hey, better safe then sorry...

Dan.




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

Date: Fri, 18 Jun 1999 12:59:54 -1000
From: David Pautler <pautler@hawaii.edu>
Subject: Match diff with '\s*' vs ' '
Message-Id: <376ACF69.518198BA@hawaii.edu>

I'm new to Perl and using egrep to try to understand problems in my
regexprs.

Below, I'm getting a successful match with a regexpr that ends in ' <',
but a regexpr that's the same except for ending in '\s*<' is failing.  I
can only guess that this has something to do with the greediness of
'\s*'.

--------------
/disk1/users/pautler% egrep     "Availability\s*</B>\s*:? <"
bc-Perl5Peschko1.htm

<FONT FACE = "Arial, Helvetica"><B>Availability</B>: <FONT FACE =
"Arial, Helvetica" SIZE = "-1"><A
HREF="http://www.books.com/scripts/xahelp.exe?sid~vZWFlm3eIb4zBaP/index~AVAIL">Usually
ships in 2-3 business days</A></FONT>.
--------------

/disk1/users/pautler% egrep    "Availability\s*</B>\s*:?\s*<"
bc-Perl5Peschko1.htm
/disk1/users/pautler%
--------------

Would someone explain why one match works and the other doesn't?

    -dp-




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

Date: 18 Jun 1999 22:18:32 GMT
From: jeromeo@atrieva.com (Jerome O'Neil)
Subject: Re: Neet Perl Obfucation Program
Message-Id: <7kegjo$a6h$1@brokaw.wa.com>

In article <376AB35B.DC356344@mail.cor.epa.gov>,
	David Cassell <cassell@mail.cor.epa.gov> writes:
> I guess we're all so used to the 'fun' of de-munging anti-spam
> addresses that it becomes mechanical after a while.

Indeed.  I guess I need to be more carefull.

Rats.

-- 
Jerome O'Neil, Operations and Information Services
Atrieva Corporation, 600 University St., Ste. 911, Seattle, WA 98101
jeromeo@atrieva.com - Voice:206/749-2947 
The Atrieva Service: Safe and Easy Online Backup  http://www.atrieva.com


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

Date: Sat, 19 Jun 1999 05:39:50 -0600
From: storm <storm@hi-line.net>
Subject: Perl and dialog
Message-Id: <376B8186.19CB2B2B@hi-line.net>

I'm trying to improve our adduser script with perl and want to use
dialog to add menus to a couple places.  I'm using RedHat 5.2, dialog
0.6 and perl version 5.004004 (?).

The dialog readme says, in part, "*  New dialog.pl perl interface to
dialog.  Makes using dialog from perl simple and powerful."

  Anyone know how to do this?  Please reply via Email, I don't get much
time to browse the newsgroups.

--
   This message brought to you by Stormlord!

   webmaster@ hi-line.net




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

Date: Fri, 18 Jun 1999 21:21:29 GMT
From: j_raff@my-deja.com
Subject: Perl Module query
Message-Id: <7ked8e$ste$1@nnrp1.deja.com>

Is there a simple way to determine what modules are loaded on a server
with out asking the ISP or Admin?
Like walking the @INC looking for files that end with ".pm".


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


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

Date: Fri, 18 Jun 1999 18:56:39 -0400
From: evil Japh <jeffp@crusoe.net>
Subject: Re: Perl Module query
Message-Id: <Pine.GSO.3.96.990618185555.17149B-100000@crusoe.crusoe.net>

> Is there a simple way to determine what modules are loaded on a server
> with out asking the ISP or Admin?

Yes, it's the pminst program in the Perl Power Tools, available at
http://language.perl.com/ppt.

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

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



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

Date: Fri, 18 Jun 1999 16:13:44 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Perl Module query
Message-Id: <Pine.GSO.4.02A.9906181613340.5420-100000@user2.teleport.com>

On Fri, 18 Jun 1999 j_raff@my-deja.com wrote:

> Is there a simple way to determine what modules are loaded on a server
> with out asking the ISP or Admin?
> Like walking the @INC looking for files that end with ".pm".

Yes, like that.

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



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

Date: Fri, 18 Jun 1999 16:00:58 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: problems with eval
Message-Id: <Pine.GSO.4.02A.9906181557540.5420-100000@user2.teleport.com>

On Fri, 18 Jun 1999, Christopher Grau wrote:

> I have had some difficulty using the eval function. Imagine that I
> have a fairly complex perl script (with luck, this doesn't matter, and
> I don't have to go into it). Basically, I am trying to execute code
> that looks like this:
> 
> 	eval "\$foo = \"bar\"";
> 
> However, this doesn't work in my complex script, $foo is never
> assigned anything. 

Are you checking the value of $@ after the eval? Could you be assigning to
a different $foo than you think? (Say, a lexical one or one in a different
package?) Are you sure that you need the evil eval STRING for this, and
that a reference wouldn't be faster, simpler, safer, and correct?

If you're still stuck, you'll have to cut your program down to the
smallest example which shows the mysterious behavior. Cheers!

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



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

Date: 18 Jun 1999 15:28:04 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Recommend a simple Online database?
Message-Id: <ylbtedxhxn.fsf@windlord.stanford.edu>

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

> I like to tell people about five approaches to databases:

>  *  Flat text databases: use open, close, <>, print; Berkeley DB can
>     tie an array to them.

And Tie::ShadowHash can turn the flat text file into a Perl hash behind
the scenes for you, although read-only.  It can also merge several such
files together from the perspective of lookups, merge them with a db/dbm
file for lookups, and let you make changes while your program is running
(the changes aren't reflected in the data store on disk, which remains
unchanged).

I wrote it because a program needed runtime access to both db and text
files, needed to be able to make changes that were visible only for the
life of the process, and wanted to just deal with a simple hash rather
than having to duplicate the logic to check all the data sources all over
the program.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: 18 Jun 1999 17:47:00 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Recommend a simple Online database?
Message-Id: <376ada74@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author; it you 
      hate it, killfile me.  i couldn't care less.]

In comp.lang.perl.misc, 
    David Cassell <cassell@mail.cor.epa.gov> writes:
:Is that supposed to be "I do know that I wouldn't trust.." or is it
:supposed to be "I don't know that I would trust.." ?

Either works better than my thinko.

--tom
-- 
    I think I'm likely to be certified before Perl is...  :-) 
	--Larry Wall in <1995Feb12.061604.6008@netlabs.com>


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

Date: Fri, 18 Jun 1999 16:57:07 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Recommend a simple Online database?
Message-Id: <376ADCD3.131ECA1A@mail.cor.epa.gov>

Tom Christiansen wrote:
> 
>      [courtesy cc of this posting mailed to cited author; it you
>       hate it, killfile me.  i couldn't care less.]

No problem.  Unlike some people, I don't mind getting e-mail.
But then, I'm not often confused with *the* Eric Schwartz,
to toss out a semi-relevant example.

And there isn't much chance of *me* killfiling *you*!
Now the converse...  :-)

> In comp.lang.perl.misc,
>     David Cassell <cassell@mail.cor.epa.gov> writes:
> :Is that supposed to be "I do know that I wouldn't trust.." or is it
> :supposed to be "I don't know that I would trust.." ?
> 
> Either works better than my thinko.

I was just wondering,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Fri, 18 Jun 1999 15:46:22 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Relocation error in Socket.so
Message-Id: <Pine.GSO.4.02A.9906181541480.5420-100000@user2.teleport.com>

On Fri, 18 Jun 1999, Andrey Zmievski wrote:

> I've downloaded an application written in Perl today, but when it tried
> to configure itself, an error was produced:
> 
> Can't load
> '/usr/local/lib/perl5/5.00503/sun4-solaris/auto/Socket/Socket.so' for
> module Socket: ld.so.1: /usr/bin/perl: fatal: relocation error: file
> /usr/local/lib/perl5/5.00503/sun4-solaris/auto/Socket/Socket.so: symbol
> __inet_ntoa: referenced symbol not found at
> /usr/local/lib/perl5/5.00503/sun4-solaris/DynaLoader.pm line 169.

Your Socket module seems to be mis-installed. (Ask your admin to) be sure
that 'make test' works before doing 'make install' for Perl, which should
fix things. Cheers!

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



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

Date: Fri, 18 Jun 1999 15:40:41 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: s/\s/ /g does not work for me... why??!!
Message-Id: <Pine.GSO.4.02A.9906181535420.5420-100000@user2.teleport.com>

On Fri, 18 Jun 1999, Luis F. Salas wrote:

> I made the change BEFORE sending them to the text file, and they
> still show up  as
> 
> xxxxxx
> yyyyy
> zzzz
> 
> instead of xxx yyyyy zzzz as I need...
> 
> It is the RETURN character I awant to get rid of...

I don't see how getting rid of a return character (a newline?) will change
six x's to three. Was that what you meant?

But if you can make a small, standalone, non-web program which shows what
part of Perl is not doing what you want, we can try to help you. You
should be able to do this with no more than about five lines of code: Just
set up a variable with the data you've got, try getting rid of the return
character, and print it out.

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



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

Date: Fri, 18 Jun 1999 16:05:03 -0700
From: "Luis F. Salas" <unclelui@grin.net>
To: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: s/\s/ /g does not work for me... why??!!
Message-Id: <376AD09F.461@grin.net>

Tom Phoenix wrote:
> 

> I don't see how getting rid of a return character (a newline?) will change
> six x's to three. Was that what you meant?
Nope.

What I want is this:

The user will see and fill out the form:

LOGIN: myname		EMAIL:  my_email

COMMENTS:   	thank you
		for helping	
		me  :-)



and the info will go to a guestbook.txt file.

Now, if the user types all comments in one line (i.e. thank you for
helping me)
then when you view the guestbook file it reads it fine.

However, since the RETURNS are included in the string, the guestbook
file
looks like this:

mynane##my_email##thank you^M
for helping^M
me  :-)##

and I want it to look like this:
myname##my_email##thank you for helping me  :-)


So when I use the command while ($rec = <GBOOK>)...
it won't get confused, because when it does the program cannot read from
the book
anymore, ergo it does not display the entries to guestbook.

I am using $comments = param('comments');
and that's why I am trying to change the \n to a mere blank space, but
so far I
have been unsuccessful. I am including the'##' myself, so that is not a
problem.
^M is...

Once again, thank you for helping me...

Luis


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

Date: 18 Jun 1999 23:21:56 GMT
From: snow@biostat.washington.edu (Gregory Snow)
Subject: sleeping vs stopping and restarting
Message-Id: <7kekak$qe0$1@nntp6.u.washington.edu>

What type of resources does a sleeping perl script consume?

My search of deja and the docs didn't turn up an answer.

I sometimes use perl to control some long but low priority simulations,
and the program that perl calls to do the work is a real memory hog,
so I want the script to run just at night.  One approach is to check
the time each iteration and if it is after 5:00am, save the current
state of everything, set up "at" or "chron" to restart the script that
night and exit.  The other option is to call sleep and sleep for
several hours, this would be simpler, but I don't want to do it if it
is consuming a significant amount of system resources.  So what does
my script do while it is sleeping?  

I'm mostly interested on unix boxes, but also curious about win95 if
anyone knows.

Thanks,


-- 
-------------------------------------------------------------------------------
     Gregory L. Snow         |    Matter cannot be created or destroyed,
     (Greg)                  |  nor can it be returned without a receipt.
snow@biostat.washington.edu  |


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

Date: 18 Jun 1999 17:39:13 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Variable substitution problem
Message-Id: <376ad8a1@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    Ondrej Palkovsky <xpalo03@vse.cz> writes:
:I've just read the perlfaq4:
:How can I expand variables in text strings?

You obviously can't.

--tom
-- 
    "No, I'm not going to explain it. If you can't figure it out, 
     you didn't want to know anyway..." --Larry Wall 


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

Date: 18 Jun 1999 17:40:27 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Variable substitution problem
Message-Id: <376ad8eb@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    Ondrej Palkovsky <xpalo03@vse.cz> writes:
:I've just read the perlfaq4:
:How can I expand variables in text strings?

Read this:

  How can I use a variable as a variable name?

    Beginners often think they want to have a variable contain the
    name of a variable.

        $fred    = 23;
        $varname = "fred";
        ++$$varname;         # $fred now 24

    This works *sometimes*, but it is a very bad idea for two
    reasons.

    The first reason is that they *only work on global variables*.
    That means above that if $fred is a lexical variable created
    with my(), that the code won't work at all: you'll accidentally
    access the global and skip right over the private lexical
    altogether. Global variables are bad because they can easily
    collide accidentally and in general make for non-scalable and
    confusing code.

    Symbolic references are forbidden under the `use strict' pragma.
    They are not true references and consequently are not reference
    counted or garbage collected.

    The other reason why using a variable to hold the name of
    another variable a bad idea is that the question often stems
    from a lack of understanding of Perl data structures,
    particularly hashes. By using symbolic references, you are just
    using the package's symbol-table hash (like `%main::') instead
    of a user-defined hash. The solution is to use your own hash or
    a real reference instead.

        $fred    = 23;
        $varname = "fred";
        $USER_VARS{$varname}++;  # not $$varname++

    There we're using the %USER_VARS hash instead of symbolic
    references. Sometimes this comes up in reading strings from the
    user with variable references and wanting to expand them to the
    values of your perl program's variables. This is also a bad idea
    because it conflates the program-addressable namespace and the
    user-addressable one. Instead of reading a string and expanding
    it to the actual contents of your program's own variables:

        $str = 'this has a $fred and $barney in it';
        $str =~ s/(\$\w+)/$1/eeg;             # need double eval

    Instead, it would be better to keep a hash around like
    %USER_VARS and have variable references actually refer to
    entries in that hash:

        $str =~ s/\$(\w+)/$USER_VARS{$1}/g;   # no /e here at all

    That's faster, cleaner, and safer than the previous approach. Of
    course, you don't need to use a dollar sign. You could use your
    own scheme to make it less confusing, like bracketed percent
    symbols, etc.

        $str = 'this has a %fred% and %barney% in it';
        $str =~ s/%(\w+)%/$USER_VARS{$1}/g;   # no /e here at all

    Another reason that folks sometimes think they want a variable
    to contain the name of a variable is because they don't know how
    to build proper data structures using hashes. For example, let's
    say they wanted two hashes in their program: %fred and %barney,
    and to use another scalar variable to refer to those by name.

        $name = "fred";
        $$name{WIFE} = "wilma";     # set %fred

        $name = "barney";           
        $$name{WIFE} = "betty";     # set %barney

    This is still a symbolic reference, and is still saddled with
    the problems enumerated above. It would be far better to write:

        $folks{"fred"}{WIFE}   = "wilma";
        $folks{"barney"}{WIFE} = "betty";

    And just use a multilevel hash to start with.

    The only times that you absolutely *must* use symbolic
    references are when you really must refer to the symbol table.
    This may be because it's something that can't take a real
    reference to, such as a format name. Doing so may also be
    important for method calls, since these always go through the
    symbol table for resolution.

    In those cases, you would turn off `strict 'refs'' temporarily
    so you can play around with the symbol table. For example:

        @colors = qw(red blue green yellow orange purple violet);
        for my $name (@colors) {
            no strict 'refs';  # renege for the block
            *$name = sub { "<FONT COLOR='$name'>@_</FONT>" };
        } 

    All those functions (red(), blue(), green(), etc.) appear to be
    separate, but the real code in the closure actually was compiled
    only once.

    So, sometimes you might want to use symbolic references to
    directly manipulate the symbol table. This doesn't matter for
    formats, handles, and subroutines, because they are always
    global -- you can't use my() on them. But for scalars, arrays,
    and hashes -- and usually for subroutines -- you probably want
    to use hard references only.

Good.  Read it again now.

  How can I use a variable as a variable name?

    Beginners often think they want to have a variable contain the
    name of a variable.

        $fred    = 23;
        $varname = "fred";
        ++$$varname;         # $fred now 24

    This works *sometimes*, but it is a very bad idea for two
    reasons.

    The first reason is that they *only work on global variables*.
    That means above that if $fred is a lexical variable created
    with my(), that the code won't work at all: you'll accidentally
    access the global and skip right over the private lexical
    altogether. Global variables are bad because they can easily
    collide accidentally and in general make for non-scalable and
    confusing code.

    Symbolic references are forbidden under the `use strict' pragma.
    They are not true references and consequently are not reference
    counted or garbage collected.

    The other reason why using a variable to hold the name of
    another variable a bad idea is that the question often stems
    from a lack of understanding of Perl data structures,
    particularly hashes. By using symbolic references, you are just
    using the package's symbol-table hash (like `%main::') instead
    of a user-defined hash. The solution is to use your own hash or
    a real reference instead.

        $fred    = 23;
        $varname = "fred";
        $USER_VARS{$varname}++;  # not $$varname++

    There we're using the %USER_VARS hash instead of symbolic
    references. Sometimes this comes up in reading strings from the
    user with variable references and wanting to expand them to the
    values of your perl program's variables. This is also a bad idea
    because it conflates the program-addressable namespace and the
    user-addressable one. Instead of reading a string and expanding
    it to the actual contents of your program's own variables:

        $str = 'this has a $fred and $barney in it';
        $str =~ s/(\$\w+)/$1/eeg;             # need double eval

    Instead, it would be better to keep a hash around like
    %USER_VARS and have variable references actually refer to
    entries in that hash:

        $str =~ s/\$(\w+)/$USER_VARS{$1}/g;   # no /e here at all

    That's faster, cleaner, and safer than the previous approach. Of
    course, you don't need to use a dollar sign. You could use your
    own scheme to make it less confusing, like bracketed percent
    symbols, etc.

        $str = 'this has a %fred% and %barney% in it';
        $str =~ s/%(\w+)%/$USER_VARS{$1}/g;   # no /e here at all

    Another reason that folks sometimes think they want a variable
    to contain the name of a variable is because they don't know how
    to build proper data structures using hashes. For example, let's
    say they wanted two hashes in their program: %fred and %barney,
    and to use another scalar variable to refer to those by name.

        $name = "fred";
        $$name{WIFE} = "wilma";     # set %fred

        $name = "barney";           
        $$name{WIFE} = "betty";     # set %barney

    This is still a symbolic reference, and is still saddled with
    the problems enumerated above. It would be far better to write:

        $folks{"fred"}{WIFE}   = "wilma";
        $folks{"barney"}{WIFE} = "betty";

    And just use a multilevel hash to start with.

    The only times that you absolutely *must* use symbolic
    references are when you really must refer to the symbol table.
    This may be because it's something that can't take a real
    reference to, such as a format name. Doing so may also be
    important for method calls, since these always go through the
    symbol table for resolution.

    In those cases, you would turn off `strict 'refs'' temporarily
    so you can play around with the symbol table. For example:

        @colors = qw(red blue green yellow orange purple violet);
        for my $name (@colors) {
            no strict 'refs';  # renege for the block
            *$name = sub { "<FONT COLOR='$name'>@_</FONT>" };
        } 

    All those functions (red(), blue(), green(), etc.) appear to be
    separate, but the real code in the closure actually was compiled
    only once.

    So, sometimes you might want to use symbolic references to
    directly manipulate the symbol table. This doesn't matter for
    formats, handles, and subroutines, because they are always
    global -- you can't use my() on them. But for scalars, arrays,
    and hashes -- and usually for subroutines -- you probably want
    to use hard references only.

One more time, please.

  How can I use a variable as a variable name?

    Beginners often think they want to have a variable contain the
    name of a variable.

        $fred    = 23;
        $varname = "fred";
        ++$$varname;         # $fred now 24

    This works *sometimes*, but it is a very bad idea for two
    reasons.

    The first reason is that they *only work on global variables*.
    That means above that if $fred is a lexical variable created
    with my(), that the code won't work at all: you'll accidentally
    access the global and skip right over the private lexical
    altogether. Global variables are bad because they can easily
    collide accidentally and in general make for non-scalable and
    confusing code.

    Symbolic references are forbidden under the `use strict' pragma.
    They are not true references and consequently are not reference
    counted or garbage collected.

    The other reason why using a variable to hold the name of
    another variable a bad idea is that the question often stems
    from a lack of understanding of Perl data structures,
    particularly hashes. By using symbolic references, you are just
    using the package's symbol-table hash (like `%main::') instead
    of a user-defined hash. The solution is to use your own hash or
    a real reference instead.

        $fred    = 23;
        $varname = "fred";
        $USER_VARS{$varname}++;  # not $$varname++

    There we're using the %USER_VARS hash instead of symbolic
    references. Sometimes this comes up in reading strings from the
    user with variable references and wanting to expand them to the
    values of your perl program's variables. This is also a bad idea
    because it conflates the program-addressable namespace and the
    user-addressable one. Instead of reading a string and expanding
    it to the actual contents of your program's own variables:

        $str = 'this has a $fred and $barney in it';
        $str =~ s/(\$\w+)/$1/eeg;             # need double eval

    Instead, it would be better to keep a hash around like
    %USER_VARS and have variable references actually refer to
    entries in that hash:

        $str =~ s/\$(\w+)/$USER_VARS{$1}/g;   # no /e here at all

    That's faster, cleaner, and safer than the previous approach. Of
    course, you don't need to use a dollar sign. You could use your
    own scheme to make it less confusing, like bracketed percent
    symbols, etc.

        $str = 'this has a %fred% and %barney% in it';
        $str =~ s/%(\w+)%/$USER_VARS{$1}/g;   # no /e here at all

    Another reason that folks sometimes think they want a variable
    to contain the name of a variable is because they don't know how
    to build proper data structures using hashes. For example, let's
    say they wanted two hashes in their program: %fred and %barney,
    and to use another scalar variable to refer to those by name.

        $name = "fred";
        $$name{WIFE} = "wilma";     # set %fred

        $name = "barney";           
        $$name{WIFE} = "betty";     # set %barney

    This is still a symbolic reference, and is still saddled with
    the problems enumerated above. It would be far better to write:

        $folks{"fred"}{WIFE}   = "wilma";
        $folks{"barney"}{WIFE} = "betty";

    And just use a multilevel hash to start with.

    The only times that you absolutely *must* use symbolic
    references are when you really must refer to the symbol table.
    This may be because it's something that can't take a real
    reference to, such as a format name. Doing so may also be
    important for method calls, since these always go through the
    symbol table for resolution.

    In those cases, you would turn off `strict 'refs'' temporarily
    so you can play around with the symbol table. For example:

        @colors = qw(red blue green yellow orange purple violet);
        for my $name (@colors) {
            no strict 'refs';  # renege for the block
            *$name = sub { "<FONT COLOR='$name'>@_</FONT>" };
        } 

    All those functions (red(), blue(), green(), etc.) appear to be
    separate, but the real code in the closure actually was compiled
    only once.

    So, sometimes you might want to use symbolic references to
    directly manipulate the symbol table. This doesn't matter for
    formats, handles, and subroutines, because they are always
    global -- you can't use my() on them. But for scalars, arrays,
    and hashes -- and usually for subroutines -- you probably want
    to use hard references only.

Any questions?

--tom
-- 
    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: Fri, 18 Jun 1999 18:34:16 -0500
From: seong joon bae <seongbae@students.uiuc.edu>
Subject: Where is IO::Socket module?
Message-Id: <Pine.GSO.4.10.9906181832450.25874-100000@ux8.cso.uiuc.edu>


I looked everywhere for IO::Socket module, but I could only find
IO::Socket::SSL module.  
Am I understanding something wrong or is it just not there?




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

Date: 18 Jun 1999 16:37:37 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Where is IO::Socket module?
Message-Id: <ylr9n9w05a.fsf@windlord.stanford.edu>

seong joon bae <seongbae@students.uiuc.edu> writes:

> I looked everywhere for IO::Socket module, but I could only find
> IO::Socket::SSL module.  Am I understanding something wrong or is it
> just not there?

IO::Socket is part of Perl core.  It should come with your installation of
Perl.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

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


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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