[9162] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2780 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 1 17:09:04 1998

Date: Mon, 1 Jun 98 14:00:33 -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           Mon, 1 Jun 1998     Volume: 8 Number: 2780

Today's topics:
        "! Appending" to a file using Perl <webmaster@yogi.net>
    Re: "! Appending" to a file using Perl (Clinton Pierce)
    Re: "! Appending" to a file using Perl <rootbeer@teleport.com>
    Re: CGI mail form format problem <barnett@houston.Geco-Prakla.slb.com>
    Re: Converting 31.12.1998 -> 12/31/1998 <jdporter@min.net>
    Re: Dereferencing SV** <jimmyoh@pacific.net.sg>
    Re: Dereferencing SV** <aqumsieh@matrox.com>
        emacs 20.2 wrongly indents perl here documents <jamie@mccarthy.org>
        File Upload Script <info@mediakitchen.ca>
    Re: File Upload Script <rootbeer@teleport.com>
    Re: Fork() - functionality in NT Perl? (Tye McQueen)
    Re: Have we got a good free Perl manual? <jdporter@min.net>
        Help with Error message <mattge@sierratel.com>
    Re: Help with Error message <rootbeer@teleport.com>
    Re: HELP::Comparing strings <barnett@houston.Geco-Prakla.slb.com>
    Re: HELP::Comparing strings <aqumsieh@matrox.com>
    Re: HELP::Comparing strings (Marek Jedlinski)
    Re: How do I tell if Perl is in foreground or backgound (Charles DeRykus)
        How to get exit code in Win32/UNIX <bjs@iti-oh.com>
        How to Get Index if given a value in the array??? <tag@io.com>
    Re: How to Get Index if given a value in the array??? (Clinton Pierce)
    Re: How to Get Index if given a value in the array??? <bjs@iti-oh.com>
        Need Crontab (Rick Alber)
    Re: Need Crontab nospam@death.to.spammers.org
    Re: Need some helps from Perl experts <rootbeer@teleport.com>
    Re: new to OO Perl <zenin@bawdycaste.org>
    Re: newbie trying to run Term::Cap on Win32 <aqumsieh@matrox.com>
        Perl class for newbie? <dfrancoDONTSPAM@fore.com>
    Re: Perl for Win32 - Loading a hive file (Tye McQueen)
        Regex: parens inside quantifiers: can you capture all o (Peter Scott)
    Re: Regex: parens inside quantifiers: can you capture a <zenin@bawdycaste.org>
    Re: Returning from a signal handler? <rootbeer@teleport.com>
    Re: simple question (Mark-Jason Dominus)
    Re: simple question (Larry Rosler)
    Re: TIP : Complex CGI scripts (Mark-Jason Dominus)
    Re: user autentification <rootbeer@teleport.com>
    Re: Using perl to post a CGI form <rootbeer@teleport.com>
    Re: Why is `undef' a unary op and not a list op? (Mark-Jason Dominus)
    Re: Win32::ODBC; NEW doesn't work <cowanb@mindspring.com>
    Re: X marks the spot, was Re: Best tool? <jdporter@min.net>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Mon, 01 Jun 1998 15:33:54 -0400
From: Satish Gopalkrishnan <webmaster@yogi.net>
Subject: "! Appending" to a file using Perl
Message-Id: <35730222.58C1@yogi.net>

How do I go about adding (inserting) records at the beginning of a file?
This is to improve the readability of the log files which are used by a
CGI application I created (http://www.yogi.net/WordGame).
Regards,
Satish.


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

Date: 1 Jun 1998 20:27:19 GMT
From: cpierce1@cp500.fsic.ford.com (Clinton Pierce)
To: webmaster@yogi.net
Subject: Re: "! Appending" to a file using Perl
Message-Id: <6kv2r7$cm4@eccws1.dearborn.ford.com>

[cc sent to author via E-Mail]

In article <35730222.58C1@yogi.net>,
	Satish Gopalkrishnan <webmaster@yogi.net> writes:
>How do I go about adding (inserting) records at the beginning of a file?
>This is to improve the readability of the log files which are used by a
>CGI application I created (http://www.yogi.net/WordGame).
>Regards,
>Satish.

* In short, you don't.  

* The slightly longer answer is, under most OS's (UNIX, DOS) doing this is
a real pain in the ass.  Most filesystems don't understand the concept of
"insert".   You can replace sections of a file, and you can append a file.
But inserting is a pain because, effectively, you have to take the data
at the beginning of the file, slide it down a bit, and put your data 
at the beginning of the file (a replacement).  Of course, all of the data
has to be moved down.  This begins to be a non-trivial problem quickly, 
especially if your log entries are not fixed length.

* The long answer is, keep your logs in a file that gets appended.  Train
everything else to read at (or near) the end of the file.  tail(1) under
UNIX is what I have in mind.  There are FAQ's on this sort of activity.

If you really want to get perverse, use a DBM (database) file.  But 
then you abandon the principle of "text" logfiles, and that's a Bad 
Thing.


-- 
+------------------------------------------------------------------------+
|  Clinton A. Pierce    |   "If you rush a Miracle Man,   | http://www.  |
|  cpierce1@ford.com    |     you get rotten miracles"    | dcicorp.com/ |
| fubar@ameritech.net   |--Miracle Max, The Princess Bride| ~clintp      |
+------------------------------------------------------------------------+
GCSd-s+:+a-C++UALIS++++P+++L++E---t++X+b+++DI++++G++e+>++h----r+++y+++>y*



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

Date: Mon, 01 Jun 1998 20:53:38 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: "! Appending" to a file using Perl
Message-Id: <Pine.GSO.3.96.980601135308.15370L-100000@user2.teleport.com>

On Mon, 1 Jun 1998, Satish Gopalkrishnan wrote:

> How do I go about adding (inserting) records at the beginning of a file?

The methods described in the FAQ are a good start. :-)  Hope this helps!

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



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

Date: Mon, 01 Jun 1998 12:38:49 -0500
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
To: Bobby <bob@simplydigital.com>
Subject: Re: CGI mail form format problem
Message-Id: <3572E729.7289B96F@houston.Geco-Prakla.slb.com>

[courtesy cc to cited author]

Bobby wrote:
> 
> I have a pretty large form (100 text fields) on a clients site that I am
> using as a mailto order form run by a basic Perl cgi. Everything works
> well except the output in the email message is not sorted in any specific
> way.
Um, okay.

> I need the output sorted alphabeticaly.
Um, okay.

> Can anyone give a Perl newbie
> any hints/help or suggestions?
Doesn't the 'sort' built-in do what you want?

perldoc -f sort

perlfaq4:
=head2 How do I sort an array by (anything)?
=head2 How do I sort a hash (optionally by value instead of key)?

Hints:
Next time, post a code snippet showing what you are having trouble
with.  None of us (none that I know of, anyway) are mind readers, so
without further input, this is all the output I can provide.

HTH.

> 
> Thanks in Advance,
> 
> Bob Rhodes
> rhodes@doublespeak.com
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
Schlumberger Geco-Prakla     (281) 596-1434 (Office Number)           
1325 S. Dairy Ashford #7051  (281) 556-7615 (Fax)                     
Houston, TX 77077                                                     
----------------------------------------------------------------------


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

Date: Mon, 01 Jun 1998 19:51:43 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Converting 31.12.1998 -> 12/31/1998
Message-Id: <35730802.A45@min.net>

I R A Aggie wrote:
> 
> Ala Qumsieh <aqumsieh@matrox.com> wrote:
> 
> + $date = '31.12.1998';
> + $date =~ s!^(\d+)\.(\d+)\.!$2/$1/!g;
> 
> Strikes me as being somewhat obsfucated.

Hmm.  Not me.  'Bout as simple as a s/// can get, almost.


> $date='31.12.1998';
> ($day,$mon,$year)=split /\./, $date;
> $date=join('/',$mon,$day,$year);
> print "$date\n";

> May be less efficient. A little easier to read. And I'm sure that
> three months from now, I'd look at this and go "huh? why did I do
> it this way??"

Yep, and then you might come up with this one-liner:

$date = join('/',(split(/\./,$date))[1,0,2]);

Using LIST SLICING to swap the positions of some items in a list.

John Porter


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

Date: Tue, 02 Jun 1998 01:45:01 +0800
From: Jimmy <jimmyoh@pacific.net.sg>
Subject: Re: Dereferencing SV**
Message-Id: <3572E89D.9555868D@pacific.net.sg>

Jimmy wrote:
> 
> Hi,
>         I am trying to write my first XS program but I find trouble in
> dereferencing SV** to SV*.  Can anyone tell me how to do that?
> 
>         Thanx in advance.
> 
> Jimmy

I have found the answer already.  Sorry for asking such a stupid
question.  Thanx

Jimmy


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

Date: Mon, 01 Jun 1998 14:08:21 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Dereferencing SV**
Message-Id: <3572EE15.58DA20F@matrox.com>

Jimmy wrote:

> Hi,
>         I am trying to write my first XS program but I find trouble in
> dereferencing SV** to SV*.  Can anyone tell me how to do that?
>
>         Thanx in advance.
>
> Jimmy

 Hi Jimmy,

I am not the best person to give you advice on this, but if you check
out:

%perldoc perlguts

and search for "dereferencing", you'll get this:

     Remember that hv_store and hv_fetch return SV**'s and not
     just SV*.  In order to access the scalar value, you must
     first dereference the return value.  However, you should
     check to make sure that the return value is not NULL before
     dereferencing it.

A bit later, you can find ...

     av_fetch
             Returns the SV at the specified index in the array.
             The key is the index.  If lval is set then the fetch
             will be part of a store.  Check that the return
             value is non-null before dereferencing it to a SV*.

                     SV**    av_fetch _((AV* ar, I32 key, I32 lval));

It sure helps to look in the documentation!

--
Ala Qumsieh             |  No .. not just another
ASIC Design Engineer    |  Perl Hacker!!!!!
Matrox Graphics Inc.    |
Montreal, Quebec        |  (Not yet!)





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

Date: Mon, 01 Jun 1998 15:16:32 -0400
From: Jamie McCarthy <jamie@mccarthy.org>
Subject: emacs 20.2 wrongly indents perl here documents
Message-Id: <3572FE10.EEA05396@mccarthy.org>

I'm a longtime perl lover, but a newbie to emacs.  I just downloaded
and installed emacs 20.2.1 a few days ago and am getting used to it.

I do enjoy the perl editing features, but indent-perl-exp has a few
bugs.  Most I can work around, one I can't.  It doesn't know what a
here document is.  I get formatting like this:

   &do_this();
   print <<END_OF_TEXT;
   Here is some text
      that has been
         wrongly indented
            by Emacs.
               END_OF_TEXT
                  do_that();
   &do_the_other();

The syntax coloring indicates that it doesn't recognize it as a string.

Any ideas?  Besides never invoking perl-indent-exp or
perl-indent-command around a here document, I mean.

-- 
        Jamie McCarthy
        jamie@mccarthy.org
 http://jamie.mccarthy.org/


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

Date: Mon, 1 Jun 1998 15:37:56 -0400
From: "Media Kitchen Inc." <info@mediakitchen.ca>
Subject: File Upload Script
Message-Id: <6kuve2$h1c$1@news.interlog.com>

Hi,

I would like to know where i could
find a script that will allow users to
upload files into a certain directory
on my server.

Thanks
PHil




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

Date: Mon, 01 Jun 1998 20:51:53 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: File Upload Script
Message-Id: <Pine.GSO.3.96.980601135009.15370J-100000@user2.teleport.com>

On Mon, 1 Jun 1998, Media Kitchen Inc. wrote:

> I would like to know where i could find a script that will allow users
> to upload files into a certain directory on my server. 

Perhaps you want to install ftpd. If you're needing to find software (as
opposed to writing it, that is) you should probably check out the various
services which archive and index free software. Hope this helps!

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



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

Date: 1 Jun 1998 15:24:12 -0500
From: tye@fiinix.metronet.com (Tye McQueen)
Subject: Re: Fork() - functionality in NT Perl?
Message-Id: <6kv2lc$rs4@fiinix.metronet.com>

winchest@babbage.csee.usf.edu (Jeff Winchester) writes:
) 
) I'd like to spin a cursor or "walk" one back and forth as soon as the new 
) process (operation) starts and until it exits.  I know that this might not be 
) too hard under UNIX with a fork() command, but that doesn't seem to be 
) implemented under Perl for NT.

    system("start /b twirler");

or something that calls CreateProcess(), like Win32::Process.
-- 
Tye McQueen    Nothing is obvious unless you are overlooking something
         http://www.metronet.com/~tye/ (scripts, links, nothing fancy)


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

Date: Mon, 01 Jun 1998 20:28:18 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Have we got a good free Perl manual?
Message-Id: <35731091.7170@min.net>

lvirden@cas.org wrote:
> 
> According to John Porter <jdporter@min.net>:
> :On 28 May 1998 22:02:52 -0400,
> :in article <sd7k975zvek.fsf@mescaline.gnu.org>,
> :rms@gnu.org (Richard Stallman) wrote:
> :>
> :> Once upon a time, I thought I would learn Perl.  I got a copy of a
> :> free manual, but I found it simply unreadable, and gave up.  Perl
> :> users told me that there were better manuals, but they were not free.
> :
> :So all this time we've been arguing about the definition of "free",
> :we should have been arguing about the definition of "good".
> 
> Close - except that the word good itself wasn't used.  Instead, the
> undefined "unreadable" and "better" are used. 

No, actually, you miss on two counts:
1. The subject header, penned by rms himself (or possibly by his
   designated representative);
2. the web page which incited this whole debate:
	http://www.gnu.org/prep/tasks_3.html#SEC3
   which states the following:

	We very urgently need ....
	A good free manual for Perl. (There are proprietary books,
	but these are no good, because they are being withheld from
	our community by their owners.)

Interesting: there the word "good" appears twice -- the second
time, with a very different meaning!  
"no good", meaning "unacceptable for reasons other than quality".


> Notice that RMS doesn't
> say _he_ found the published literature better - just that someone
> else told him that.  We have yet to discover if he considers the issue
> that Programming, Learning, etc. acceptable doc but enslaved, or if

(And then you use the word "acceptable", meaning "of decent quality, 
but possibly unacceptable anyway".  ;-)

John Porter


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

Date: Mon, 01 Jun 1998 11:25:30 -0700
From: Matthew Genesi <mattge@sierratel.com>
Subject: Help with Error message
Message-Id: <3572F21A.41C6@sierratel.com>

Im trying to learn perl and do not understand the following error
message. After getting this message the program still runs and seems to
work.	

value of <HANDLE> construct can be "0"; test with defined() at ./test.pl
line 65535

Can someone tell me what this error message means?

Matt


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

Date: Mon, 01 Jun 1998 20:53:00 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Help with Error message
Message-Id: <Pine.GSO.3.96.980601135204.15370K-100000@user2.teleport.com>

On Mon, 1 Jun 1998, Matthew Genesi wrote:

> Im trying to learn perl and do not understand the following error
> message. 

All of Perl's error and diagnistic messages are listed in the perldiag
manpage. Does that give you what you need to know? Hope this helps!

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



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

Date: Mon, 01 Jun 1998 12:27:51 -0500
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
Subject: Re: HELP::Comparing strings
Message-Id: <3572E497.68CDC6E@houston.Geco-Prakla.slb.com>

Marek Jedlinski wrote:
> 
> Johan Priwshy <Centollo@iname.com>  wrote:
> 
> >Hi there. I've a little problem comparing strings.
> >let's say we have these two variables:
> >$str1 = "test";
> >$str2 = "test";
> >
> >and let's say we can compare them within an if statement:
> >if ($str1 == $str2) {
> 
> you mean:
> if ($str1 eq $str2 ) { ...
> 
> Use `eq' for string comparisons where you use `==' for numeric,
> and `neq' where you use `!='
What is neq?  Perl gives me the message:
Bareword found where operator expected at junk8 line 4, near ""$input"
neq"

Don't you mean 'ne' for strings, and != for numeric?

> 
> .marek
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: Mon, 01 Jun 1998 14:20:35 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: HELP::Comparing strings
Message-Id: <3572F0F3.37DC9C77@matrox.com>

Johan Priwshy wrote:

> Hi there. I've a little problem comparing strings.
> let's say we have these two variables:
> $str1 = "test";
> $str2 = "test";
>
> and let's say we can compare them within an if statement:
> if ($str1 == $str2) {
>     bla bla
> }
>
> I've found THIS DOESN'T work!!

Have a look at

%perldoc perlop

You are using the wrong comparison operator (HINT!!)
Also, you shouldn't be fiddling with passwords at this point of your
Perl life ;-)

--
Ala Qumsieh             |  No .. not just another
ASIC Design Engineer    |  Perl Hacker!!!!!
Matrox Graphics Inc.    |
Montreal, Quebec        |  (Not yet!)





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

Date: Mon, 01 Jun 1998 19:49:02 GMT
From: cicho@polbox.com (Marek Jedlinski)
Subject: Re: HELP::Comparing strings
Message-Id: <35730543.9518434@news.nask.org.pl>
Keywords: If you're happy and you know it, clunk your chains.

[posted & emailed]

Dave Barnett <barnett@houston.Geco-Prakla.slb.com>  wrote:



>> Use `eq' for string comparisons where you use `==' for numeric,
>> and `neq' where you use `!='
>What is neq?  Perl gives me the message:
>Bareword found where operator expected at junk8 line 4, near ""$input"
>neq"
>
>Don't you mean 'ne' for strings, and != for numeric?

Ouch. 'ne' is right, of course. Ouch again.

 .marek




-- 
After things go from bad to worse, the cycle will repeat itself.
http://come.to/fnord/


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

Date: Mon, 1 Jun 1998 19:25:42 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: How do I tell if Perl is in foreground or backgound?
Message-Id: <Etw0Mu.61o@news.boeing.com>

In article <3570BCA8.82100FDA@netlabs.net>,
Robert Dorfman  <dorfmanr@netlabs.net> wrote:
 > 
 > I have a Perl/Sybperl script that logs into a Sybase Adaptive Server
 > and starts a database backup. This is run automatically by cron.
 > However, I'd like to use the same script and allow it to be called by a
 > user.If running in the foreground I'll display a list of databases that
 > may be selected for backup. Then I'll fork the process to do the actual
 > database dump. How can I tell if my script is running in foreground or
 > background? Also, would running in the background be different from
 > being started by cron?
 > 
 
Among other things, cron differs both in PATH handling and 
disposition of stdout/stderr. (man cron). 

To check if background:  perldoc perlfaq8 and look at the section: 

   "How do I find out if I'm running interactively or not?"


HTH,
--
Charles DeRykus


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

Date: Mon, 1 Jun 1998 14:57:59 -0400
From: "Brian J. Sayatovic" <bjs@iti-oh.com>
Subject: How to get exit code in Win32/UNIX
Message-Id: <6kuts0$b3g$1@malgudi.oar.net>

    I'm writing a script which I hope to have work on UNIX and NT.  In this
script, I execute a batch of processes and would like to have the script be
aware of any horrible probelems with the porocesses, like a SEGV or
DivByZero error.  In UNIX, I've been told I can use the $?.  I'm not too
sure if this works in NT since I'm using Win32::Process::Create (as is used
in the Win32 version open3 I'm using.)

    How can I accomplish this task?  I'm having trouble even finding a way
to reliably cause such an error so I can test how to catch them (i.e., on
Solaris, dividing a float by zero returns 'Inf', not a FPE signal.)

    Any help would be appreciated.

Brian Sayatovic.




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

Date: Mon, 01 Jun 1998 14:52:12 -0500
From: "Todd A. Guillory" <tag@io.com>
Subject: How to Get Index if given a value in the array???
Message-Id: <35730669.97CC8349@io.com>

I want to get the index if I'm given a value that occurs in an array (the
opposite of the way it normally occurs).

Is there a quicker way to  do this in PERL than what I have below?

For example, if the $input{'month'} is "April" I have to use a for loop to
find that is index value 3.  Is there a "PERL" way to do this?

@months = ("January","February","March","April","May","June","July","August","September","October","November","December");

for ($index=0; $index <= (@months - 1); $index++ )  
   {
    if ( $months[$index] eq $input{'month'} )
      {
      $monthnumber = $index + 1;
      } # end if
    } # end for
  }


Thanks
Todd
tag@io.com


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

Date: 1 Jun 1998 20:43:11 GMT
From: cpierce1@cp500.fsic.ford.com (Clinton Pierce)
To: tag@io.com
Subject: Re: How to Get Index if given a value in the array???
Message-Id: <6kv3ov$cm5@eccws1.dearborn.ford.com>

[cc to author via E-Mail]
In article <35730669.97CC8349@io.com>,
	"Todd A. Guillory" <tag@io.com> writes:
>I want to get the index if I'm given a value that occurs in an array (the
>opposite of the way it normally occurs).
>
>Is there a quicker way to  do this in PERL than what I have below?
>
>For example, if the $input{'month'} is "April" I have to use a for loop to
>find that is index value 3.  Is there a "PERL" way to do this?
>
>@months = ("January","February","March","April","May","June","July","August","September","October","November","December");
>
>for ($index=0; $index <= (@months - 1); $index++ )  
>   {
>    if ( $months[$index] eq $input{'month'} )
>      {
>      $monthnumber = $index + 1;
>      } # end if
>    } # end for
>  }

The "perl way" is any way that gets the job done before your boss fires
you..  But this looks OK, and satisfies your requirements:

	#
	# Do this code only once.
	#
	@MONTHS= qw(January  February  March  April  May  June  July
                August  September  October  November  December);
	$a=0;
	foreach( @MONTHS ) {
		$CAL{$_}=++$a;
	}

	#
	# Do this until cows come home.
	#
	print $CAL{'October'}, "\n";   # Results in "10"

This has the added bonus of not being slow if you call it over and over
again.   (Yeah, it's a small list, but when we start adding months
after December 1999 to avoid year 2000, it'll come in handy!)



***** FREE RANDAL! *****
-- 
+------------------------------------------------------------------------+
|  Clinton A. Pierce    |   "If you rush a Miracle Man,   | http://www.  |
|  cpierce1@ford.com    |     you get rotten miracles"    | dcicorp.com/ |
| fubar@ameritech.net   |--Miracle Max, The Princess Bride| ~clintp      |
+------------------------------------------------------------------------+
GCSd-s+:+a-C++UALIS++++P+++L++E---t++X+b+++DI++++G++e+>++h----r+++y+++>y*



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

Date: Mon, 1 Jun 1998 16:40:41 -0400
From: "Brian J. Sayatovic" <bjs@iti-oh.com>
Subject: Re: How to Get Index if given a value in the array???
Message-Id: <6kv3sk$e7s$1@malgudi.oar.net>

If you're going to do this only once, this seems like a good way.  However,
if you're going to be looking up multiple values in the array over-and-over,
you should try implementing a hash of it.  This will only work if the array
contains unique values.  Still, it should be faster since whatever search
algorithm is used for the has is almost certainl faster than a linear
search -- and faster since its running below perl instead of being
interpreted:

%months = ();

for($index = 0; $index <= $#months; $index ++) {
    $month{$months[$index]} = $index;
}

Now you can do something like this...

$monthIndex = $months{$monthName};

Of course, you'll want to take care of case-sensitivity (perhaps make the
keys of the hash all uperr-case), etc.

There is probably still a better way, but I thought I'd put my $0.02 in.

Brian Sayatovic.

Todd A. Guillory wrote in message <35730669.97CC8349@io.com>...
>I want to get the index if I'm given a value that occurs in an array (the
>opposite of the way it normally occurs).
>
>Is there a quicker way to  do this in PERL than what I have below?
>
>For example, if the $input{'month'} is "April" I have to use a for loop to
>find that is index value 3.  Is there a "PERL" way to do this?
>
>@months =
("January","February","March","April","May","June","July","August","Septembe
r","October","November","December");
>
>for ($index=0; $index <= (@months - 1); $index++ )
>   {
>    if ( $months[$index] eq $input{'month'} )
>      {
>      $monthnumber = $index + 1;
>      } # end if
>    } # end for
>  }
>
>
>Thanks
>Todd
>tag@io.com




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

Date: Mon, 01 Jun 1998 18:51:56 GMT
From: ralber@ix.netcom.com (Rick Alber)
Subject: Need Crontab
Message-Id: <6kutft$mq6@sjx-ixn4.ix.netcom.com>

I just moved my domain to a new ISP (Mindspring) and found that they
won't run a crontab program for me like my old ISP did. Booo! I'm
looking for a workaround and thought there might be an ISP or other
service out there that runs crontabs for users like me. I need someone
or some company with a permanent connection to the Internet (I don't
have one) who's got some spare cycles. The crontab program would call
my process one time a night, thereby triggering a mailing to about
15,000 people. That mailing just *might* promote the service that
provides the crontab. 

Does anybody know who or what might do this? Can someone direct me to
where I might look for such a service?

Thanks.

----- Rick Alber



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

Date: 1 Jun 1998 19:16:13 GMT
From: nospam@death.to.spammers.org
Subject: Re: Need Crontab
Message-Id: <6kuult$cl4@eccws1.dearborn.ford.com>

In article <6kutft$mq6@sjx-ixn4.ix.netcom.com>,
	ralber@ix.netcom.com (Rick Alber) writes:
>I just moved my domain to a new ISP (Mindspring) 
>[...] thereby triggering a mailing to about
>15,000 people. That mailing just *might* promote the service that
>provides the crontab. 

Out of curiosity (and maybe for humor value) are these two events 
related?


>Does anybody know who or what might do this? Can someone direct me to
>where I might look for such a service?

Somewhere the Fourth Circle of Hell (Hoarders and Wasters).  



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

Date: Mon, 01 Jun 1998 18:10:56 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Need some helps from Perl experts
Message-Id: <Pine.GSO.3.96.980601111028.15370D-100000@user2.teleport.com>

On Mon, 1 Jun 1998, Seman Bajau wrote:

> I've downloaded free scripts from Selena Sol's archive. I already tried
> vainly to install the web calendar scripts but until now still not
> working. 

When you're having trouble with a CGI program in Perl, you should first
look at the please-don't-be-offended-by-the-name Idiot's Guide to solving
such problems. It's available on CPAN.

   http://www.perl.com/CPAN/
   http://www.perl.org/CPAN/
   http://www.perl.org/CPAN/doc/FAQs/cgi/idiots-guide.html
   http://www.perl.org/CPAN/doc/manual/html/pod/

Hope this helps!

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



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

Date: 1 Jun 1998 19:17:14 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: new to OO Perl
Message-Id: <896729059.261142@thrush.omix.com>

John Porter <jdporter@min.net> wrote:
	>snip<
: Arrays seem to be a bit faster than hashes, so if one can
: reasonably implement his objects as blessed array-refs
: rather than hash-refs, it should be faster. I've seen it done.
	>snip<

	I've actually just built a little pragma called "fields" to
	help make this a lot easier.  As an extra plus, it also pollutes
	your namespace quite a bit. :-)

	Anyway, a test version can be found at:

	http://thrush.omix.com/pub/perl/moudles/fields-1.002.tar.gz

	Here's the perldoc:

NAME
    fields - Perl extension for blah blah blah

SYNOPSIS
      package My::Class;

      use fields qw(Field Names You Want To Use);
      sub new {
          my $class = shift;
          my $self  = [];

          $self->[Field] = 'value';
          $self->[Names] = 'value';
          $self->[You]   = 'value';
          $self->[Want]  = 'value';
          $self->[To]    = ['some', 'list'];
          $self->[Use]   = 'value';
          return bless $self, $class;
      }

DESCRIPTION
    Defines a set of symbolic constants for use as object field names when
    using an array ref as an object. This has a couple of advantages over
    using a hash ref and keys:

    Speed
        Using an array ref for an object yields much faster access times
        then a hash ref. Because the symbolic constants this module defines
        will be inlined by the perl interpreter there is no run time over
        head for name look up.

    Error Checking
        Because these names are used as bare words, when strict is applied
        it will cause compile time errors if you misspell a field name.
        Conversely traditional hash value lookups are very prone to this
        type of error and will never cause a compile time error or warning,
        and in some cases no warning at all.

        This module is very similar to the constant module. In fact, these
        statements are almost the same:

          use constant Foo => 0;
          use fields qw(Foo);

        The difference is that fields uses an incremented value for each new
        field named assuring no name collisions (so Foo and Bar don't both
        evaluate to 0). fields also checks to see if the field has been
        defined already, and if so to reuse the numeric index it used the
        first time. Thus, if you accidently call use fields 'Foo' twice,
        your code won't break because it's looking up 16 now instead of 2.

        Using -w will cause compile time warnings to be produced if you
        accidently override a field with a method name or vis-versa.

BUGS
    Field names can not be the same as method, function, or constant names.
    This is probably a Good Thing[tm].

    No way to cause compile time errors when one of these field names get
    redefined. IMHO, there is absolutely no time when redefining a sub is a
    Good Thing[tm], and should be taken out of the language.

HISTORY

     Revision 1.1  1998/06/01 18:02:06  byron
     Initial revision

AUTHOR
    Zenin <zenin@archive.rhps.org>

    aka Byron Brummer <byron@thrush.omix.com>.

    Based off of the constant module by Tom Phoenix.

SEE ALSO
    perldoc constant, perl(1).



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

Date: Mon, 01 Jun 1998 14:24:27 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: newbie trying to run Term::Cap on Win32
Message-Id: <3572F1DB.C45C9540@matrox.com>

tom arnall wrote:

> the compiler tells me that OSPEED and TERM are undefined and then goes
> back to OS w/out doing anything - what do i need to do to get the
> '$terminal' structure right?

You need to define the ospeed of your term ;-)
I prefer to use POSIX for that:

require Term::Cap;
require POSIX;

my $termios = new POSIX::Termios;
$termios->getattr;
my $ospeed = $termios->getospeed;
$terminal = Tgetent Term::Cap { TERM => undef, OSPEED => $ospeed};

Now .. you are ready to go!
Also, Check out:

% perldoc Term::Cap

--
Ala Qumsieh             |  No .. not just another
ASIC Design Engineer    |  Perl Hacker!!!!!
Matrox Graphics Inc.    |
Montreal, Quebec        |  (Not yet!)





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

Date: Mon, 01 Jun 1998 15:24:29 -0400
From: Dan Franco <dfrancoDONTSPAM@fore.com>
Subject: Perl class for newbie?
Message-Id: <3572FFED.B90204A0@fore.com>

Can anyone recommend a good Perl course for a non programmer?  Perhaps
something that teaches the basics of Perl along with general
programming concepts?

Thanks in advance,
Dan

Please remove the DONTSPAM from my email address to reply to me.

-- 
----------------------------------------------------------------------
Dan Franco                 UNIX System Administrator
FORE Systems, Inc.         Direct:  (724) 742-7685
3000 FORE Drive            Email:   dfranco@fore.com
Warrendale, PA 15086       Fax:     (724) 742-7474
URL:  http://www.fore.com  Main:    (724) 742-4444
----------------------------------------------------------------------
"One can never consent to creep when one feels an impulse
 to soar."
    - Hellen Keller
----------------------------------------------------------------------


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

Date: 1 Jun 1998 15:16:33 -0500
From: tye@fiinix.metronet.com (Tye McQueen)
Subject: Re: Perl for Win32 - Loading a hive file
Message-Id: <6kv271$p0d@fiinix.metronet.com>

scrivo_robert@jpmorgan.com writes:
) I have been trying to load a hive file using the following code:
) 
)   use Win32::Registry;
)   my $Register = "";
)   my $subkey = "MyHomeKey";
) 
)   $HKEY_LOCAL_MACHINE->Open($Register,$hkey)|| die $!;
)   $hkey->Load($subkey,"c:\\temp\\hive.reg")|| die $!;
)   $hkey->Close();
) 
) This returns "No such file or directory at load.pl line 6." even though the
) file exists as specified. Any thought on what I'm doing wrong would be greatly
) appreciated???

$! doesn't tell you anything about why Win32::Registry calls fail.
Actually, there is nothing that can tell you anything about why
Win32::Registry calls fail.  My replacement, Win32API::Registry,
uses SetLastError() so you can use Win32::GetLastError() to see
why its calls failed.

Win32::Registry has improved a great deal since I wrote
Win32API::Registry, with lack of error reporting the major problem
that I see remaining with it.  So you could patch it in that regard
or you could grab and use Win32API::Registry [unless you are using
ActiveWare Perl which doesn't support MakeMaker and so doesn't 
support most Perl extensions].

Perhaps your C: drive is a FAT file system and so you can't load
a hive that has a "." in its name [according to the documntation; I
haven't checked this myself].  More likely, hive.reg is not a hive
file [binary] but a text representation of a registry subtree so
you need to use something other than RegLoadKey() [which is what
Win32::Registry::Load() calls].  I don't think there is an API
call that decodes text representations of registry subtrees so you
probably have to use a program that understands whataver format
your hive.reg file was written in [perhaps regedit.exe].
-- 
Tye McQueen    Nothing is obvious unless you are overlooking something
         http://www.metronet.com/~tye/ (scripts, links, nothing fancy)


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

Date: 1 Jun 1998 18:47:49 GMT
From: psf@euclid.jpl.nasa.gov (Peter Scott)
Subject: Regex: parens inside quantifiers: can you capture all of them?
Message-Id: <6kut0l$rhc@netline.jpl.nasa.gov>

I recently had a parsing problem which looked amenable to using a
regex; I wanted to get a list of the tables and columns referenced
in an SQL SELECT statement, so I constructed a nice regex which took
into account the possibilities of column and table aliases, even the
ones which might have contained reserved words in quotes.  

Only trouble was, the capturing parens around the table and column names
only returned the last one in each case, because I had missed an
important point about regexes.  I'm not ready to give up on the regex
solution just yet, though.  The SQL regex is huge, here's a simpler 
example that shows what I mean:

#  animal foods         mammal? sounds

$_ = "dog kibble biscuits pal Y bark woof";
@fs = /(\w+) (?: \s+ (\w+) )* \s+ ([YN]) (?: \s+ (\w+) )*/x;
print "$1: @fs[1..$#fs]\n";

Output:		dog: pal Y woof

Now, if I wanted to capture all of the foods and all of the sounds
using a regex, is there a way?  Being able to express the syntax of
the statement in a single regex is just too appealing to want to
give it up without a fight...

-- 
This is news.  This is your      |  Peter Scott, NASA/JPL/Caltech
brain on news.  Any questions?   |  (psf@euclid.jpl.nasa.gov)

Disclaimer:  These comments are the personal opinions of the author, and 
have not been adopted, authorized, ratified, or approved by JPL.


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

Date: 1 Jun 1998 19:19:05 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Regex: parens inside quantifiers: can you capture all of them?
Message-Id: <896729170.501806@thrush.omix.com>

Peter Scott <psf@euclid.jpl.nasa.gov> wrote:
: I recently had a parsing problem which looked amenable to using a
: regex; I wanted to get a list of the tables and columns referenced
: in an SQL SELECT statement,

	You might want to take a look at the new SQL::Statement module
	just uploaded to CPAN.  It's entire job is parsing SQL.

-- 
-Zenin
 zenin@archive.rhps.org


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

Date: Mon, 01 Jun 1998 19:18:32 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Returning from a signal handler?
Message-Id: <Pine.GSO.3.96.980601121701.15370G-100000@user2.teleport.com>

On Mon, 1 Jun 1998, Brian J. Sayatovic wrote:

> Tom Phoenix wrote in message ...
> >On Fri, 29 May 1998, Brian J. Sayatovic wrote:
> >
> >Now, you know that a segfault doesn't make a signal which perl can catch,
> >right? That is, as I understand it, when a segfault happens, the perl
> >binary is unable to run further Perl code.

> I didn't realize this.  I mean, I thought it wouldn't affect perl if a child
> of it caused a segfault.  I've learned something for the day.

Wait - a segfault in the child process doesn't (in itself) hurt the parent
process. I was talking about a segfault affecting perl itself.

Cheers!

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



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

Date: 1 Jun 1998 15:16:04 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: simple question
Message-Id: <6kuulk$dao$1@monet.op.net>
Keywords: Jacques little pont Schuylkill


In article <356EC833.C36BF228@euroforum.nl>, a  <mvn@euroforum.nl> wrote:
>What I want is check for a directory "c:\perl\scripts" and if it's not
>there, create it.
>
>How could I do that?

You use the `mkdir' function.

If the directory already exists, then it'll fail, but who cares?





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

Date: Mon, 1 Jun 1998 13:19:01 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: simple question
Message-Id: <MPG.fdcac90e4bea3db989680@hplntx.hpl.hp.com>

In article <6kuulk$dao$1@monet.op.net>, mjd@op.net says...
> 
> In article <356EC833.C36BF228@euroforum.nl>, a  <mvn@euroforum.nl> wrote:
> >What I want is check for a directory "c:\perl\scripts" and if it's not
> >there, create it.
> >
> >How could I do that?
> 
> You use the `mkdir' function.
> 
> If the directory already exists, then it'll fail, but who cares?

I think I would care, because I would have to examine the failure code to 
see if it failed for some other reason than prior existence (such as 
permissions).  Otherwise I couldn't be sure the directory existed after 
the 'mkdir'.  It would seem simpler and safer to do the existence test 
first, then do the 'mkdir' and test for a real failure.

-- 
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com


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

Date: 1 Jun 1998 15:12:33 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: TIP : Complex CGI scripts
Message-Id: <6kuuf1$d8t$1@monet.op.net>
Keywords: brethren campground chromate Edwina

In article <6kunb7$kt4$1@nz12.rz.uni-karlsruhe.de>,
Pascal Wolff <ujiw@rz.uni-karlsruhe.de> wrote: The only drawback I can
>think of right now is that 'use strict' complains very heavily.  Any
>thoughts from the CGI/Perl-gurus ?

Do it this way:

----------------------------------------------------------------
%dispatch =
( tofrmGoHere =>  sub { .... },
  tofrmGoThere => sub { .... },
  ....
  DEFAULT      => sub { .... },
);

$FORM = DEFAULT;
foreach (param()) {
  $FORM = $_, last if /tofrm/;
}
$DISPATCH{$FORM}->();
----------------------------------------------------------------


You don't have to put the subroutines inlined into the %dispatch
structure; you can make them named subroutines and then use

	tofrmGoThere => \&doThereForm,

etc.


This dispatch table idea turns out to be an extremely valuable
technique in all sorts of applications.  For example, you can have a
hierarchical table of handler functions, and use something like this:

sub dispatch {
  my @where = @_;
  for (;;) {
    my $key = join $; , @where;
    if (exists $dispatch{$key}) {
      return $dispatch{$key}->(@_);
    } else {
      pop @where;
    }
  }
}

Then you can define a hierarchy of functions, so that you can call
`dispatch(animal,vertebrate,mammal,dog)', and if there's no routine
defined for that it'll automatically try (animal,vertebrate,mammal),
then (animal,vertebrate), then (animal), and finally a default handler
if nothing more appropriate was registered in the dispatch table.



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

Date: Mon, 01 Jun 1998 19:13:57 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: user autentification
Message-Id: <Pine.GSO.3.96.980601111114.15370E-100000@user2.teleport.com>

On Mon, 1 Jun 1998, stranger wrote:

> I'm novice in perl and, may be, it's foolish problem ,
> but plies don't replay "RTFM ".
> I'm also "read the ... manual" and there no solution.

If you've read the manual and there's no solution, what makes you think
that we've got a solution? :-)

> As I understand getpwid, getpnam don't allow to determinate right or wrong
> password :

Those functions will (on some systems) give you a crypted password; you
may then use the crypt function to encrypt the user's attempted password
to see whether it matches or not. The crypt function in perl is documented
in the you-know-what. :-) 

Hope this helps!

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



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

Date: Mon, 01 Jun 1998 18:08:53 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Using perl to post a CGI form
Message-Id: <Pine.GSO.3.96.980601110822.15370C-100000@user2.teleport.com>

On 1 Jun 1998, CoRey wrote:

> I'll need to telnet to that site, at port 80, and send the text
> to translate, along with the language options, in some fashion.
> Is there a module that helps with this?

Try LWP, which you can find on CPAN. Hope this helps!

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



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

Date: 1 Jun 1998 14:58:35 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Why is `undef' a unary op and not a list op?
Message-Id: <6kutkr$d3b$1@monet.op.net>
Keywords: blouse pomp pressure residual


In article <6kukfe$t1k$1@client3.news.psi.net>,
Abigail <abigail@fnx.com> wrote:
>If it would take a list argument, C<undef @array;> would give
>the same result as C<map {undef} @array;>, 

I see your point, and I think it's a good one.

But at present, we have the situation that the argument of `undef' is
in a special context: it's not evaluated.  For example,

	undef &foo;

does not invoke `foo', and

	undef $foo[1];

does not call FETCH if @foo is a tied array.

I don't see any reason why 

	undef @foo;

would necessarily evaluate @foo just because `undef' was now a list
operator.  I'm asking a syntactic change; it needn't be accompanied by
a semantic change.

Of course, such a change might be difficult to implement, but I
haven't looked, so I don't know.




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

Date: Mon, 01 Jun 1998 15:13:24 -0400
From: Bill Cowan <cowanb@mindspring.com>
To: Dmitri Budchenko <dmitri-b@usa.net>
Subject: Re: Win32::ODBC; NEW doesn't work
Message-Id: <3572FD54.FF3D907A@mindspring.com>

Dmitri Budchenko wrote:
> 
> The following line always returns False:
> 
> if (!($O1 = new Win32::ODBC($DSN1))){....
> 
> I'm running Perl 5.004 and Roth's ODBC on Windows95 machine. I did all
> required file copies required by ODBC installation instruction. Probably,
> the problem is in some incorrect value in @INC. Actually, before this line,
> script creates a proper DSN for a given Access database. Script has been
> tested on other similar machine, and worked Ok.

If "new" methold for Win32::ODBC return an undef (i.e. a false condition, 
instead of an object reference), then there was an error in db connection.
You need to do following to print actual error message:

use Win32::ODBC;
$Source = 'dsn=Sybase System 10;UID=foo;PWD=trash';

if ($db = new Win32::ODBC($Source)) {
    print "\nODBC connection successful for data source $Source.\n";
} else {
    #-- Get ODBC error information.
    $Message =  Win32::ODBC::Error();  # <<<===========================
    print "\nMessage: $Message\n";
    print "ERROR: ODBC error during connection\n";
    exit;
}

-- Bill
------------------------------------------------------------------------
Metagenix, Inc:  Leading the Way in Data Migration.
Web:  http://www.metagenix.com/ for more datails.
Bill Cowan, cowanb@mindspring.com, Voice: 919-210-4910 Fax: 919-489-2621
Applying Perl-based toolkit and methodology to data migration process.


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

Date: Mon, 01 Jun 1998 19:36:13 GMT
From: John Porter <jdporter@min.net>
Subject: Re: X marks the spot, was Re: Best tool?
Message-Id: <3573045F.6CA5@min.net>

Randal Schwartz wrote:
> 
> Alan... perhaps you weren't aware that my first salaried job was as a
> technical writer.  Learning to call something by its real official
> Marketing Approved Name is Very Important and Hammered In during the
> early training.  And "X Windows" is wrong enough that it grinds every
> time I hear it. :-)

Yeah, I remember many times at a previous job, 
seeing our manuals say things like "X/Windows", 
"X-Windows", "Xwindows", etc.
Going up to the tech writers -- "Um, excuse me..."

John Porter


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

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

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