[11702] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5302 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 5 17:06:27 1999

Date: Mon, 5 Apr 99 14:00:20 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 5 Apr 1999     Volume: 8 Number: 5302

Today's topics:
    Re: (newbie) matching value from array??? (Tad McClellan)
    Re: [Q] Help Needed on map <jglascoe@giss.nasa.gov>
    Re: Accessing MS Access with perl <greg2@surfaid.org>
    Re: backgroup job with "at" command <ddelikat@protix.com>
    Re: Can some one debug this perl - I need help <jglascoe@giss.nasa.gov>
    Re: Can some one debug this perl - I need help <alex@saers.com>
        Communicating with a C shell script menardm@my-dejanews.com
    Re: constructing a list of hashes <jglascoe@giss.nasa.gov>
    Re: constructing a list of hashes (Sean McAfee)
    Re: constructing a list of hashes (Larry Rosler)
        For web site design, and hosting, come to World Phase gabe@worldphase.com
    Re: here docs vs qq quote operator. Just personal prefe <ddelikat@protix.com>
    Re: here docs vs qq quote operator. Just personal prefe (Sam Holden)
        How to compile (perlcc) *.pm, then "use" it? mtaylor@cybernet.com
    Re: Lisp influences on Perl, Perl as an AI language (Randal L. Schwartz)
    Re: Lisp influences on Perl, Perl as an AI language <ddelikat@protix.com>
        mag tape IOCTL <jengland@enetis.net>
    Re: minimal pattern matching <cassell@mail.cor.epa.gov>
        Perlshop Problem <erik@rockymountainwebtech.com>
    Re: Pick one of two files <cassell@mail.cor.epa.gov>
    Re: Pick one of two files (Tad McClellan)
    Re: PROGRESS Data Base and Perl ? <ddelikat@protix.com>
        Return value undef, but with || undef'ed value, result  (Justin Masters - remove y to reply)
    Re: splice incompatible with foreach (Larry Rosler)
    Re: splice incompatible with foreach <paul.cameron@sun.com>
    Re: splice incompatible with foreach <paul.cameron@sun.com>
        This proverbial "perldoc". <grichard@uci.edu>
    Re: This proverbial "perldoc". <uri@home.sysarch.com>
    Re: This proverbial "perldoc". <grichard@uci.edu>
        Time Functions in Perl ! rujain@my-dejanews.com
    Re: Time Functions in Perl ! (Sam Holden)
    Re: Web -> Database Access... <greg2@surfaid.org>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Mon, 5 Apr 1999 10:41:45 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: (newbie) matching value from array???
Message-Id: <93iae7.ngv.ln@magna.metronet.com>

Jerry (preeper@cts.com) wrote:

: Now right after I start the loop to fetch each row of game scores and
: assign all the data items in the row to a variable name, I have added:

:       for $i (0 .. $team_count) {
:       if ($link_city{$i} == $away) {
                           ^^
                           ^^

   == tests for *numeric* equality.

   You want eq to test for string equality, I think.


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Mon, 05 Apr 1999 14:56:28 -0400
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: Effie Rover <null@effierover.com>
Subject: Re: [Q] Help Needed on map
Message-Id: <3709075C.7A615158@giss.nasa.gov>

Effie Rover wrote:
> 
> Can anyone point out some good examples of useful code using map WITH
> explanations? Either on web tutorials or posted here ... that's how I
> learn best. Thanks!

my @numbers = (1..10); 
print "numbers: @numbers\n";

my @squares = map { $_ * $_ } @numbers;
print "squares: @squares\n";

my @roots = map { sqrt } @numbers;
print "roots: @roots\n";

my @celsius = map { $_ * 10 } (-10 .. 10);
my @fahrens = map { 1.8 * $_ + 32 } @celsius;

print "Celsius | Fahrenheit\n";
print "--------------------\n";
printf "%7.2f | %7.2f\n", shift @celsius, shift @fahrens while @celsius;


	Jay Glascoe


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

Date: Mon, 05 Apr 1999 21:42:43 +0100
From: Greg Griffiths <greg2@surfaid.org>
To: Patrick <pgh@ga.nl>
Subject: Re: Accessing MS Access with perl
Message-Id: <37092043.F489477E@surfaid.org>

I suggest that you take a look at DBI as you are running on a Linux
server, although if you can get a windows server running take a look at
ODBC.pm from http://www.roth.net/odbc/ although I'm quite sceptical
about getting an MS Access db to run under a unix like environment.
either convert your DB or your server is probably the best bet, although
give it a try first, as I know that Access & Unix don't mix, although I
assume that includes Linux ?!

Patrick wrote:
> 
> Hi,
> 
> Can someone tell me how to read a ms-access database with perl on a
> Linux (redhat 5.1) server.
> 
> Thank,
> Patrick G.


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

Date: Mon, 05 Apr 1999 15:40:20 -0500
From: David Delikat <ddelikat@protix.com>
Subject: Re: backgroup job with "at" command
Message-Id: <37091FB4.3F54@protix.com>

userjeff@my-dejanews.com wrote:
> 
> I use the command "at" in FreeBSD and have the following problem that I
> do not have in UNIX(Digital 4.0U). I have one a script written in perl5,
> say, test.pl  It works fine when I type "test.pl" in FreeBSD.But it does not
> work when I type
> at -f test.pl now + 1 minute
> (In UNIX(Digital), it is fine with the command: at now + 1 minute test.pl  )
> I think the main problem is in FreeBSD the default env. for at is /bin/sh
> But I do not know how to solve this problem.
>  Summary: How to execute a perl script using the command "at" in FreeBSD?
> 
> Jeff
> 
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own


well, this really isn't a perl question...

what you need to do is look at man 'at' to determine
what the environment looks like when it runs the program.
there are lots of things that can be out of place.  including
what shell is used to run them.

-dav

-- 
<((((><
Consultant: Internet, Database, Business Systems
Unix/Linux, Windows95/NT
mailto:david-delikat@usa.net / http://obj.webjump.com/


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

Date: Mon, 05 Apr 1999 15:12:31 -0400
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: Mike Tickle <michael.tickle@stud.umist.ac.uk>
Subject: Re: Can some one debug this perl - I need help
Message-Id: <37090B1F.C40ED597@giss.nasa.gov>

Mike Tickle wrote:
> 
<snip>

your code won't even compile: you have no curly
braces, "{}", attached to the foreach loop.


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

Date: Mon, 5 Apr 1999 22:24:43 +0200
From: "ACE Alex" <alex@saers.com>
Subject: Re: Can some one debug this perl - I need help
Message-Id: <WY8O2.3582$x43.5721@nntpserver.swip.net>

Uhh, what? Can you compile perl scripts to binarys?
/alex
alex@saers.com

Jay Glascoe wrote in message <37090B1F.C40ED597@giss.nasa.gov>...
>Mike Tickle wrote:
>>
><snip>
>
>your code won't even compile: you have no curly
>braces, "{}", attached to the foreach loop.




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

Date: Mon, 05 Apr 1999 20:30:24 GMT
From: menardm@my-dejanews.com
Subject: Communicating with a C shell script
Message-Id: <7eb6h0$bph$1@nnrp1.dejanews.com>

I have a perl cgi script that I'm using to kick off a C shell script
(ultimately I could rewrite the Csh script code and add its functionality to
the perl script, but thats not a time option right now).  The Csh script
previously ran from the command line.  It is interactive, and asks the user
various questions and according to the answer does different things (no
kidding).  I'm having trouble getting the perl script and the Csh script to
communicate properly.  I can get the Csh script output to appear, but when
the Csh script asks a question (using $< ) I can't that communication path
working correctly.  I've tried using the open command with a pipe
(open(filehandle , "command |")) and I've also tried the open2 subroutine
(open2(readfilehndl, writefilehndl, "command")) with no success.  Any
Ideas....

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Mon, 05 Apr 1999 16:10:09 -0400
From: Jay Glascoe <jglascoe@giss.nasa.gov>
Subject: Re: constructing a list of hashes
Message-Id: <370918A1.3C6378AB@giss.nasa.gov>

Sean McAfee wrote:
> 
> Jay Glascoe  <jglascoe@giss.nasa.gov> wrote:
> >foreach my $rec (@record) {
> >    $_ = 0 foreach values %$rec;
> >}
> 
> ITYM:
> 
> foreach my $rec (@record) {
>         $rec->{$_} = 0 foreach keys %$rec;
> }

no, "$_" is bound to each value from from the hash.
Try this:

@hash{'A' .. 'H'} = (1..8);

print "$_ => $hash{$_}\n" foreach sort keys %hash;
print "\n";

$_ = 0 foreach values %hash;
print "$_ => $hash{$_}\n" foreach sort keys %hash;

	Jay Glascoe


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

Date: Mon, 05 Apr 1999 20:32:41 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: constructing a list of hashes
Message-Id: <J59O2.1304$9Y5.6803256@news.itd.umich.edu>

In article <370918A1.3C6378AB@giss.nasa.gov>,
Jay Glascoe  <jglascoe@giss.nasa.gov> wrote:
>Sean McAfee wrote:
>> Jay Glascoe  <jglascoe@giss.nasa.gov> wrote:
>> >foreach my $rec (@record) {
>> >    $_ = 0 foreach values %$rec;
>> >}

>> ITYM:
>> foreach my $rec (@record) {
>>         $rec->{$_} = 0 foreach keys %$rec;
>> }

>no, "$_" is bound to each value from from the hash.
>Try this:

>@hash{'A' .. 'H'} = (1..8);
>print "$_ => $hash{$_}\n" foreach sort keys %hash;
>print "\n";

OK, I get:

A => 1
B => 2
C => 3
D => 4
E => 5
F => 6
G => 7
H => 8

>$_ = 0 foreach values %hash;
>print "$_ => $hash{$_}\n" foreach sort keys %hash;

Now I get:

A => 1
B => 2
C => 3
D => 4
E => 5
F => 6
G => 7
H => 8

What version of Perl are you using?  It's 5.005_02 for me.

-- 
Sean McAfee                                                mcafee@umich.edu
print eval eval eval eval eval eval eval eval eval eval eval eval eval eval
q!q@q#q$q%q^q&q*q-q=q+q|q~q:q? Just Another Perl Hacker ?:~|+=-*&^%$#@!


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

Date: Mon, 5 Apr 1999 13:50:03 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: constructing a list of hashes
Message-Id: <MPG.1172c1d91799ddcc989833@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <370918A1.3C6378AB@giss.nasa.gov> on Mon, 05 Apr 1999 
16:10:09 -0400, Jay Glascoe <jglascoe@giss.nasa.gov> says...
> Sean McAfee wrote:
> > 
> > Jay Glascoe  <jglascoe@giss.nasa.gov> wrote:
> > >foreach my $rec (@record) {
> > >    $_ = 0 foreach values %$rec;
> > >}
> > 
> > ITYM:
> > 
> > foreach my $rec (@record) {
> >         $rec->{$_} = 0 foreach keys %$rec;
> > }
> 
> no, "$_" is bound to each value from from the hash.
> Try this:
> 
> @hash{'A' .. 'H'} = (1..8);
> 
> print "$_ => $hash{$_}\n" foreach sort keys %hash;
> print "\n";
> 
> $_ = 0 foreach values %hash;
> print "$_ => $hash{$_}\n" foreach sort keys %hash;

I am sure you tried this program before you posted it.  But you must be 
using a different version of perl from anyone else.  It doesn't change 
any hash values when I try it.

Someone else thought the same thing *yesterday*, and tried to change the 
keys of a hash by aliasing.  It didn't work any better than it does for 
the values of a hash.  I'll just quote my previous answer verbatim; 
s/keys/values/g in the last paragraph;


Does it really work for you?  It doesn't for me, and I wouldn't expect 
it to.  Here is the documentation from perlsyn:

"If any element of LIST is an lvalue, you can modify it by modifying VAR
inside the loop. That's because the foreach loop index variable is an 
implicit alias for each item in the list that you're looping over." 

The members of the list of keys are rvalues (expressions whose values 
are the keys), not lvalues (references to the keys).


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


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

Date: Mon, 05 Apr 1999 19:17:32 GMT
From: gabe@worldphase.com
Subject: For web site design, and hosting, come to World Phase
Message-Id: <7eb284$7n6$1@nnrp1.dejanews.com>

Come to World Phase for all your Internet needs.



We are your complete Internet design company.
               We work with you, to create your custom internet
               presence.

               Our Business Services Include
               (select from the links below)
               - web site design
               - graphic design
               - web site marketing
               - e-commerce
               - web hosting
               - site redesign
               - starter packages
               - online menu design for restaurants
               - Our Rates

               If you have a need for web site development,
               including animations, flash multimedia,
               animated gifs, image maps, javascript, perl
               implementation, database integration, and
               graphic design, Worldphase has the expertise to
               satisfy you.
visit us at http://www.worldphase.com

Thanks,
Gabriel John Cohen

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Mon, 05 Apr 1999 14:31:30 -0500
From: David Delikat <ddelikat@protix.com>
To: abigail@fnx.com
Subject: Re: here docs vs qq quote operator. Just personal preference?
Message-Id: <37090F92.794B@protix.com>

Abigail wrote:
> 
<snip>
> Abigail
> --
> perl -wleprint -eqq-@{[ -eqw\\\\- -eJust -eanother -ePerl -eHacker -e\\\\-]}-

OK, what's up Abigail, that one didn't work.  I just copy and paste
in another X session and it gives me lots of perl errors.

-dav

-- 
<((((><
Consultant: Internet, Database, Business Systems
Unix/Linux, Windows95/NT
mailto:david-delikat@usa.net / http://obj.webjump.com/


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

Date: 5 Apr 1999 20:06:37 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: here docs vs qq quote operator. Just personal preference?
Message-Id: <slrn7gi5ud.fdc.sholden@pgrad.cs.usyd.edu.au>

On Mon, 05 Apr 1999 14:31:30 -0500, David Delikat <ddelikat@protix.com> wrote:
>Abigail wrote:
>> 
><snip>
>> Abigail
>> --
>> perl -wleprint -eqq-@{[ -eqw\\\\- -eJust -eanother -ePerl -eHacker -e\\\\-]}-
>
>OK, what's up Abigail, that one didn't work.  I just copy and paste
>in another X session and it gives me lots of perl errors.

Abigail is just trying to lull people into doing 'copy and paste' with
the sigs. So that one day what will go down in history as the 'perl worm'
will be unleashed, as thousands of people on thousands of servers execute
arbitrary code posted to usenet by someone they have never met...

Then again maybe I'm just paranoid ;)

-- 
Sam

Computers in the future may weigh no more than 1.5 tons.
	--Popular Mechanics, 1949


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

Date: Mon, 05 Apr 1999 19:04:34 GMT
From: mtaylor@cybernet.com
Subject: How to compile (perlcc) *.pm, then "use" it?
Message-Id: <7eb1fs$72i$1@nnrp1.dejanews.com>

I've been investigating on how to use something like "perlcc" (the B::CC
backend) to compile a .pm file, and the "use" it in a script.

The straightforward approach does not work:
  perlcc x.pm
  mv x.pm x.pm.old
  perl -e 'use x qw(); &x::somefunction();'

The "use x" will not load x.so (it only looks for x.pm).

I imagine that I somehow have to use the DynaLoader to bring in x.so?  Do I
have to do anything wierd with the xs stuff?

Also, x.so has too many symbols: it includes compile-time dependencies that
are needed.  So, if x.pm "uses" y.pm, then the y.pm functions referenced in
x.pm will be compiled into x.so.  This is not what I wanted...


Any ideas on:
  1) How to get "x.so" to load in from another perl script?
  2) Reduce the symbols in x.so to only those found in x.pm?


Thanks for reading this!

BTW: the target OS is FreeBSD 2.2.7, 3.1, and/or RedHat Linux 5.2, and I'm
using perl 5.005_02 and perl 5.005_03.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 05 Apr 1999 13:28:37 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Lisp influences on Perl, Perl as an AI language
Message-Id: <m1677abymi.fsf@halfdome.holdit.com>

>>>>> "Jonathan" == Jonathan  <jonathan@meanwhile.freeserve.co.uk> writes:

Jonathan> I'd be very interested to hear discussion from people who
Jonathan> know Lisp and Perl on this. My feeling is that Perl looks
Jonathan> like C, but behaves just as much in what I'd always taken to
Jonathan> be a Lisp-ish manner.

And with the code in
<URL:http://www.cpan.org/authors/id/GAAS/perl-lisp-0.05.tar.gz>,
you don't have to choose.  A lisp interpreter written in Perl!

print "Just another Perl hacker,"

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Mon, 05 Apr 1999 15:22:37 -0500
From: David Delikat <ddelikat@protix.com>
Subject: Re: Lisp influences on Perl, Perl as an AI language
Message-Id: <37091B8D.1CFB@protix.com>

Jonathan wrote:
> 
> Let me start out by saying *I am not trying to start a language war here.* I
> think Perl is an incredibly beautiful language, and I have a lot of
> admiration for what I know about Lisp.
> 
> I've always meant to learn Lisp - when I have the time, which is never now.
> I started learning Perl last week, because I thought it would be the best
> tool to write some file convertors in. This turns out to be true, but I've
> been shocked at how much else the language seems good for.
> 
> The most impressive things about Perl seem to me to be  [1] the flexibile
> and creative way it lets you treat data structures - hashes of hashes of
> arrays and such are a marvellous idea, and likewise the support the langauge
> has the concept of "many" through functions like for(each), keys and slice
> [2] the runtime flexibility it achieves through its "I'll do my best to do
> what you say" attitude, flexible function calling, ability to execute
> strings etc. I can see so many possibilities here - and this is all the sort
> of stuff that I thought I'd have to learn Lisp for, or hack very shakily and
> at great effort into C++. (One place I got that idea is Coplien Purple
> book.)
> 
> I'd be very interested to hear discussion from people who know Lisp and Perl
> on this. My feeling is that Perl looks like C, but behaves just as much in
> what I'd always taken to be a Lisp-ish manner.
> 
> Second part of this question: Perl seems an obvious language to use for AI.
> Is anyone doing much work in this area with Perl?
> 
> Jonathan Coupe.

I learned Lisp in College, and regret to say I have 
not been able to use it since ( great language for
'out of box' work ).  Yes there are some similarities
in the attitudes that the two languages are based on.

as for the second part, I have written some Genetic
algorythms in perl.  I started to write some logic
managment stuff ( similar to prolog ) but stopped
because I am too busy.  I can see it would be very 
powerful for that use.  I think there are some modules
in the archives too...

-dav


-- 
<((((><
Consultant: Internet, Database, Business Systems
Unix/Linux, Windows95/NT
mailto:david-delikat@usa.net / http://obj.webjump.com/


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

Date: Mon, 5 Apr 1999 14:15:19 -0600
From: Justin England <jengland@enetis.net>
Subject: mag tape IOCTL
Message-Id: <Pine.SUN.4.05.9904051406580.10619-100000@mail.enetis.net>

I am trying to write some scripts that will manipulate my 4mm dat drive,
but I am having problems with the ioctl().

This is using FreeBSD 2.1.6 and Perl 5.004_01

I have basically created the following program that should simply eject
the tape that is loaded (mt -f /dev/rst0 offline).

But produces the following error:

Can't locate object method "struct" via package "mtop" at (eval 182) line 1.

Which comes from the mtio.ph file:

eval 'sub MTIOCTOP { &_IOW(ord(\'m\'), 1, struct mtop);}';


Could anybody give me some guidance as to what I need to change in order
of this to work?

Below is the code I am using.

Thanks,

Justin


#!/usr/local/bin/perl
require "sys/ioctl.ph";
require "sys/mtio.ph";

$mt_cmd_t = "sl";

open(TAPE, "/dev/rst0") || die "$!\n";
$mt[0] = MTOFFL();
$mt[1] = "0";
$mt_cmd = pack($mt_cmd_t, @mt);

ioctl(TAPE, &MTIOCTOP, $mt_cmd) || die "$!\n";;
close(TAPE);



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

Date: Mon, 05 Apr 1999 12:08:40 -0700
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: minimal pattern matching
Message-Id: <37090A38.6EE44522@mail.cor.epa.gov>

sstarre@my-dejanews.com wrote:
> Methinks that s/// needs another switch. I'm trying to locate all instances of
> strings surrounded by a delimiter in a string, such as
> 
>   $petnames{cat}='morris';
>   $petnames{dog}='fido';
>   $_=':cat: is a good pet, but :dog: is better.';
>   s/\:(.*)\:/$petnames{$1}/g;
> 
> (results in "is better.")
> 
> This work great on one instance on the line, but in this case it seems to find
>   ":cat: is a good pet, but :dog:"
> as $1 since matching is greedy.
> 
> I studied switches in pp 7x in Camel, and none seem to direct Perl to match
> minimally. Are there a set of switches that I can use to direct the match to
> operate minimally, as many times as possible in the line?

Sara,
   You're thinking in terms of the operator s/// when you want to think in
terms of the regexes within the operator.  Perl has all the 'lazy' or
'non-greedy' operators I have needed.  Instead of '.*' try '.*?' .  Take
a look through the perlre docs, and you'll see that '?' gives you a number
of minimal matches:
*?
+?
??
{n,m}?

And there are many more uses for '?' in regexes.  In the words of Larry
Wall, "Have the appropriate amount of fun."

David
-- 
David L. Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Mon, 05 Apr 1999 12:16:12 -0700
From: Erik Boles <erik@rockymountainwebtech.com>
Subject: Perlshop Problem
Message-Id: <37090BFB.9E935D76@rockymountainwebtech.com>

Perlshop is running great for us with one exception....we are using a
secure server but still want the credit card info to be mailed to us
when the transaction is completed.... I know it has the option to
include CC# with the receipt to the vendor (us) but whrn you select 'use
secure server' it disables this feature.....

does anyone know of a workaround?  We plan to use cybercash or the like
in the near future but for now and for testing reasons would like it to
submit the CC# with the email...

Also, when finishing the form (or viewing rate info) it brings up a
security window that recommends they not continue with the
transaction...siting the info is secure, but is being sent to an
insecure location....would like to get away from this as well, if
possible....

Any help greatly appreciated.....I wish there were a perlshop listserv
or Users Group.....

Erik




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

Date: Mon, 05 Apr 1999 12:21:25 -0700
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: Pick one of two files
Message-Id: <37090D35.4D19A96E@mail.cor.epa.gov>

Scribbles wrote:
> Hiyas,

Hiya rightbackatyou,
 
> This is probably pretty basic; can I have an <A HREF> point to a cgi
> script that will display one file if it exists, another if it doesn't,
> and if so, any examples anywhere around? TIA.

Oops, sorry, but you're asking this in the wrong newsgroup.
Even if your program is written in Perl.  Really.
You have a cgi/html quesiton, so oyu really should ask in a cgi
newsgroup, where you can get lots of *helpful* answers instead of
this annoying reply.  :-)  Try:
  comp.infosystems.www.authoring.cgi

HTH,
David
-- 
David L. Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Mon, 5 Apr 1999 10:44:32 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Pick one of two files
Message-Id: <g8iae7.ngv.ln@magna.metronet.com>

Scribbles (nospam@nomail.com) wrote:

: This is probably pretty basic; can I have an <A HREF> point to a cgi
: script that will display one file if it exists, another if it doesn't,
: and if so, any examples anywhere around? TIA.


   if ( -e $firstfile ) {
      open(IN, $firstfile) || die "could not open '$firstfile'  $!";
   }
   else {
      open(IN, $otherfile) || die "could not open '$otherfile'  $!";
   }

   while (<IN>) {print}

   close(IN);


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Mon, 05 Apr 1999 14:47:18 -0500
From: David Delikat <ddelikat@protix.com>
Subject: Re: PROGRESS Data Base and Perl ?
Message-Id: <37091346.59E2@protix.com>

Patrick Fichou wrote:
> 
> Hi,
> 
> I currently work on a Unix/Progress environment and discovered Perl
> recently... but really like this language !!!
> I would like to know if someone knows how to acces a Progress DB with Perl.
> Just reading the files would be enough to make some CGI package !
> I use HP/UX 10.20 and Progress 6.3.
> Thank you !
> 
> Patrick

back when perl was younger I used to use a lot
of pipes to access data.  of course you need to
be careful managing transctions tho.

basically it looks like this:

open( SQL, "|sql" ) || die;  # I always sent the output to a file
print SQL "select data from table sort by field\n";
close SQL;

not the best solution, but there was little else at the time.

-dav

-- 
<((((><
Consultant: Internet, Database, Business Systems
Unix/Linux, Windows95/NT
mailto:david-delikat@usa.net / http://obj.webjump.com/


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

Date: 05 Apr 1999 12:38:39 -0700
From: jmastyers@pcocd2.intel.com (Justin Masters - remove y to reply)
Subject: Return value undef, but with || undef'ed value, result = 1?
Message-Id: <cavsoaeoo1s.fsf@frc6040.fm.intel.com>


I have the following code that is puzzling me:


($nbcl)         = &checkargsoneval('nbcl') || $NBCL;

$NBCL = undef under debugger.
nbcl is not an argument, which this subroutine checks for.  The last
statement of the subroutine says:

return(@returnvals);

In debugger, @returnvals is undef as well.

However, $nbcl = 1, when I run the debugger.


I changed the line to say:
($nbcl)         = &checkargsoneval('nbcl');

The value for @returnvals is still undef, and $nbcl is also undef.

Why does $nbcl get undef value without the use of '|| $NBCL;'?  Where is
the '1' coming from?

So what gives here?  (I'm using Perl 5.4004 on AIX 4.1.5)

Justin Masters (remove y to reply - too tired of spam..)

--
------------------------------------------------------------------------------
   Justin Masters   (Sr. Cad Engineer - Design Automation)  PH: 916-356-6735
   Intel Corp. FM5-94                                      FAX: 916 356-7874
   1900 Prairie City Rd, Folsom, CA 95630          jmastyers@pcocd2.intel.com


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

Date: Mon, 5 Apr 1999 12:11:58 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: splice incompatible with foreach
Message-Id: <MPG.1172aad96242b30c989832@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <3708FAD3.7B815030@execonn.com> on Mon, 05 Apr 1999 14:03:00 
-0400, Marshall Dudley <mdudley@execonn.com> says...
> I am trying to go through an array and do something with each element,
> and in some cases remove the element from the array.  The splice
> function is the only one I can find to let me do this, but it interacts
> with the foreach so I get screwy results.

This is the short answer, from perlsyn:

"If any part of LIST is an array, foreach will get very confused if you 
add or remove elements within the loop body, for example with splice. So 
don't do that."

However, let's do it anyhow... 

> This simple script is suppose to look at all lines and remove those that
> say remove.  But it completely misses any line after a remove, and
> doesn't always remove the lines with remove in them.  Does anyone know
> an easy solution to getting around this?

Yes, process the array back to front.  Then the offsets that you are 
keeping count of will be correct.

> @lines = ("1 keep","2 keep","3 remove","4 keep","5 remove","6 remove","7
> keep");
> $count = -1;
> foreach $line (@lines) {
>         $count++;

Change the three lines above to:

$count = @lines;
foreach $line (reverse @lines) {
        $count--;

> #do things with that particular $line here then remove some of the lines
> from the array
>         if ($line =~ /remove/) {splice (@lines,$count,1); }
>         print "$line\n";
> }
> print "\n";
> foreach $line (@lines) { print "$line\n"; }
> 
> RESULT:
> 
> 1 keep
> 2 keep
> 3 remove
> 5 remove
> 7 keep
> 
> 1 keep
> 2 keep
> 4 keep
> 6 remove
> 7 keep

7 keep
6 remove
5 remove
4 keep
3 remove
2 keep
1 keep

1 keep
2 keep
4 keep
7 keep

And now that all that is said and done, let's do it the right way:

  @lines = grep !/remove/, @lines;

Or, to take account of your other expressed need:

  #do things with that particular $line here then remove some of
  #the lines from the array

  @lines = map { do_something($_); /remove/ ? () : $_ } @lines;

The do_something() can be a subroutine call or inline code.

Perl functions 'grep' and 'map' make a lot of ugly things clean.

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


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

Date: Mon, 05 Apr 1999 19:30:23 +0000
From: Paul Cameron <paul.cameron@sun.com>
To: Marshall Dudley <mdudley@execonn.com>
Subject: Re: splice incompatible with foreach
Message-Id: <37090F4F.67EFCFB2@sun.com>

Marshall Dudley wrote:

> This simple script is suppose to look at all lines and remove those that
> say remove.  But it completely misses any line after a remove, and
> doesn't always remove the lines with remove in them.  Does anyone know
> an easy solution to getting around this?

It is doing bad things to your iterator ...

Either work from the end of the array to the start, like:

for (int i = $#array; i >= 0; i--) {
    // do your splicing here
}

Or, rebuild a new array. While I don't know how splice is implemented
internally
off the top of my head, I'm betting it's far more expensive than rebuilding
a new
array from the previous one.

Paul.



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

Date: Mon, 05 Apr 1999 19:32:04 +0000
From: Paul Cameron <paul.cameron@sun.com>
Subject: Re: splice incompatible with foreach
Message-Id: <37090FB4.10C6268C@sun.com>

Paul Cameron wrote:

> for (int i = $#array; i >= 0; i--) {
>     // do your splicing here
> }

Oh god, I've been writing too much Java!!

Paul.



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

Date: Mon, 5 Apr 1999 12:23:01 -0700
From: "Gabriel Richards" <grichard@uci.edu>
Subject: This proverbial "perldoc".
Message-Id: <7eb2cj$aq2@news.service.uci.edu>

Where is this proverbial "perldoc" program that everyone seems to think will
answer all newbie questions?

I've got some Win32 perl distribution here on my work machine and can't find
any "perldoc" anywhere just a bunch of hypertext docs. I typed perldoc at my
Unix terminal (where my scripts run) and got bad command. Do I need to
download something from somewhere?

Gabe




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

Date: 05 Apr 1999 15:31:12 -0400
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: This proverbial "perldoc".
Message-Id: <x7hfquvp8f.fsf@home.sysarch.com>

>>>>> "GR" == Gabriel Richards <grichard@uci.edu> writes:

  GR> Where is this proverbial "perldoc" program that everyone seems to
  GR> think will answer all newbie questions?

  GR> I've got some Win32 perl distribution here on my work machine and
  GR> can't find any "perldoc" anywhere just a bunch of hypertext
  GR> docs. I typed perldoc at my Unix terminal (where my scripts run)
  GR> and got bad command. Do I need to download something from
  GR> somewhere?

i can't resist :-)

try:

perldoc perldoc


(quoted without permission from the IFAQ posted on 4/1 to c.l.p.moderated)

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Mon, 5 Apr 1999 13:47:21 -0700
From: "Gabriel Richards" <grichard@uci.edu>
Subject: Re: This proverbial "perldoc".
Message-Id: <7eb7ad$dc8@news.service.uci.edu>

> try:
>
> perldoc perldoc

No dice...another idea? Where is perldoc!

Gabe




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

Date: Mon, 05 Apr 1999 19:46:11 GMT
From: rujain@my-dejanews.com
Subject: Time Functions in Perl !
Message-Id: <7eb3u2$9ag$1@nnrp1.dejanews.com>

Hello,

The situation is : I have input as timestamp <yyyy-mm-dd> <hh:mm:ss> format.
I want to convert this timestamp to the unix time format (secs elapsed since
1-1-1970). Is there any function in Perl, which will work on Windows-NT and
UNIX platforms.

I tried to use :
    use Date::Parse;
    $time = str2time($date);

but it gave error : Can't locate Date/Parse.pm in @INC (@INC contains:
c:\perl\lib c:\perl\site\lib .) at filename.pl line 5.

Is Date, not a standard lib function.

I have perl version as :
This is perl, version 5.005_03 built for MSWin32-x86-object

thanx,
rujain.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 5 Apr 1999 20:17:21 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Time Functions in Perl !
Message-Id: <slrn7gi6ih.fdc.sholden@pgrad.cs.usyd.edu.au>

On Mon, 05 Apr 1999 19:46:11 GMT, rujain@my-dejanews.com wrote:
>Hello,
>
>The situation is : I have input as timestamp <yyyy-mm-dd> <hh:mm:ss> format.
>I want to convert this timestamp to the unix time format (secs elapsed since
>1-1-1970). Is there any function in Perl, which will work on Windows-NT and
>UNIX platforms.
>
>I tried to use :
>    use Date::Parse;
>    $time = str2time($date);
>
>but it gave error : Can't locate Date/Parse.pm in @INC (@INC contains:
>c:\perl\lib c:\perl\site\lib .) at filename.pl line 5.
>
>Is Date, not a standard lib function.

Date::Parse is a module you can download from CPAN (perldoc CPAN). I believe
it is 'pure perl' and thus will work with a perl built elsewhere (ie.
ActiveState).

-- 
Sam

People get annoyed when you try to debug them.
	--Larry Wall


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

Date: Mon, 05 Apr 1999 21:45:57 +0100
From: Greg Griffiths <greg2@surfaid.org>
To: Henrik Widenfors <pt98hwi@student.hk-r.se>
Subject: Re: Web -> Database Access...
Message-Id: <37092105.C314A68A@surfaid.org>

take a look at Perl DBI and ODBC.pm form http://www.roth.net/odbc/
(although the latter is Windows only at the mo), if your server is not a
windows one then either convert your DB to the required format or look
for another server. Firstly I'd call your ISP and talk it through with
them as many will charge you for the workload. Email me for more info.

Henrik Widenfors wrote:
> 
> Hi
> 
> Can I write a Cgi-script in Perl that opens a MS Access database and
> then sends SQL queries to it? Where can I find information about web ->
> database access on the web?
> 
> Thanks alot
> 
> PLEASE send a e-mail to    pt98hwi@student.hk-r.se   aswell
> 
> / Henrik Widenfors


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

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


Administrivia:

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

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

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 5302
**************************************

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