[9504] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3098 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 8 16:07:17 1998

Date: Wed, 8 Jul 98 13:00:23 -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           Wed, 8 Jul 1998     Volume: 8 Number: 3098

Today's topics:
    Re: -w on production code (was Re: better way of gettin (Chip Salzenberg)
    Re: -w on production code (was Re: better way of gettin (Chip Salzenberg)
    Re: 2-byte code match problem lvirden@cas.org
    Re: <STDIN> chunk 1 - Error (Larry Rosler)
    Re: attachment to email <maierc@chesco.com>
        circular 'use' and exporting (Joe McMahon)
    Re: Comparing arbitrary dates <agy@macgreg.com>
    Re: explaining the whys of referencing... WAS Re: on th <dtbaker_@flash.net>
    Re: explaining the whys of referencing... WAS Re: on th <dfan@harmonixmusic.com>
    Re: File::Find recursive technique? <xah@shell13.ba.best.com>
        how to flush a socket? <pefe@camoes.rnl.ist.utl.pt>
    Re: I have a question. (Larry Rosler)
        MIME encoding Files & BLAT <starling@umr.edu>
    Re: NEVER "call warn() and return undef" (Re: question  <David.Boyce@fmr.com>
    Re: NEVER "call warn() and return undef" (Re: question  <aas@sn.no>
    Re: new charter and moderator for comp.lang.perl.announ (Clinton Pierce)
        Newbie Needs Help:  Very Easy Seach <chad@tice.com>
        NT Sysadmin scripts keydet89@yahoo.com
    Re: Oh man, DO I love Perl ! (References to things that <zenin@bawdycaste.org>
    Re: Oh man, DO I love Perl ! (References to things that <aas@sn.no>
    Re: OLE and Perl (Jan Dubois)
        OLE automation with excel mad_ahmad@my-dejanews.com
    Re: perl 5.004.04 on AIX 4.2.1 <pmora@ca.ibm.com>
        Perl CGI and warnings [Was: Re: -w on production code ( lvirden@cas.org
    Re: Perl CGI and warnings [Was: Re: -w on production co (Larry Rosler)
    Re: question about inline editing (Kelly Hirano)
    Re: regexp s/// for removing tail end of string (I.J. Garlick)
    Re: Text::MetaText Features <dtbaker_@flash.net>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 08 Jul 1998 19:31:38 GMT
From: chip@pobox.com (Chip Salzenberg)
Subject: Re: -w on production code (was Re: better way of getting the last modified file?)
Message-Id: <6o0hhi$4fg$1@cyprus.atlantic.net>

According to tchrist@mox.perl.com (Tom Christiansen):
>BUGS
>   The -w switch is not mandatory.
>   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Tom, you are well aware of the dangers of quoting 'scripture' out of
context.  Yes, Larry wrote that.  But he has also written that he
*likes* the way having -w and strictness optional has worked out:  It
brings rewards and feelings of virtue to those who choose the path of
wisdom, rather than making people feel coerced into doing right.

Given that context, and considering that Larry could make -w mandatory
*ANY* *TIME* he feels like it, you should really stop flogging the
fiction that the One True Perl Runtime is "perl -w -Mstrict".
-- 
Chip Salzenberg                - a.k.a. -               <chip@pobox.com>
"I brought the atom bomb.  I think it's a good time to use it."  //MST3K
           ->  Ask me about Perl training and consulting  <-
     Like Perl?  Want to help out?  The Perl Institute: www.perl.org


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

Date: Wed, 08 Jul 1998 19:34:15 GMT
From: chip@pobox.com (Chip Salzenberg)
Subject: Re: -w on production code (was Re: better way of getting the last modified file?)
Message-Id: <6o0hmc$4g1$1@cyprus.atlantic.net>

According to tchrist@mox.perl.com (Tom Christiansen):
>In comp.lang.perl.misc, Randal Schwartz <merlyn@stonehenge.com> writes:
>:-w is training wheels.  
>
>Please don't let Randal set a bad example for any of you.

Please don't let Tom make you lengthen the fringes of your garments.
Short fringes are OK.  So is running without -w, ** AS LONG AS YOU ARE
WILLING TO DEBUG IT ON YOUR OWN ** and not whine to c.l.p.m.

(If you don't the the 'fringe' thing, don't sweat it.  It's an obscure
religious point.  Kind of like -w, really.  :-))
-- 
Chip Salzenberg                - a.k.a. -               <chip@pobox.com>
"I brought the atom bomb.  I think it's a good time to use it."  //MST3K
           ->  Ask me about Perl training and consulting  <-
     Like Perl?  Want to help out?  The Perl Institute: www.perl.org


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

Date: 8 Jul 1998 19:09:28 GMT
From: lvirden@cas.org
Subject: Re: 2-byte code match problem
Message-Id: <6o0g58$j2m$1@srv38s4u.cas.org>


According to Abigail <abigail@fnx.com>:
:lvirden@cas.org (lvirden@cas.org) wrote on MDCCLXIX September MCMXCIII in
:<URL: news:6nnm32$t0g$1@srv38s4u.cas.org>:
:++ 
:++ According to Abigail <abigail@fnx.com>:
:++ :Yun Giljung (mingtian@hanmail.net) wrote on MDCCLXVIII September MCMXCIII
:++ :in <URL: news:359de7d1.34507217@usenet.kornet21.net>:
:++ :++ i hope Perl is not be like Java or Visual Basic or TCL that use Unicode
:++ :++ for their internal system, that really does not help 2 bytes codes.
:++ 
:++ :There doesn't seem to be any indication Perl is going towards fixed
:++ :width 16bit characters. But it will have UTF-8 support.
:++ 
:++ 
:++ The sad part of this is that there are additional, wider, versions of unicode
:++ that still won't be supported.
:++ 
:++ However, hopefully if the utf-8 support is done correctly, additional changes
:++ to support the wider utf's can be made interally and the perl programmer
:++ won't need to know about it.
:
:UTF-8 is an encoding for UCS-2 and UCS-4. Currently, exactly 0 codepoints
:of UCS-4 which aren't part of UCS-2 have been assigned to.
:
:Which wider versions of Unicode are you referring to?

I was referring to comments a coworker made to me referring me to unicode.org
and to utf-16.  Apparently, from your remarks, either his understanding of
the info at that site, or my understanding of his arguments of utf-16 vs utf-7
are misinformed.  I apologise .
-- 
<URL:mailto:lvirden@cas.org> Quote: In heaven, there is no panic,
<*> O- <URL:http://www.teraform.com/%7Elvirden/> only planning.
Unless explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.


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

Date: Wed, 8 Jul 1998 11:44:00 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: <STDIN> chunk 1 - Error
Message-Id: <MPG.100d5dd06fd78cc59896f4@nntp.hpl.hp.com>

[This followup was posted to comp.lang.perl.misc and a copy was sent to 
the cited author.]

In article <35A1D837.45B3@chesco.com> on Wed, 08 Jul 1998 17:23:49 GMT, 
Charles Maier <maierc@chesco.com> says...
> Larry Rosler wrote:
> > In article <35A1329A.D9D5A89F@provideo.dk> on Mon, 06 Jul 1998 13:24:58 -
> > 0700, Thomas Albech <thomas@provideo.dk> says...
 ...
> > > if ($name =~ "randal") {
> > 
> > Type more carefully.
> > 
> > if ($name eq "randal") {
 ...
> Thats ok.. the operator =~  means "contains" to ME. I read his line as
> saying "$name contains randal"... which should work just as well.

The operator =~ means "matches" to almost everyone else.  The second 
problem here is the use of double-quotes to delimit the regex.  Here is 
what Friedl (in 'Mastering Regular Expressions', p. 248) says about that:

Similarly, using $test =~ "...string..." could be useful if you wanted 
*real* double-quote processing, rather than the doublequote*ish* 
processing discussed earlier.  But frankly, I would leave this to an 
Obfuscated Perl Contest.

> His problem appears to be.. he is printing a possible NULL value. If the
> name enterred is NOT in the hash.. he does not test for it.... and tries
> to print it. 

You mean *undefined* value -- he does test for a NULL value ("").
 
> > $secretword = $words{$name};  # get the secret word
> > print "$secretword\n";   # Displays secret word
> 
> A better choice might be:
> 
> if exists($words{$name}) {

An even better choice might be something that compiles:

  if (exists($words{$name})) {

> 	$secretword = $words{$name};  # get the secret word	
> 	print "$secretword\n";   # Displays secret word
> } else {
> 	$secretword = "groucho";
> }

This is all discussed on p. 11:

If the name is not found, the value of $secretword will be an empty 
string,* ...

* Well, OK, it's the *undef* value, but it looks like an empty string to 
the *eq* operator.  You'd get a warning about this if you used -w on the 
command line, which is why we omitted it here.

BUT:  He didn't omit it on p. 10, which is where the footnote relates 
(but he did omit it at the bottom of p. 11).  That is an erratum, which I 
didn't find at 
<URL:http://www.oreilly.com/catalog/lperl2/lperl2.current>.

-- 
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 08 Jul 1998 19:25:13 GMT
From: Charles Maier <maierc@chesco.com>
Subject: Re: attachment to email
Message-Id: <35A1F4A8.3429@chesco.com>

Gangadhar Vaddepalli wrote:
> 
> Hi There,
> I'm wondering whether we can attach another file to email using Perl.
> I want to send an attchment which is also an HTML file along with the
> message.
> 
> Can anybody give me some idea?
> 
> --
> Thanks
> Gangadhar
> Tel: (650)964-1807
> vadepali@ix.netcom.com

I typically run on a UNIX system and have tied to figger this too. I
HAVE read the sendmail manpage (my email interface) and it does not
explain this very well. Anyone had success with sending atachment(S)
with sendmail??

-- 
Chuck Maier
CDM Consulting Services
http://www.cdmcon.com
(610) 943-2726


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

Date: Wed, 08 Jul 1998 13:50:01 -0400
From: joe.mcmahon@gsfc.nasa.gov (Joe McMahon)
Subject: circular 'use' and exporting
Message-Id: <joe.mcmahon-0807981350010001@prtims.stx.com>

This situation has come up in our code; we've got a workaround, but it's
not pretty at all. We're looking for a better way to do it, modulo some
restrictions.

We have a class which initializes a number of variables with object
references and then exports them. (Yes, I know this isn't such a great
idea, but at the moment we haven't the time to restructure the entire
system.) Many other classes 'use' this class and therefore get access to
these global object references.

We have created a new class that this initializer class calls. It needs
access to the initializer's globals, so we have the new class 'use' the
initializer class. The initializer class needs to call methods in the new
class, so we have the initializer 'use' the new class. Another module uses
the initializer class and calls it, resulting in a call from the
initializer to the new class. Here's a vastly simplified example:

In A.pm:

    package A;

    BEGIN { $Exporter::Verbose = 1 }

    use Exporter;
    @ISA = qw(Exporter);
    @EXPORT = qw($foo);

    use vars qw($foo);

    use B;

    $foo = "I have foo!";

    sub show {
        B::show();
    }

    1;


in B.pm:

   package B;
   use A;    # expecting import of $foo - see below

   sub show {
       print "I think \$foo is '$foo'\n";
   }

   1;

in main:

   use A;
   a::show();

When we get to B, $foo is undefined. Output looks like this.

Importing into A from Exporter:  at /usr/people/joe/lib/perl5/Carp.pm line 0
Importing into main from A: $foo at /usr/people/joe/lib/perl5/Exporter.pm
line 152
        Exporter::export('A', 'main') called at
/usr/people/joe/lib/perl5/Exporter.pm line 182
        Exporter::import('A') called at main line 1
        main::BEGIN() called at A.pm line 0
        eval {...} called at A.pm line 0
I think foo is ''

If we add an explicit A->import() in B:

    sub show {
        A->import;
        print "I think \$foo is '$foo'\n";
    }
   
we get

Importing into A from Exporter:  at /usr/people/joe/lib/perl5/Carp.pm line 0
Importing into main from A: $foo at /usr/people/joe/lib/perl5/Exporter.pm
line 152
        Exporter::export('A', 'main') called at
/usr/people/joe/lib/perl5/Exporter.pm line 182
        Exporter::import('A') called at main line 1
        main::BEGIN() called at A.pm line 0
        eval {...} called at A.pm line 0
Importing into B from A: $foo at A.pm line 16
I think foo is 'I have foo!'

Voila. The variable is accessible, but the explicit call to import is a
bit hard to explain to the uninitiated reader, and it makes an explicit
dependency on A. Alternatively, we can just reference the silly thing
directly in B:

    sub show {
        print "I think \$foo is '$A::foo'\n";
    }

with the same results as before, $foo is now visible, but then it becomes
necessary to explain why we have an explicit dependency A again.

Is there a better way to address the circular 'use'? (Don't tell me not to
export the variables - I know that that is the real solution, but we
haven't scheduled enough time to make that much of a structural change to
every module for this release - we've had a "prove this is Y2K compliant"
foisted on us already that wasn't in the release schedule.) 

 --- Joe M.


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

Date: Wed, 8 Jul 1998 15:27:57 -0400
From: "Adam Graham-Yooll" <agy@macgreg.com>
Subject: Re: Comparing arbitrary dates
Message-Id: <6o0h78$ru1$1@client3.news.psi.net>


Mark Evan Jones wrote in message <35A39D73.9AD430F1@mindless.com>...
>I am looking to find code that can both compare two dates and tell me
>the difference in days as well as return a date when a number of days
>are added to an initial one. I have located a few modules that do what I
>want (most notably Steffen Beyer's Date::Calc), but I do not currently
>have install access on these machines, and I was wondering if there were
>equivilent modules/scripts included with the standard distribution of
>perl 5.00404?  I can't seem to find any summary information on all these
>.pl and .pm files in the libraries do.  Can someone point me to such a
>list, or point out a script that can do what I need that doesn't require
>access to the lib dirs?

try these two functions to get Julian and Gregorian dates.

sub julianDt {
 my $date = $_[0];
 my $m;
 my $d;
 my $y;
 ($m,$d,$y) = split /,/, $date;
 my $a = int(($m - 14) / 12);
 my $one = int((1461 * ($y + 4800 + $a)) / 4);
 my $two = int(367 * ($m - 2 - (12 * $a)) / 12);
 my $three = int((3 * int(($y + 4900 + $a) / 100)) / 4);
 my $jd = $one + $two - $three + $d - 32075;
 return $jd;
}

sub gregDt {
 my $jd = $_[0];
 my $month;
 my $year;
 my $w = int(($jd - 1867216.25) / 36524.25);
 my $x = int($w / 4);
 my $a = $jd + 1 + $w - $x;
 my $b = $a + 1524;
 my $c = int(($b - 122.1) / 365.25);
 my $d = int(365.25 * $c);
 my $e = int(($b - $d) / 30.6001);
 my $f = int(30.6001 * $e);
 my $day = $b - $d - $f;
 if ($e > 13) {
   $month = $e - 13;
 }
 else {
   $month = $e - 1;
 }
 if (($month == 1) || ($month == 2)) {
   $year = $c - 4715;
 }
 else {
   $year = $c - 4716;
 }
 my $date = "$month" . "," . "$day" . "," . "$year";
 return $date;
}





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

Date: Wed, 08 Jul 1998 13:13:38 -0500
From: Dan Baker <dtbaker_@flash.net>
Subject: Re: explaining the whys of referencing... WAS Re: on the fly subs with special tag markers
Message-Id: <35A3B6D2.63D@flash.net>

Larry Rosler wrote:

> References on references:  perldoc perlref and Chapter 1 of 'Advanced
> Perl Programming'
> 
> References on data structures:  perldoc perldsc and Chapter 2 of
> 'Advanced Perl Programming'
> 
> Understanding and using references may be the boundary between novice
> and intermediate in Perl programming, like switching from snowplow turns
> to stem turns in skiing.  Welcome to Middle School. :-)
---------

ah crap... too bad I didn't start with perl when I was a kid! I'd be
fearless, and wouldn't mind falling down so much.  ;)  I think I'd
better go practice onthe bunny hill for a while, at least for this
week...


D




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

Date: 08 Jul 1998 14:55:33 -0400
From: Dan Schmidt <dfan@harmonixmusic.com>
Subject: Re: explaining the whys of referencing... WAS Re: on the fly subs with special tag markers
Message-Id: <wk7m1oxjdm.fsf@turangalila.harmonixmusic.com>

Dan Baker <dtbaker_@flash.net> writes:

| eep, I was afraid it would be something like that! references are a
| topic I am still having a lot of trouble with. I think my brain is
| stuck in old fashioned pass-the-value... can you recommend any
| specific book that does a good job of explaining references to
| beginners?

The Summer 1998 issue of The Perl Journal has an excellent
introduction to references written by Mark-Jason Dominus.

-- 
                 Dan Schmidt -> dfan@harmonixmusic.com, dfan@alum.mit.edu
Honest Bob & the                http://www2.thecia.net/users/dfan/
Factory-to-Dealer Incentives -> http://www2.thecia.net/users/dfan/hbob/
          Gamelan Galak Tika -> http://web.mit.edu/galak-tika/www/


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

Date: 08 Jul 1998 11:35:15 -0700
From: Xah Lee <xah@shell13.ba.best.com>
Subject: Re: File::Find recursive technique?
Message-Id: <yo3d8bgw5r0.fsf@shell13.ba.best.com>


Thanks to Chris Nador.

I've found another way. Basically, this algorithm is based on the level notion. i.e. each node in the tree is assigned a level. Here's a rough description:
Traverse the tree, 
 if the current file's level is same as previous file's level, then do nothing special;
 if the current is greater than previous by n, then print n number of "<ul>";
 if current is less than previous, then print n "</ul>" as before.
Each time the above "which" is evaluated, print a "<li>currentFileName" at the end.

I find it extremely difficult to implement the above inside a subroutine passed to File::Find::find, because the way File::Find::find was written. What I did was to use "File::Find::find" to read the whole file tree into an array, and process array outside the "find".

Here's the script for those interested. (its for Mac, as is.)

#!/usr/local/bin/perl5 -w

use strict;
use File::Find;
use File::Basename;

my $inputFilePath=q{user347:T2:perl_files_dir:};
my @fileListArray;

find(sub {push(@fileListArray,qq($File::Find::name\n));},$inputFilePath);

# cLevel stands for currentLevel. pLevel stands for previousLevel.
my $cLevel=0;
my $pLevel=0;
my $currentFileFullName;

print qq(<ul>\n);

foreach $currentFileFullName (@fileListArray) {

$cLevel = substr($currentFileFullName,length($inputFilePath)) =~ tr(:)();

if ($cLevel == $pLevel) {;} elsif ($cLevel > $pLevel) {foreach $_ ($pLevel+1 .. $cLevel) {print qq(\t)x$_ . qq(<ul>\n)};} else {foreach $_ (reverse($cLevel+1 .. $pLevel)) {print qq(\t)x$_ . qq(</ul>\n)};};

print qq(\t) x $cLevel . qq(<li>) . basename($currentFileFullName) . qq(\n);

$pLevel=$cLevel;
};

print qq(</ul>\n);

__END__


This task should be easily done by a recursive algorithm, but cannot be done with File::Find::find because the way it is written. Specifically, because it starts with the directory instead of it's content. File::Find::find is flawed in many other ways as well. I've received a few solutions, all seems to be very complex. Quite an unwholesome situation.

Btw, who wrote File::Find?

 Xah, xah@best.com
 http://www.best.com/~xah/Wallpaper_dir/c0_WallPaper.html
 "Unix + C + Perl = apocalypse now"




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

Date: Wed, 08 Jul 1998 20:18:26 +0200
From: Pedro Ferraz <pefe@camoes.rnl.ist.utl.pt>
Subject: how to flush a socket?
Message-Id: <35A3B7F2.10D3A609@camoes.rnl.ist.utl.pt>

    I've got a problem:
    I'm making a CGI in Perl and he communicates with an Java aplication
via socket. When he sends the data to the Java app, he then blocks in
the read from the socket, waiting for the response. But meanwhile, the
Java app stays blocked too in the readLine (i'm using Buffered Reader
streams), because the Perl seems not to have flushed the question...
    txs in advance....

Pedro Ferraz



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

Date: Wed, 8 Jul 1998 11:59:24 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: I have a question.
Message-Id: <MPG.100d6169776542769896f5@nntp.hpl.hp.com>

[This followup was posted to comp.lang.perl.misc and a copy was sent to 
the cited author.]

In article <35A3AFF3.5F13@cs.itc.hp.com> on Wed, 08 Jul 1998 11:44:19 -
0600, Jack Xie <jackx@cs.itc.hp.com> says...
> Hi:
> 	I was reading Teach yourself Perl5 for 21 days. I stamble across  this
> code: 
> 	
> 
> $string =~ s/\d{2} ([\W]) \d{2} \1 \d{2}/$1-$2-$3/x;
> 
> 
> The book says that it converts a day-month-year string to the dd-mm-yy
> format. I don't understand how this code works, can anyone explain it to
> me?

What makes you think it works, when it obviously doesn't.  The obvious 
error is the reference to three captured matches, when there is only one 
set of capturing parentheses.  The brackets around \W are superfluous, 
also.

I'd suggest the wastebasket for that book.  Buy 'Learning Perl' from 
O'Reilly & Associates.  HP will save a lot of money that way in the long 
run, which will help our profit-sharing. :-)

-- 
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 8 Jul 98 19:06:41 GMT
From: sTarLING <starling@umr.edu>
Subject: MIME encoding Files & BLAT
Message-Id: <35a3c341.0@news.cc.umr.edu>

I'm needing to MIME encode files and send them out from a Win95/NT 
environment using the Win32 build of Perl.  

Can I use the the MIME Tools module by Eryq to encode the files and then 
use BLAT to mail them?


Anyone have a better way to do this?  

Or, does anyone have any tips on getting the MIME tools to work with 
Win32 Perl?


Ugh.  This'd be SO much easier on a unix system...

thanks,
chris starling


starling@umr.edu
starling@ccsi.com


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

Date: Wed, 08 Jul 1998 14:19:20 -0400
From: David Boyce <David.Boyce@fmr.com>
Subject: Re: NEVER "call warn() and return undef" (Re: question about objects)
Message-Id: <35A3B828.79D04EA6@fmr.com>

Zenin wrote:
> 
> Gisle Aas <aas@sn.no> wrote:
>         >snip<
> : I'm sure that not everyone will agree that Perl lack a robust
> : exception mechanism today.  What's un-robust with what we have?
> 
>         eval {
>             do_something() or die "I didn't do_somthing";
>         };
>         if ($@) {
>             if ($@ =~ /do_something/) {
>                 handle_do_something_error();
>             }
>             else { die };
>         }

Yes, and let's not even get into how this would work in a different
locale ...

-David


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

Date: 08 Jul 1998 20:43:06 +0200
From: Gisle Aas <aas@sn.no>
Subject: Re: NEVER "call warn() and return undef" (Re: question about objects)
Message-Id: <m3ogv0xjyd.fsf@furu.g.aas.no>

Zenin <zenin@bawdycaste.org> writes:

> Gisle Aas <aas@sn.no> wrote:
> 	>snip<
> : I'm sure that not everyone will agree that Perl lack a robust
> : exception mechanism today.  What's un-robust with what we have?
> 
> 	eval {
> 	    do_something() or die "I didn't do_somthing";
> 	};
> 	if ($@) {
> 	    if ($@ =~ /do_something/) {
> 	        handle_do_something_error();
> 	    }
> 	    else { die };
> 	}
> 
> 	Look a little closer if you missed it.

The problem is that the "Undefined subroutine &main::do_something"-exception
is caught by your RE and invokes handle_do_something_error(), and if
the die inside eval is invoked you misspelled somthing so it wouldn't
match.

If you are afraid of typos, you can always do something like this:

   use strict;
   use constant do_something_exception => "do_something_exception\n";

   eval {
      do_something() or die do_somthing_exception;
   };
   if ($@) {
       if ($@ eq do_something_exception) {
           handle_do_something_exception();
       }
       else { die; }
   }

With perl5.005 you will be able to throw objects, and then you can set
up an exception handler like this:

   if ($@ && ref($@)) {
       if ($@->is_math_error) {
            handle_math_error();
       } elsif ($@->is_something_error) {
            handle_something_error();
       } else {
	    die;  # propagate
       }
   } elsif ($@) {
       die;  # perhaps an internal Perl exception
   }

-- 
Gisle Aas


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

Date: 8 Jul 1998 17:10:16 GMT
From: cpierce1@cp500.fsic.ford.com (Clinton Pierce)
Subject: Re: new charter and moderator for comp.lang.perl.announce
Message-Id: <6o095o$r4q1@eccws1.dearborn.ford.com>

In article <5qogv02vku.fsf@prometheus.frii.com>,
	Nathan Torkington <gnat@frii.com> writes:
>Randal Schwartz <merlyn@stonehenge.com> writes:
>> So, what do you think a new charter should permit/deny?  Who do you
>> think should be moderator?
>
>As I said to you on #perl, I feel that commercial postings should be
>allowed.  I think comp.lang.perl.announce should be for announcements
>relating to Perl--including conferences, new books, new issues of The
>Perl Journal, new modules, and commercial products that use Perl.
>                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I'd like clarification on this part.

Our product contains 1% Perl code...may we advertize a new release on 
clpa?  no?  50%!  May we advertize now?  If the Apache Project announces
a new server with enhanced perl support features, does that warrant an
announcement?  Do they get a break 'cause they're in the free-source
movement also?  Would a commercial vendor (say, Netscape) get the same
break?

That part can get real ugly.

Perhaps "commercial products which have perl as a focused part of the
product: development libraries, unusual ports, extensions (such as GUIs),
IDEs and debuggers."?

-- 
+------------------------------------------------------------------------+
|  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: Wed, 8 Jul 1998 14:38:13 -0500
From: "Chad Hudson" <chad@tice.com>
Subject: Newbie Needs Help:  Very Easy Seach
Message-Id: <6o0hud$vc$1@news.onramp.net>

By defalut I am the company's webmaster and I need a very simple perl script
that will search a database file and spit out the url which would be in the
first col.

Example

F_USA.html    Flag of the United States of America
F_Canada.html    Flag of Canada
M_USA    Map of the United States of America

There has to be a free script out there that does this.  I have a search
engine for search mult. files, but would like a quicker engine.

Thank you
Chad Hudson




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

Date: Wed, 08 Jul 1998 18:02:01 GMT
From: keydet89@yahoo.com
Subject: NT Sysadmin scripts
Message-Id: <6o0c6p$jla$1@nnrp1.dejanews.com>

Does anyone know were I can find Perl on Win32 sysadmin
scripts for maintaining a NT/win95 network?

I have checked ActiveState, but I haven't been able to access
their forums.

I am particularly interested in controlling services, accessing
the registry and the EventLog; using NetAdmin, AdminMisc, and NetResource.

Basically, I am looking for examples that I can modify for my own
sysadmin uses...

Thanks

Carv

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 8 Jul 1998 18:19:37 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Oh man, DO I love Perl ! (References to things that go out of scope)
Message-Id: <899922517.608539@thrush.omix.com>

Tom Christiansen <tchrist@mox.perl.com> wrote:
: All data should always be private.  Totally.  Once you start
: messing around with an objects internals and you are not that
: class, you have violated the abstraction.  Don't do that.

	I believe you where the first one I saw use the term, OOOP (Overly
	Object Oriented Programming).

	Abstraction is a good thing, when it has a purpose.  Abstraction for
	the sake of abstraction alone is often counterproductive.  There is
	a time and place for set/get methods, and a time and place for
	direct public/protected field access.  Chose the best tool and
	design for the job at hand.  Forcing the use of a particular methodology
	without reguard for the task at hand isn't very Perlish.
-- 
-Zenin
 zenin@archive.rhps.org


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

Date: 08 Jul 1998 20:54:53 +0200
From: Gisle Aas <aas@sn.no>
Subject: Re: Oh man, DO I love Perl ! (References to things that go out of scope)
Message-Id: <m3lnq4xjeq.fsf@furu.g.aas.no>

Zenin <zenin@bawdycaste.org> writes:

> Gisle Aas <aas@sn.no> wrote:
> : The '_foo' in B and the '_foo' in D is separate.  The same 'foo' is
> : visible in all classes.  The 'bar' in B and the 'bar' in D is
> : separate.  In E 'foo' from B and 'bar'/'baz' from D is visible; the
> : private fields (and 'bar' from B) are not.
> : If 'B' at some point introduce a new field called 'baz', then there
> : will be no conflict with the use of the field 'baz' in D.
> 
> 	...Ok, I think we're one the same page, but I'm not sure I
> 	understand the logic you've got here for why what is which.
> 
> 	What exactly desides that one field is private vs public?
> 	Is it the leading underscore?

Currently it is.

>                                        Is everything else public/protected,
> 	unless declared with use fields?

Everything not declared with fields is regarded as a typo.

>                                         In which case, the last one
> 	to be declared (in the highest sub package) is the one visible
> 	as public/protected until something else declares it with
> 	fields?

Yup!

> 	Personally (if I read this correctly), I think I would have
> 	much preferred syntax like:
> 
> 	package B;
> 	use public qw(foo bar);
> 	use private qw(_foo);
> 
> 	Or at least:
> 
> 	use fields::public qw(foo bar); 
> 	...etc...

This is a very good idea.  I have been playing privately with stupid
syntaxes like:

    use fields [a => "private"];
    use fields "a:private";

but it never made sense to me, so I ended up with the "_" rule in the
fields.pm patch I made.  The current fields.pm module is still
experimental so it would not be difficult to change it.

> 	Thus giving the ability to call the fields whatever one likes,
> 	and also allow for a "use protected" if such support is possible.

I like it.  I don't think "protected" makes much sense in perl where
you can enter and leave classes whenever you want.

> 	-Perl, beyond all other languages, typically trys hard to let
> 	the user do what they like the way they like without forcing
> 	conventions, such as leading underscores, globals in leading
> 	caps, constants in all caps, etc.  Why force name convetion
> 	here?

It was just a first shot at implementing the mechanisms to support
private fields.  Implementing your idea with two different pragmas is
easy with the current fields.pm.

> 	Don't get me wrong, I think fields and what it represents is
> 	absolutely great (possibly, one of the best things to happen
> 	to perl since it moved away from 4.x), I just think the
> 	syntax could be a little cleaner.

Agree.

-- 
Gisle Aas


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

Date: Wed, 08 Jul 1998 21:48:30 +0200
From: jan.dubois@ibm.net (Jan Dubois)
Subject: Re: OLE and Perl
Message-Id: <35a3c443.4283419@news2.ibm.net>

[mailed & posted]

Helmut Dreyer <dreyer@ttc.thyssen.de> wrote:

>I'm trying to build some scripts in Perl doing OLE automation with
>german MS Office applications (Excel and Access). At the moment I have
>problems at two points:
>
>(1)
>I'm looking for the the names of objects, methods and properties of
>the OLE servers in the german MS Office 97 package ... but until now
>with only little success. Can anybody give me a hint where I can find
>a german documentation of the OLE servers in the german MS Office 97
>??

You will find this in the "Visual Basic Reference for Microsoft Excel"
etc. that is only installed if you select it during custom setup.
Microsoft doesn't expect "standard" users of their product to use VB (or
OLE automation). :-)

>(2)
>Some of the methods in the german OLE servers use
>non-international-characters (e. g. "Vffnen" for "Open"). When I use
>these words in a Perl script I get comilation Errors and the prog is
>not executed. Can anybody give me a hint how to solve this problem ??

This was true for Office 95 and earlier, but Microsoft has stopped this
foolishness by now and always uses the English names in the Office 97
type libraries. So you would have to call C<Open> and not C<Vffnen>.
Just in case you really need to talk to some older OLE server you can
use the C<Invoke> method:

    my $Doc = $Object->Invoke('Vffnen', @OtherArgs);

This is only available in the Win32::OLE module and not in ActiveState
build 3xx however.

-Jan

PS: If you actually do use Office 97, don't forget to install service
release 1. This fixes several problems with the type libraries
(especially for Word).


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

Date: Wed, 08 Jul 1998 19:21:01 GMT
From: mad_ahmad@my-dejanews.com
Subject: OLE automation with excel
Message-Id: <6o0gqs$s0u$1@nnrp1.dejanews.com>

Hi, I'm working on a project where i'm making calls to an Excel spreadsheet
from perl thru OLE automation. I can grab individual cells from a
spreadsheet, but I want to grab a range from a spreadsheet and store it in an
array in Perl.	so that it's much faster So far I have tried the following:

$j = 2;
@ourcolumn = $comparesheet->Range(Cells(2,$j), Cells(42,$j))->{'Value'};

and:

@ourcolumn = $comparesheet->Range("Cells(2,$j), Cells(42,$j)")->{'Value'};

I think it should work because the following does:

$worksheet->Range("A1:D1")->{'Value'} = ["North","South","East","West"];

thanks for any help.

Ahmad saeed


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Wed, 08 Jul 1998 13:43:53 +0000
From: Paul Mora <pmora@ca.ibm.com>
Subject: Re: perl 5.004.04 on AIX 4.2.1
Message-Id: <35A37799.2179ED74@ca.ibm.com>

Darren Henderson wrote:

> I'm having some trouble getting perl 5.004.04 to compile under AIX 4.2.1.
>
> It's comming down to the following.....
>
>         AutoSplitting perl library
>
>         Making DynaLoader (static)
>          gcc  -L/usr/local/lib -bE:perl.exp -o perl perlmain.o
> lib/auto/DynaLoad
> er/DynaLoader.a  libperl.a `cat ext.libs` -lnsl -ldbm -ldl -lld -lm -lc
> -lbsd -l
> PW
> ld: 0706-005 Cannot find or open file: libgcc.a
>         ld:open(): No such file or directory
> ld: 0706-005 Cannot find or open file: libgcc.a
>         ld:open(): No such file or directory
> gcc: file path prefix `/usr/local/lib/gcc-lib/E:perl.exp/2.8.1/' never
> used
> make: The error code from the last command is 1.
>

Hi.

Put a link for libgcc.a in /lib.  It usually resides somewhere in
/usr/local/lib/gcc-lib/rs6000-ibm-aix/<version>.

pm

--
Paul Mora
email: pmora@ca.ibm.com




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

Date: 8 Jul 1998 18:39:35 GMT
From: lvirden@cas.org
Subject: Perl CGI and warnings [Was: Re: -w on production code (was Re: better way of getting the last modified file?)
Message-Id: <6o0ed7$gtl$1@srv38s4u.cas.org>


According to Zenin  <zenin@bawdycaste.org>:
:Abigail <abigail@fnx.com> wrote:
:: The fact that an upgrade of perl might emit new warnings is a *GOOD*
:: reason to keep -w on production code.
:
:	I agree, with the exception of most CGI code.  As much as I'd
:	love it to be otherwise, web error logs just don't get looked
:	at when not developing or debugging so any warnings are just
:	going to go to waste, or worse (in the case of some versions
:	of Netscape) going to cause the server to barf.  Sending the
:	errors to the browser via CGI::Carp is completely out of the
:	question for production code. -If a client sees some random
:	(and very likely harmless) warning suddenly appear on there
:	web pages they'd freak, and rightfully so.

Okay.  Here's what I have read so far

1. CGI that no longer work, or potentially will quit working soon is a bad thing.
2. CGI is frequently installed in odd out of the way places and cannot
necessarily all be tested before installing an urgent upgrade to perl with
regards to security.

3. Using perl -w in CGI scripts generates errors that go into web error logs
that just don't get looked at frequently enough.  Use of the -Mdiagnostics
will reduce the number of warnings to those logs, but doesn't help with the
fact that the logs are not being checked.

4. Use of CGI::Carp sends the output to the users - not necessarily a
politically correct thing to do.

It seems to me that items 1 and 2 imply that one certainly doesn't want to
be rudely surprised by a new emergency upgrade to perl that causes the
script to malfunction or cease functioning.

If folk don't want the output to go to the user, and don't check the error logs,
then some kind of alternative seems to be useful.

Is there a way that the perl -Mdiagnostics -w output could be emailed to
a script maintainer?  
-- 
<URL:mailto:lvirden@cas.org> Quote: In heaven, there is no panic,
<*> O- <URL:http://www.teraform.com/%7Elvirden/> only planning.
Unless explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.


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

Date: Wed, 8 Jul 1998 12:44:07 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Perl CGI and warnings [Was: Re: -w on production code (was Re: better way of getting the last modified file?)
Message-Id: <MPG.100d6be4d9b6c4729896f6@nntp.hpl.hp.com>

[This followup was posted to comp.lang.perl.misc and a copy was sent to 
the cited author.]

In article <6o0ed7$gtl$1@srv38s4u.cas.org> on 8 Jul 1998 18:39:35 GMT, 
lvirden@cas.org <lvirden@cas.org> says...
 ...
> If folk don't want the output to go to the user, and don't check the error logs,
> then some kind of alternative seems to be useful.
> 
> Is there a way that the perl -Mdiagnostics -w output could be emailed to
> a script maintainer?  

Yes.  I suggested that earlier in this thread, and did not meet with 
universal approval (mild understatement!!!).  But here is one way to do 
it on Unix systems.  It mails the warning together with an edited call-
stack trace:

$SIG{'__WARN__'} = sub {	# Intercept a warning and report.
    my ($err, $i, $file, $line) = (shift, 0);
    $err .= " @{[$file =~ m|([^/]+)$|]}:$line" while
	($file, $line) = (caller ++$i)[1, 2];
    $ENV{PATH} .= ':/usr/sbin:/usr/lib';
    if (open MAIL, "| sendmail -odi -oem -t") { # Give up on failure.
        print MAIL "To: $Mail\nSubject: $Subject\n\n$err";
        close MAIL;
    }
}; 

The recipient $Mail and subject $Subject have to be defined, of course.

-- 
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 8 Jul 1998 12:44:45 -0700
From: hirano@Xenon.Stanford.EDU (Kelly Hirano)
Subject: Re: question about inline editing
Message-Id: <6o0i7d$jmt@Xenon.Stanford.EDU>

In article <MPG.100d8d73d4a866bc9896ae@news.surfnet.nl>,
Real <real@earthling.net> wrote:
>Alexander Farber wrote;
>> (Okay, i can check for </BODY>, but that's not the question.
>> And AFAIK $ARGV contains the name of actual file, but i wonder
>      ^^^^^
>        |
>What ? -+

as far as i know
-- 
Kelly William Hirano	                    Stanford Athletics:
hirano@cs.stanford.edu	                 http://www.gostanford.com/
hirano@alumni.stanford.org      (WE) BEAT CAL (AGAIN)! 100th BIG GAME: 21-20


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

Date: Tue, 7 Jul 1998 16:13:44 GMT
From: ijg@csc.liv.ac.uk (I.J. Garlick)
To: "Jerry" <jerry@fitzweb.com>
Subject: Re: regexp s/// for removing tail end of string
Message-Id: <EvqFqw.LD6@csc.liv.ac.uk>

[Posted and mailed]

In article <6norj5$afs$1@news.iquest.net>,
"Jerry" <jerry@fitzweb.com> writes:
> Hi there, hope someone can give me a quick hack to do this.
> 
> I have a string that is a full path to a file, i.e.
> dir/subdir/subsubdir/file.ext  What I want to do is strip off the file name,
> leaving just the path info (with the final / ) in a string.  The paths will
> have a varying number of directories, so I don't think I can use split to
> just grab all the dirs, throw out the last one, and join the remainder
> together. (If this is the way to go, please show me I can't see it).
> 
> I tried substitution, using this:
> $path =~ s/\/.*?$//;
> but it strips off everything after the first '/'.  I thought the '.*?' would
> give  me the minimal match, and the '$' would make the match start at the
> end of the string, but I'm wrong.
> 
> Checked the FAQ, newsgroup, manpages, several books.  All to no avail.  I
> know I'm missing something elementarily simple....
> 
> TIA,
> Fitz

I am sure this will have been answered already, but I generally use

	File::Basename

function as described on page 436 of the camel.

I tried to use a regexp, but there where too many variables to accommodate
and I am not that good at regexp/perl yet anyway.

-- 
--
Ian J. Garlick
ijg@csc.liv.ac.uk

You can't carve your way to success without cutting remarks.


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

Date: Wed, 08 Jul 1998 13:18:47 -0500
From: Dan Baker <dtbaker_@flash.net>
Subject: Re: Text::MetaText Features
Message-Id: <35A3B807.5361@flash.net>

Andy Wardley wrote:
> 
> #========================================================================
> #
> # Text::MetaText
------------

very cool, you may soon have many groupies using the module. It looks
handy for the webmaster who wants to learn just enough perl to build
dynamic or updatable HTML.

Dan




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

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

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