[8566] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2183 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 25 22:07:47 1998

Date: Wed, 25 Mar 98 19:00:31 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 25 Mar 1998     Volume: 8 Number: 2183

Today's topics:
    Re: - Limiting the length of a list on a page..... - (Martin Vorlaender)
    Re: eval, do FILE <Daryl.Tester@au.com.steadycom>
        Forced log out after a defined total time, how? moetteli@citeu.unige.ch
    Re: Forced log out after a defined total time, how? (Timothy Luoma)
    Re: Going Rates for PERL Programming??? (brian d foy)
    Re: Going Rates for PERL Programming??? <webmaster@fccjmail.fccj.cc.fl.us>
        hash vs hash ref (Tomas)
    Re: How do I check "errorlevel" in a perl script (Jeffrey Drumm)
        interfacing C++ to Perl5 with SWIG <j.kiser@ix.netcom.com>
    Re: Is there a "Newsgroup" for Newbies to Perl? just@letterror.com
    Re: need regexp help (Douglas Wilson)
        No output <edgar@pce.net>
    Re: Passing reference to array of hashes: a better way? (Ken Fox)
    Re: Passing reference to array of hashes: a better way? <zenin@archive.rhps.org>
    Re: Perl5 on Irix <rpsavage@ozemail.com.au>
        Programming Perl, 2nd ed for sale (Sheldon E. Smith)
    Re: PROPOSAL: The Perl Dictionary (brian d foy)
    Re: PROPOSAL: The Perl Dictionary <rpsavage@ozemail.com.au>
    Re: Ref to var in other sub? (Ken Fox)
        removing eval from a loop <jalukas@lucent.com>
    Re: removing eval from a loop <jstern@world.northgrum.com>
        Shortcut question (Andre L.)
        Use CPAN with Windows 95's DOS prompt? (Sheldon E. Smith)
    Re: Using perl code as a config file syntax? (Or, can r <zenin@archive.rhps.org>
        verifying email address -- how? <khemani@plexstar.com>
    Re: verifying email address -- how? (Mike King)
    Re: verifying email address -- how? <zenin@archive.rhps.org>
        || and 'or' - implications? (Ian Macdonald)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 25 Mar 1998 20:06:08 +0100
From: martin@RADIOGAGA.HARZ.DE (Martin Vorlaender)
Subject: Re: - Limiting the length of a list on a page..... -
Message-Id: <351955a0.524144494f47414741@radiogaga.harz.de>

James (James@cydaps.nospam.co.uk) wrote:
: On Mon, 23 Mar 1998, Martin Vorlaender wrote:
: >That's exactly what Randal Schwartz presents in his WebTechniques column
: >#2 at http://www.stonehenge.com/merlyn/col02.html
: Thanks for the URL, but when I tried it I got 404 file not found. I have
: managed to find col16.html and col22.html but no col02.html at the
: moment, any ideas??

Whoops... I left out the 'WebTechniques' part. The correct URL is
http://www.stonehenge.com/merlyn/WebTechniques/col02.html

Sorry,
  Martin
--
                          | Martin Vorlaender | VMS & WNT programmer
 Ceterum censeo           | work: mv@pdv-systeme.de
 Redmondem delendam esse. |       http://www.pdv-systeme.de/users/martinv/
                          | home: martin@radiogaga.harz.de


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

Date: Thu, 26 Mar 1998 10:36:31 +1030
From: Daryl Tester <Daryl.Tester@au.com.steadycom>
Subject: Re: eval, do FILE
Message-Id: <35199C07.7DC56EC7@au.com.steadycom>

Mike Heins wrote:

>>   "do 'stat.pl';   is just like   eval `cat stat.pl`; [...]"

> The blue camel amends that to say "rather like". Apparently it
> is ahead of perlfunc(1).

Ah, that Larry and his cunning use of the English language. :-)

>> I presume it's a namespace/scoping issue here (I've read what I think is
>> the relevent docs until my forehead bled), but what exactly is going on here?

>    print (defined $::template{'Oi'} ? "Line 6, I bet.\n" : "Line 7, I bet.\n");

Aha!  This has led me down a new and interesting path; I had always
thought that
'my $varname;' in the main package and 'use vars qw($varname);' were
equivalent.
This is clearly wrong, and although I've yet to grasp the exact
semantics, at
least I know where my train of thought became derailed (and it's nothing
that
reading of the docs won't fix).  My forehead and I thank you, Sir!

> --
> Mike Heins                          http://www.minivend.com/  ___ 

-- 
 Daryl Tester (Daryl dot Tester at steadcom dot com dot au)
 (Mail domain reversed - the things we do to avoid spam).


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

Date: 26 Mar 1998 00:04:34 GMT
From: moetteli@citeu.unige.ch
Subject: Forced log out after a defined total time, how?
Message-Id: <6fc62i$e74@uni2f.unige.ch>

Hi


Does anybody know of a script or program, that forces a user to log out, after he has been logged in for a certain _total_ time a day.
If there)s no such beast, how can I force to log out a user? By killing it)s tty or what else?


Thanks for any response
Phil



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

Date: 26 Mar 1998 01:39:22 GMT
From: nospam+yes_this_is_a_valid_address@luomat.peak.org (Timothy Luoma)
Subject: Re: Forced log out after a defined total time, how?
Message-Id: <6fcbka$mbg$21@ha2.rdc1.nj.home.com>

In <6fc62i$e74@uni2f.unige.ch> moetteli@citeu.unige.ch wrote:

> Does anybody know of a script or program, that forces a user to log out, 
> after he has been logged in for a certain _total_ time a day. If there)s no 
> such beast, how can I force to log out a user? By killing it)s tty or what 
> else?

There's 'idled' and 'clobberd' and some shells (tcsh) have variables which 
will allow you to do this (not sure if you can prevent lusers from 
changing/unsetting them).
 
I've never gotten any of them to compile under NeXTStep/OpenStep though.... 
let me know if you do

TjL


--
"A picture is worth a thousand words" but personally, 
I think the person who coined that phrase never saw the web.

                        -- Gary D. Foster
[do NOT remove the 'nospam' to reply!]
Early phase of the unofficial @Home FAQ: http://members.home.com/faqs



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

Date: Wed, 25 Mar 1998 18:51:57 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Going Rates for PERL Programming???
Message-Id: <comdog-ya02408000R2503981851570001@news.panix.com>
Keywords: from just another new york perl hacker

In article <6fbg77$k1v@julius.ling.ohio-state.edu>, kcohen@julius.ling.ohio-state.edu (Kevin B Cohen) posted:

>i'm somewhat surprised that custom scripting pays more than tweaking,
>if for no other reason than that i'd rather write my own stuff than
>futz about with someone else's code any day of the week....

my rates tend to depend on how much i want to do the project
- i don't like tweaking other's scripts, so i charge more
for that, but it's really just a trick to get the client to
go the cheap route by letting me re-do it completely.

i've been know to quote OUTRAGEOUS rates for some projects
that i really had no intention of doing.  some people just
don't get the hint that $9 trillion/hour is a nice way of
saying "no thanks". i bump up the rates that high for any
project which has the words "<some name> Script Archive" in
the description :)

but, a more interesting question:  some economists say that
they don't beleive that there is a shortage of high-tech
workers because there is not evidence of "upward wage
pressure".  not that i want to know what people are making,
but are the full time Perl people making what they want or
what they think is reasonable?

being in the "New Media" world, i happen to know a lot of
start-up types who aren't making as much as they want or
could because, well, they work for start-ups. a classically
trained musician likened it to the conditions before the
American Federation of Musicians was around - musicians tend
to love what they do and will put up with a certain amount
of hardship to do it (and managers and so on might take
advantage of that).  likewise, people trying to break into
the Perl world might be the same way - they'll do anything
to be able to do Perl a lot and employers or business might
take advantage of these (e.g. all these posts for a Perl
scripter in exchange for equity or ad revenues).  is part
of the absence of the "upward wage pressure" due to
Perl programmers selling themselves short?

just curious...

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers <URL:http://www.pm.org>


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

Date: Thu, 26 Mar 1998 02:54:38 GMT
From: Webmaster <webmaster@fccjmail.fccj.cc.fl.us>
Subject: Re: Going Rates for PERL Programming???
Message-Id: <3519C20E.7279783A@fccjmail.fccj.cc.fl.us>

brian d foy wrote:

> likewise, people trying to break into
> the Perl world might be the same way - they'll do anything
> to be able to do Perl a lot and employers or business might
> take advantage of these (e.g. all these posts for a Perl
> scripter in exchange for equity or ad revenues).  is part
> of the absence of the "upward wage pressure" due to
> Perl programmers selling themselves short?
>
> just curious...

Would you say part of the problem is the
impression that since the Perl enviroment
was 'free' the coders should be as well?

I get the impression that most posters
think that Usenet is a giant helpdesk
environment, at times...

Sneex



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

Date: Thu, 26 Mar 1998 02:00:11 GMT
From: boson@earthlink.net (Tomas)
Subject: hash vs hash ref
Message-Id: <3519b4a0.42349069@news.earthlink.net>

Could someone give me a simple reason why or when it is better to have
a reference to a hash than just using the hash itself. For instance
these both codes does the same.

%hash = (name =>"Jason");
print $hash{name};

$hashref = {name =>"Jason};
print $hashref->{name};

Thanks in advance.

Tom



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

Date: Thu, 26 Mar 1998 00:14:17 GMT
From: drummj@mail.mmc.org (Jeffrey Drumm)
Subject: Re: How do I check "errorlevel" in a perl script
Message-Id: <35199794.282645786@news.mmc.org>

On Wed, 25 Mar 1998 14:24:26 -0800, Chris Bender <cbender@creo.com> wrote:

>I want to check the errorlevel of an NT batch file from within a perl
>script.
>
>Currently, I am doing:
>
>$status = system("my_batch_file.bat");
>die if ( $status );
>
>This is a problem, because in order for $status to be non-zero, I have
>to put an "exit 1" command in my batch file. I don't want to have exit
>commands in my batch file, because when I run it from the command line,
>it will exit from the active shell.
>
>Is there any way of checking the "errorlevel" variabl;e from within
>perl?  $! doesn't work with NT.

You might pass a parameter to the batch file in the system() call that gets
tested when an errorlevel is set; if it matches, the batch file does an
EXIT 1.

in the batch file:

IF ERRORLEVEL = 1 GOTO PERLCHK
GOTO END
:PERLCHK
IF "%1" == "PerlCalled" EXIT 1
:END

In your Perl code:

$status = system("my_batch_file.bat","PerlCalled");
die if ( $status );

-- 
                           Jeffrey R. Drumm, Systems Integration Specialist
                                  Maine Medical Center Information Services
                                     420 Cumberland Ave, Portland, ME 04101
                                                        drummj@mail.mmc.org
"Broken? Hell no! Uniquely implemented." -me


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

Date: Wed, 25 Mar 1998 15:48:40 -0800
From: Jeffee Kiser <j.kiser@ix.netcom.com>
Subject: interfacing C++ to Perl5 with SWIG
Message-Id: <351997D8.3E4D@ix.netcom.com>

I am working on writing some extensions to Perl5 using C++ and
interfacing it to Perl with SWIG.  I have done this with regular C with
no problems, but when I try to use C++ with classes it fails to work.  I
am working on a UNIX workstation running Solaris 2.5.1.  I have tried
several simple examples and they all run into the same problems (I even
tried the really simple example that comes with the SWIG distribution
which is a simple shapes class with a Polygon subclass which inherits
from it).  When I run this simple csh script on the example:

#######################################################################
#!/bin/csh

swig -c++ -perl5 -shadow -module shapes shapes.i
CC -I/usr/local/perl5.004_04/lib/perl5/sun4-solaris/5.00404/CORE \
-c shapes_wrap.c
ld -G shapes_wrap.o -L/usr/local/lib -L/usr/local/perl5.004_04 \
-L/usr/lib -lm -lperl -lc -o shapes.so
#######################################################################

it runs OK and creates the shapes.so library as well as the wrappers and
the shapes.pm perl module.  However, when I try to invoke this module
into a perl script I get the following error at the command line:

#######################################################################
Can't load './shapes.so' for module shapes: ld.so.1:
/usr/local/bin/perl: fatal: relocation error: symbol not found:
__0OnwUi: referenced in ./shapes.so at
/usr/local/perl5.004_04/lib/perl5/sun4-solaris/5.00404/DynaLoader.pm
line 166.

 at shapes.pm line 7
BEGIN failed--compilation aborted at shapes.pl line 3.
#######################################################################

I already checked my LD_LIBRARY_PATH and PERL5LIB environment variables
and they are OK (like I said, this works OK as long when I use regular
C).  Does this problem stem all the way back to when I built perl? 
Should I try to build it with the UNIX C++ compiler instead of the plain
C compiler?  Any help or suggestions would greatly appreciated.

Jeffee Kiser
Design Engineer -- San Jose, CA


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

Date: Wed, 25 Mar 1998 19:42:23 -0600
From: just@letterror.com
Subject: Re: Is there a "Newsgroup" for Newbies to Perl?
Message-Id: <6fcbm7$g64$1@nnrp2.dejanews.com>

[ a little late, I stumbled into this one by accident, but it was
insulting enough to bite ]

> In comp.lang.perl.misc, Mark Stackhouse <stackhou@execpc.com> writes
> a terribly mutilated, miswrapped posting:
[but still has a very valid point]
> :If you, (or anyone else for that matter), knows of a better
> :language that non programmers can utilize to get some REAL
> :work done, I'm all ears!
>
In article <6f5fm2$lr4$1@csnews.cs.colorado.edu>,
  tchrist@mox.perl.com (Tom Christiansen) wrote:
> Nonprogammers should not use any programming language.   Period.
> Nonsurgeons should perform any surgical interventions.  Period.  This is
> a profession, you know.  If you aren't a programmer, hire one.
>
> "C/Java/C++/Perl for Non-programmers" is oxymoronic.

Come on Tom! You know this is utter nonsense. How many people
have to program on the side because they need to extract or
evaluate data or whatever? Gazillions of scientists, who's main
occupation is something else, spend quite some time coding,
whether they like it or not.
Many webmasters do a little Perl to get their stuff going,
still they would not call themselves programmers.
There are many, many situations where non-programmers can solve
their own problem better and faster than any "real" programmer
could, because it would take more time to explain the problem
to a professional than to code it up yourself. A friend of mine
once said: "programming is too important to leave to programmers".
Which is very true in many situations. Lastly; a professional
f*ck is not likely going to be the best you had in your life.
(ok, that was cheap)

Oh, to the original poster: you might want to have a look at
Python instead (http://www.python.org/), it's syntax is a lot
easier to understand for beginners than Perl's. <*duck*> ;-)
I am not a programmer, and I get lots of work done with Python.

Just van Rossum


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


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

Date: Wed, 25 Mar 1998 23:04:11 GMT
From: dgwilson@gte.net (Douglas Wilson)
Subject: Re: need regexp help
Message-Id: <6fc2di$i12$1@gte2.gte.net>

On 25 Mar 1998 16:18:49 -0500, bens@chippewa.cis.ohio-state.edu
(benjamin j snyder) wrote:

>
>I am having trouble with a few things, mainly regexps.
>
>I have the following line:
>@id_info = split (/./,$value);
>
>I *KNOW* $value has something in it, but @id_info has *NOTHING*.  Shouldn't

The problem is that you're splitting on a regexp.
Using /./ means that every character is a delimiter and
so there's nothing to save between the delimiters.

Use "." not /./ if you want to split on dot characters and ""
if you want to split on every character.

see:
perldoc perlfuncs

Hope that helps,
Douglas Wilson



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

Date: Wed, 25 Mar 1998 18:05:19 -0500
From: "James R. Edgar" <edgar@pce.net>
Subject: No output
Message-Id: <35198DAF.D212EC3@pce.net>

I am having a problem with my passwd script.
	
	When I try to submit info from the browser to the user.dat file 
I get Could Not Append To User File .
	I have tried different chmods. Nothing has changed.

	Can someone tell me why this is happening.

James R. Edgar


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

Date: 26 Mar 1998 02:08:03 GMT
From: kfox@pt0204.pto.ford.com (Ken Fox)
Subject: Re: Passing reference to array of hashes: a better way?
Message-Id: <6fcda3$23d3@eccws1.dearborn.ford.com>

Jonathan Feinberg <jdf@pobox.com> writes:
> spamfree@yahoo.com writes:
> 
> >             push @pmdata, %thisrecord;
> 
> You meant to push a reference to the hash, not the elements of the
> hash:
> 
>       push @pmdata, \%thisrecord;

That might work if %thisrecord is a lexical and a new lexical is
created for each record.  Otherwise @pmdata will just get a whole
bunch of references to the same hash.  Probably better to use a
reference from the start:

my $thisrecord = { };

while (!$done) {
	# build %{$thisrecord} with $thisrecord->{KEY} = VALUE

	push @pmdata, $thisrecord;
	$thisrecord = { };
}

The Perl Data Structures Cookbook mentions this in the "COMMON
MISTAKES" section.  Readers have to generalize from arrays to hashes
though. ;)

- Ken

-- 
Ken Fox (kfox@ford.com)                  | My opinions or statements do
                                         | not represent those of, nor are
Ford Motor Company, Powertrain           | endorsed by, Ford Motor Company.
Analytical Powertrain Methods Department |
Software Development Section             | "Is this some sort of trick
                                         |  question or what?" -- Calvin


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

Date: 26 Mar 1998 02:47:23 GMT
From: Zenin <zenin@archive.rhps.org>
Subject: Re: Passing reference to array of hashes: a better way?
Message-Id: <890880812.652042@thrush.omix.com>

Ken Fox <kfox@pt0204.pto.ford.com> wrote:
: That might work if %thisrecord is a lexical and a new lexical is
: created for each record.  Otherwise @pmdata will just get a whole
: bunch of references to the same hash.  Probably better to use a
: reference from the start:

	Or just create one on the fly and not worry about what kind
	of data you have or it's scope:

	push @pmdata, { %thisrecord };

-- 
-Zenin
 zenin@archive.rhps.org


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

Date: Thu, 26 Mar 1998 09:35:20 +1000
From: Ron Savage <rpsavage@ozemail.com.au>
Subject: Re: Perl5 on Irix
Message-Id: <351994B8.6B02@ozemail.com.au>

David Andre wrote:
> 
> I've tried looking at FAQ's and through the www.perl.com
> pages but I've found nothing referencing this. I'm trying to
> build a 64bit version of perl on an SGI machine running Irix
> 6.4. There is no irix_6_4.sh file in the hints directory. I
> was wondering if anyone had any luck building this.[snip]

You didn't actually say you'd built the non-64 bit version successfully...

I've built it for IRIX 5.3, for what little that's worth.

-- 
Cheers,
Ron Savage
Office: savage.ron.rs@bhp.com.au
Home (preferred): rpsavage@ozemail.com.au
Web: http://www.ozemail.com.au/~rpsavage


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

Date: Thu, 26 Mar 1998 01:37:28 GMT
From: ssmith@galina.enet.dec.com (Sheldon E. Smith)
Subject: Programming Perl, 2nd ed for sale
Message-Id: <6fc8bm$qsi$1@mrnews.mro.dec.com>

If anybody is interested, I accidentally wound up with a second copy. 
Lightly thumbed through.

$20 plus shipping; first come, first served....

-- Shel Smith


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

Date: Wed, 25 Mar 1998 18:07:06 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: PROPOSAL: The Perl Dictionary
Message-Id: <comdog-ya02408000R2503981807060001@news.panix.com>
Keywords: from just another new york perl hacker

In article <eli$9803251350@qz.little-neck.ny.us>, Eli the Bearded <*@qz.to> posted:


>imperlmeable - impervious to attempts to understand (see JAPH)

shouldn't that be "imperlvious"?

chairperlson - the Perl Project Head.

experliment - just trying some code to see what happens.

imperlial - high rank in the Perl Community.  See Larry.

inoperlable - a perl script that won't compile.

operla - an opera completely done in Perl, see also Perl Poetry.

salesperlson - a person who sells Perl wares.

superlintendent - the person who belongs to the email address one enters
   in Configure.

vesperl - nightly chants to the Perl Gurus.

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers <URL:http://www.pm.org>


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

Date: Thu, 26 Mar 1998 09:35:25 +1000
From: Ron Savage <rpsavage@ozemail.com.au>
Subject: Re: PROPOSAL: The Perl Dictionary
Message-Id: <351994BD.4D32@ozemail.com.au>

Ed Finch wrote:
> 
> Perl is going to take over the world. Therefore, the word perl and its[snip]

Perl n. The (Allegedly) Perfect Language - get it?. Obscurantistic lies pretend it stands for Pathologically 
Eclectic Rubbish Lister, etc.

-- 
Cheers,
Ron Savage
Office: savage.ron.rs@bhp.com.au
Home (preferred): rpsavage@ozemail.com.au
Web: http://www.ozemail.com.au/~rpsavage


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

Date: 26 Mar 1998 01:53:33 GMT
From: kfox@pt0204.pto.ford.com (Ken Fox)
Subject: Re: Ref to var in other sub?
Message-Id: <6fccet$23d2@eccws1.dearborn.ford.com>

Zenin <zenin@archive.rhps.org> writes:
> David DelGreco <david_delgreco@intuit.com> wrote:
> : I'll just 'use strict', lexically scope everything and all will
> : be well.  However, in keeping with the principal of laziness, I
> : was hoping to make use of some formerly global hashes of hashes
> : (now scoped in main())
>
> 	Use a package global.

I'd use a lexical variable with file scope.  The declaration must
appear before any code that uses it because code before the
declaration (or outside the file) can't see the variable.  Lexicals
don't go in the symbol table.  A nice side-effect to this approach is
that loading the file multiple times will create multiple instances of
the lexical.  You'll have to put your code into unique packages of
course because subroutines aren't lexicals.  (Or use anonymous
subroutines assigned to lexicals... :)

Here's a small example:

-- foo.pl --------------------------------------------------

#!/usr/bin/perl -w

use strict;

load_module('foo1', 'bar.pl');
load_module('foo2', 'bar.pl');

foo1::bar('gold', 79);
foo2::bar('gold', 'Au');

print "in foo1 gold = ", foo1::bar('gold'), "\n";
print "in foo2 gold = ", foo2::bar('gold'), "\n";

sub load_module {
    my($package_name, $file_name) = @_;
    eval "package $package_name; do '$file_name'";
}

-- bar.pl --------------------------------------------------

my %hash = ();

sub bar {
    my($key, $value) = @_;

    if (defined $value) {
	$hash{$key} = $value;
    }
    else {
	$value = $hash{$key};
    }

    $value;
}

- Ken

P.S. Using the Perl object system might be a better solution to
     David's problem than using global variables at all.

-- 
Ken Fox (kfox@ford.com)                  | My opinions or statements do
                                         | not represent those of, nor are
Ford Motor Company, Powertrain           | endorsed by, Ford Motor Company.
Analytical Powertrain Methods Department |
Software Development Section             | "Is this some sort of trick
                                         |  question or what?" -- Calvin


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

Date: Wed, 25 Mar 1998 16:51:55 -0600
From: John Lukas <jalukas@lucent.com>
Subject: removing eval from a loop
Message-Id: <35198A8B.6B99@lucent.com>

I am at my wit end.  :^)

I have an application that is required to read
and process different text files at different
times, with potentially different fields, and/or
different field names or order. When the program
starts, I have the field names that apply to the
current file in a string, like $ARatts below. I can
get the program to process the data correctly (see the
very simplified version below) by using eval's on strings.
The Camel book says that this is a no-no, due to need to
parse the 2 eval's for each record, and I believe it! I
am unwilling to make the entire loop an eval (for a
variety of reasons), but I have not been able to figure
out how to use eval in a BLOCK context, as the Camel
book recommends. I appreciate any help.

#!/home/lukas/QSE/bin/perl -w

$delim = '\|';
$, = "|";
$ARatts = '$carodnr, $field, $order, $actdate, $value';

while (<>) {
	chop;
	eval "($ARatts) = split (/${delim}/, q\b$_\b, -1);";
	print "carodnr = <$carodnr>\n";
	eval "print $ARatts . q/\n/;";
}

-- 

	John Lukas
	630-224-6290
	jalukas@lucent.com


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

Date: Wed, 25 Mar 1998 23:57:49 GMT
From: Jim Stern <jstern@world.northgrum.com>
Subject: Re: removing eval from a loop
Message-Id: <351999FD.7DD2B02D@world.northgrum.com>

John Lukas wrote:
> 
> I am at my wit end.  :^)
> 
> [...]
> #!/home/lukas/QSE/bin/perl -w
> 
> $delim = '\|';
> $, = "|";
> $ARatts = '$carodnr, $field, $order, $actdate, $value';
[This list of fields can vary at run time.  An eval works but it's too
slow.  Would BLOCK eval help?]

> 
> while (<>) {
>         chop;
>         eval "($ARatts) = split (/${delim}/, q\b$_\b, -1);";
>         print "carodnr = <$carodnr>\n";
>         eval "print $ARatts . q/\n/;";
> }

The bad news:  BLOCK eval is not flexible enough for your needs.  It
requires that "the code to be executed doesn't vary."  (See perlfunc.)

The good news:  You don't need eval.  You don't need variables.  Hashes
are the ticket:

<snip>
#!/usr/local/bin/perl -w
# Simplified version of your code
use strict;
my @ARatts = qw(carodnr field order actdate value);
my $delim = ',';
while (<>) {
        chomp;          # Usually safer than 'chop'
        my %hash;
        @hash{@ARatts} = split /${delim}/, $_;
        print "@hash{@ARatts}\n";
}
</snip>

-- 
Jim Stern -- Views here are my own, not my employer's.   (Hawthorne, CA)


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

Date: Wed, 25 Mar 1998 21:21:20 -0500
From: alecler@cam.org (Andre L.)
Subject: Shortcut question
Message-Id: <alecler-2503982121200001@dialup-530.hip.cam.org>

In the two following examples, I'm searching through an array for a match
between two variables. If a match is found, I want to get out of the loop
immediately, so that the $found flag retains the value true (I need it for
later).

I find that these two variations behave identically. Still, I'm wondering
whether example #1 is legit syntax or if it is wrong. What do you think?


# Example 1 -- unorthodox?
foreach $new_val (@entries) {
   $found = ($new_val eq $search_val) and last;
}


# Example 2 -- more classic
foreach $new_val (@entries) {
   $found = ($new_val eq $search_val);
   if ($found) { last; }
}

Thanks,
A.L.


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

Date: Thu, 26 Mar 1998 02:32:42 GMT
From: ssmith@galina.enet.dec.com (Sheldon E. Smith)
Subject: Use CPAN with Windows 95's DOS prompt?
Message-Id: <6fcbk8$vn$1@mrnews.mro.dec.com>

Hi. I'm trying to figure out how to configure and use CPAN on a 
MickeySquish Windows 95 system. I'm running the DJGPP port of Perl 5:

        This is perl, version 5.004_02

        Copyright 1987-1997, Larry Wall

        MS-DOS port Copyright (c) 1989, 1990, Diomidis Spinellis
        djgpp v2 port (jpl5003c) by Hirofumi Watanabe, 1996
        djgpp v2 port (perl5004) by Laszlo Molnar, 1997

Plus, I'm still rather new with Perl: I have the CPAN-1.36.readme, and 
I've read it, but don't really understand it. 
Question: Are all the modules external .pm files, or is Perl actually 
re-compiled and re-linked?

When I try 
        perl -MCPAN -e shell
it suggests I try
        install Bundle::CPAN

As that blows up, I see a message going by that suggests getting 
Bundle::libnet. Well, now I *have* libnet-1.0605.tar. 
Question: Into what directory do I untar it?

I'm hoping a few friendly answers will help. When/If I can get it running, 
I'll try to post a few notes for the FAQ.

Thanks in advance....

------------------------------------------------------------------------------
	Sheldon E. Smith
	Enterprise Management Services
	OpenVMS & Digital Unix Management & Performance

Digital Equipment Corporation		(612) 837-4826 Telephonw
7831 Glenroy Rd, # 250			(612) 837-4801 Fax
Bloomington, MN 55439-3132		Sheldon.Smith@Digital.com
------ PGP keyid 1024/48710315 1996/05/07 <ssmith@galina.enet.dec.com> -------
   PGP Key fingerprint =  B9 A6 6F 00 24 C0 5E B8  DB 8A 9A DE D3 DA 2B B4


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

Date: 26 Mar 1998 02:41:15 GMT
From: Zenin <zenin@archive.rhps.org>
Subject: Re: Using perl code as a config file syntax? (Or, can require return more then one value?)
Message-Id: <890880444.354089@thrush.omix.com>

Justin Vallon <vallon@pearl.fi.bear.com> wrote:
: What about defining a configuration interface, rather than worrying 
: about what the global is named?

	Can we get away from globals completely?  It's been pretty much
	proven that they are not needed nor useful in any way when reading
	Perl coded config files.

: Then, use the config package in the
: caller (main program) and the config file.

	I still don't see the advantage to a package of any kind...but let's
	dig through this anyway because I'd like to make some points about
	Perl code style.

: Caller:
:     package Config;
:     sub EnableVerbose { $Config::Opts{'verbose'} = 1; }

	Style issue:
	You're in package Config, so why are you fully qualifying
	%Opt?  sub EnableVerbose { $Opts{verbose} = 1 } is fine. -Just
	remember to use vars qw(%Opts) at the top so when you drop in
	use strict it will all be happy.

:     sub AddIncludeDir { push @Config::Dirs, @_; }
:     sub GetIncludeDirs { return @Config::Dirs; }
:     sub GetVerbose { return $Config::Opts{'verbose'}; }

	Just my own style here, but I for one can't stand this type
	of OOO (Overly Object Oriented, I think I picked that up from
	Tom C :-) code style.

	In this case, you're not even using an object, so it's (get()/set())
	even sillier, IMHO.  If you're just setting basic fields, get()/set()
	is overkill at best and can lead to almost madding code.  There is
	are a few applications where I work that are written in Java.  They
	connect to a database and use tables with well over 500 fields. 
	Most of them store the data in objects with the 500 fields as fields
	in object, which makes sense.  A couple of them however, manually
	set each one of these 500 fields with there own set/get methods...

	Any idea how many lines of code need to be writen to just set 500
	fields, let alone the overhead when you do it for 3000 records...

	No, this isn't the case here, but there still is absolutely no valid
	reason to use a get/set system for such instances.  I'm not saying
	there aren't times that get/set isn't the better way, just that it's
	used far to much since "schools" started teaching "Object Oriented
	Programming Theory"...  Why don't we make this config reader module
	multithreaded while where at it and maybe even give it the ability
	to read config files using URLs...  This isn't Java, stop coding in
	Java.

:     sub Read { local ($file) = @_; Reset; require $file; }

	...I don't get it.  How does @Dirs affect the search by
	require()...?  It doesn't...and what, exactly, is verbose actually
	going to go?

: Config file:
:     Config::AddIncludeDir "/usr/include";

	What's wrong with use lib "/usr/include"?

:     Config::EnableVerbose;
:     1;

	You still return 1?  How do you get your config data...?  You're not
	back on that global idea again are you...?

: Then:
:     Config::Read 'config.file';
:     local @dirs = Config::GetIncludeDirs;
:     local $verbose = Config::GetVerbose;

	...Huh?  How exactly, does Config::Read() import your config
	data...?

: That allows you to define the interface,

	I have yet to see how it does this.

: then you can define whatever you want for management of multiple config files,

	Again, I have yet to see how this can be done.  You already have
	support for multible config files and config files that use other
	config files by using require.

	## This is my config file, isn't it neat?
	{
	    FOO => require 'foo.conf',  ## We'll import a stuct from foo.conf
	    BAR => {
	        ## But we'll set BAR here "manually"
	        SomeOption => 'value',
	        Etc        => 'stuff',
	    },
	};

: or even have a config file writer:
:     sub Write { print "Config::EnableVerbose" if Config::GetVerbose;
:                 print "Config::AddIncludeDir " . join ",", @Config::Dirs; };

	And this could easily handle multi-level data stucts how, exactly? 
	If you need such a beast, Data::Dumper can do it in pure perl.

: It would also make the config file much more readable.  Consider the
: above file vs:
: push @Config::Dirs, "/usr/include";
: $Config::Opts{'verbose'} = 1;
: 1;

	Ack...more readable?  Consider that config file vs:

	## My config, isn't it cool?
	{
	    verbose    => 1,
	    whatever   => 'my dog spot',
	};

	Multi-level config files are just as easy:

	## I want to connect to multible databases at once using the DBI
	## interface, and give each one it's own name in a hash of handles.
	## By using this config, I can easily map the names to the correct
	## connect arguments needed for each database login:
	{
	    DataBaseFoo   => [ 'fooSID', 'foo', 'pass', 'Oracle' ],
	    DataBaseBar   => [ 'fooSID', 'bar', 'pass', 'Oracle' ],
	    DataBaseDog   => [ 'dog',    'dog', 'pass', 'Informix' ],
	};


	And in my code, simply do:

	my $dbConfig = require 'db.conf';

	foreach my $db (keys %{ $dbConfig }) {
	    $DBHandles{$db} = DBI->connect (@{ $dbConfig{$db} })
	        or confess qq(Can not connect to '$db': $DBI::errstr);
	}

	As far as I'm concerned, pretty much any argument to use a module
	of any kind to read config files that are writen in perl code is
	now mute.  No one has brought forward a single good argument for
	doing such a design.  None of the ideas are easier, safer, faster,
	or cleaner then a simple require "config.file".  I'm sorry I ever
	started this thread and I'm dumping it in my kill file right after
	I send this message...

	Ask a simple question about building a better round wheel
	and get 10 people asking to build square wheels for you...

-- 
-Zenin
 zenin@archive.rhps.org


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

Date: Wed, 25 Mar 1998 18:28:28 -0500
From: Yash Khemani <khemani@plexstar.com>
Subject: verifying email address -- how?
Message-Id: <3519931C.C42287@plexstar.com>

hi folks,

could you provide a suggestion about how to verify the validity of
an email address?

there are two levels of validity one could check:

 - could the address provided be valid?  by this, i mean - is this a
   syntactically valid address?

 - is the address provided actually valid?  this means connecting to
   the mail server on port 25 and using the VRFY command.  the problem
   here, however, is that this is not always possible.  you have to
   end up looking at mx records and it all gets very ugly.

anyone out there have a suggested solution?

thanks,
yash


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

Date: Thu, 26 Mar 1998 02:08:25 GMT
From: m.king.garbage@praxa.garbage.com.au (Mike King)
Subject: Re: verifying email address -- how?
Message-Id: <3519b85a.246458869@news.ozemail.com.au>

You could verify that the domain exists using WHOIS


On Wed, 25 Mar 1998 18:28:28 -0500, Yash Khemani
<khemani@plexstar.com> wrote:

>hi folks,
>
>could you provide a suggestion about how to verify the validity of
>an email address?
>
>there are two levels of validity one could check:
>
> - could the address provided be valid?  by this, i mean - is this a
>   syntactically valid address?
>
> - is the address provided actually valid?  this means connecting to
>   the mail server on port 25 and using the VRFY command.  the problem
>   here, however, is that this is not always possible.  you have to
>   end up looking at mx records and it all gets very ugly.
>
>anyone out there have a suggested solution?
>
>thanks,
>yash



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

Date: 26 Mar 1998 02:54:09 GMT
From: Zenin <zenin@archive.rhps.org>
Subject: Re: verifying email address -- how?
Message-Id: <890881218.569726@thrush.omix.com>

Yash Khemani <khemani@plexstar.com> wrote:
: could you provide a suggestion about how to verify the validity of
: an email address?

	This is an FAQ.  What it basically comes down to is that if you
	really want to be sure of it's validity, you'll have to send them
	an email and wait for a response.

:  - could the address provided be valid?  by this, i mean - is this a
:    syntactically valid address?

	Check the FAQ.  You can get close, but not exact.  Even if you
	build a spec Internet email parser (I forget the RFC for them)
	you still can't be sure. -Sendmail will accept a lot of addresses
	that will be "valid" but not parse by strict RFC.

:  - is the address provided actually valid?  this means connecting to
:    the mail server on port 25 and using the VRFY command.  the problem
:    here, however, is that this is not always possible.  you have to
:    end up looking at mx records and it all gets very ugly.

	Not to mention UUCP, POP spliting domains, et al that make this
	method vary unreliable.

: anyone out there have a suggested solution?

	See the FAQ.

-- 
-Zenin
 zenin@archive.rhps.org


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

Date: 25 Mar 1998 21:16:22 GMT
From: ian@caliban.org (Ian Macdonald)
Subject: || and 'or' - implications?
Message-Id: <slrn6hit16.okf.ian@caliban.xs4all.nl>

I can't find this in the FAQ, so here goes:

On page 191 of 'Programming Perl', in the section describing the use
of the 'open' function, the following recommendation appears:

"(And you must also be careful to use 'or die' after the statement
rather than '|| die', because the the precedence of || is higher than
list operators like open)"

Now, I'm just starting out in Perl and recently finished reading
'Learning Perl', which on page 110 shows this use of the || operator
without any warnings. In fact, throughout the rest of the book, it's
this notation that is used and not 'or'.

Going back to 'Programming Perl', on page 94 it says:

As more readable alternatives to &&, ||, and !, Perl provides the
'and', 'or' and 'not' operators. The behaviour of these operators is
identical - in particular, they short-circuit the same way."

Frankly, I'm confused.

Can someone explain to me in lucid terms what the implications are of
using the symbolic and literal forms? If I develop good practice now,
I won't have to unlearn bad habits later.

Thanks,

Ian
-- 
Ian Macdonald                         |       Don't give in to spammers.
http://www.caliban.org/               |      Use your real e-mail address
PGP key available from public servers |               on Usenet.
Linux 2.0.33 on an i686               |


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

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

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