[16633] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4045 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 17 11:06:13 2000

Date: Thu, 17 Aug 2000 08:05:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <966524711-v9-i4045@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 17 Aug 2000     Volume: 9 Number: 4045

Today's topics:
    Re: array weirdness. <sariq@texas.net>
    Re: close window (Gwyn Judd)
    Re: close window <Joe.Rocklin@sdrc.com>
        DBI / DBD-Oracle problem, database disconnected <erik.dantes@wmich.edu>
    Re: glob error on AIX <guenther.degenfelder@datev.de>
    Re: glob error on AIX <care227@attglobal.net>
    Re: Mail processing (Colin Keith)
    Re: MS Access (Mark-Jason Dominus)
    Re: MS Access <gregory_griffiths@cargill.com>
    Re: need help with  s/// (Colin Keith)
    Re: newbie - documentation <red_orc@my-deja.com>
    Re: Newbie: DBI gives "Begin Failed " error (Colin Keith)
        Nothing wrong with newbies (was Re: Negativity in Newsg (Randal L. Schwartz)
    Re: perl 5.6 <alex.buell@tahallah.clara.co.uk>
        Perl Flashes window <jmaayan@isdn.net.ilt>
    Re: Perl Flashes window <tom.kralidis@ccrs.nrcan.gcDOTca>
    Re: Perl Flashes window <fillem@dl2.org>
    Re: Perl Flashes window <gregory_griffiths@cargill.com>
        Perl Pfad <Stefan.Soller@gmx.ch>
    Re: PERL/TK AND WIDGETS <aqumsieh@hyperchip.com>
    Re: PERL/TK AND WIDGETS <panderse@us.ibm.com>
        Reading remote files brian.russo@nextel.com
    Re: Reading remote files <tony_curtis32@yahoo.com>
    Re: Regex Alternation Question (Mark-Jason Dominus)
    Re: Regex Alternation Question (Mark-Jason Dominus)
    Re: Regex Alternation Question <aqumsieh@hyperchip.com>
    Re: Regex Alternation Question (Teodor Zlatanov)
    Re: Sorting is very slow (Anno Siegel)
    Re: Sorting is very slow (Mike Stok)
    Re: Sorting is very slow (Decklin Foster)
        Two pipes and only one runs, why? <panderse@us.ibm.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 17 Aug 2000 14:42:46 GMT
From: Tom Briles <sariq@texas.net>
Subject: Re: array weirdness.
Message-Id: <399BFA03.57BC2D2C@texas.net>

jason wrote:
> 
> Teodor Zlatanov wrote ..
> ><MPG.1403d3ee4b63494798ac82@nntp.hpl.hp.com>:Larry Rosler (lr@hpl.hp.com):comp.
> >: In article <8nd91k$naj$1@nnrp1.deja.com>, johnvert@my-deja.com says...
> >: > Hi, this question may seem trivial, but I can't find a logical
> >: > explanation for it: why does:
> >: > my @list=([1,2,3,4,5]);
> >: > print @{$list[0]};
> >: >
> >: > outputs the string: 12345
> >: > while: print "@{$list[0]}";
> >: > outputs the string: 1 2 3 4 5?
> >:
> >: perlfaq5: "Why do I get weird spaces when I
> >: print an array of lines?"
> >
> >I think he might want to look at perlvar for $" and $, as well :)  This was
> >just asked in an earlier thread.
> 
> yeah .. IMHO the FAQ document should contain references to those vars ..

Agreed.

Patches welcome...well, sort of...I sent a patch for this several months
ago, and never heard back.  Perhaps I'll resubmit it.

- Tom


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

Date: Thu, 17 Aug 2000 13:05:19 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: close window
Message-Id: <slrn8pnouo.306.tjla@thislove.dyndns.org>

I was shocked! How could Flip <radjis@hotmail.com>
say such a terrible thing:
>Could anybody tell me what the perl command is to close the current
>browserwindow

kill 9, $netscape_pid;

usually does it for me

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
He played the king as if afraid someone else would play the ace.
		-- John Mason Brown, drama critic


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

Date: Thu, 17 Aug 2000 09:24:20 -0400
From: Joe Rocklin <Joe.Rocklin@sdrc.com>
Subject: Re: close window
Message-Id: <399BE784.55144E2B@sdrc.com>

I think what you're asking is not a perl question, but a javascript
one.  If it is a perl question I don't know the answer, but for
javascript it's simply : close(), when a handler is invoked.

Hope this helps.
--Joe

Flip wrote:

> Could anybody tell me what the perl command is to close the current
> browserwindow
>
> thanks.

--
------------------------------------------------------------------------------
Joe Rocklin             joe.rocklin@sdrc.com
"The whole of science is nothing more than a refinement of everyday thinking."
        -- Albert Einstein, Physics and Reality [1936]:





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

Date: Thu, 17 Aug 2000 10:45:32 -0400
From: Erik Dantes <erik.dantes@wmich.edu>
Subject: DBI / DBD-Oracle problem, database disconnected
Message-Id: <399BFA8C.25447873@wmich.edu>

I am having an intermitten problem.  I have a perl script that generates
web pages pulling data from an Oracle database.  I am using:
 Perl: 5.00503
 DBI: 1.13
 DBD-Oracle: 1.03

 I get this entry in the error_log:
 DBD::Oracle::db prepare failed: ERROR Database disconnected at
/path/to/file/openwork.pl line 313.
 [Tue Aug 15 0:57:49 2000] [error] Can't prepare SQL statement: ERROR
Database disconnected

 Now if I reload the web page, _Most_ of the time, it will then run.  On
the occasions that it does not reload properly, if I give Apache a -HUP,
it always works.

 At the beginning of the script I have:
 $db=DBI->connect("dbi:Oracle:host=machine;sid=orcl","acct","password")
   || die "Connect Failed: $DBI::errstr";

 I then call subroutines, and included in them are:
 $sql = "SELECT stuff FROM table WHERE condition";
 $cur = $db->prepare("$sql")
   || die "Can't prepare SQL statement: ", $db->errstr(), "\n";
 $cur->execute()
   || die "Can't execute SQL statement: ", $cur->errstr(), "\n";
 while (($stuff) = $cur->fetchrow_array) {
   do some things here...
 }
 warn "Problem in fetchrow_array(): ", $cur->errstr(), "\n"   if
$cur->err();


 I often call multiple subroutines, some with database connections. At
the end of the script I have:
 $db->disconnect()
   || warn "Failed to disconnect: ", $db->errstr(), "\n";


 Looking through this, I notice I don't have any finish().  Could that
be part of it?  Anyhow.  Is there a way to capture the disconnection and
force a reconnect?  Any ideas are welcome.

 Erik




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

Date: Thu, 17 Aug 2000 16:41:24 +0200
From: "Guenther Degenfelder" <guenther.degenfelder@datev.de>
Subject: Re: glob error on AIX
Message-Id: <399bfa18$1@news.datev.de>


"Drew Simonis" <care227@attglobal.net> schrieb im Newsbeitrag
news:399ABC1D.98C04691@attglobal.net...
> Guenther Degenfelder wrote:
> >
> > I got same errors by running ANY perl script with a copy of the AIX 4.3
perl
> > on a AIX 4.2 machine...
> >
>
> Perhaps you shouldn't be running a binary built for a later version?
> Can't you get a binary of perl built for 4.2?  Or get the source
> and compile it locally...

Yes.
I know.

This was only a hint for don, where his error could come from!

I will upgrade my 4.2 machine to 4.3 somewhere in the future if i'm feeling
very boring...

Regards

    Guenther




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

Date: Thu, 17 Aug 2000 10:59:29 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: glob error on AIX
Message-Id: <399BFDD1.AE0628AE@attglobal.net>

Guenther Degenfelder wrote:
> 
> "Drew Simonis" <care227@attglobal.net> schrieb im Newsbeitrag
> >
> > Perhaps you shouldn't be running a binary built for a later version?
> > Can't you get a binary of perl built for 4.2?  Or get the source
> > and compile it locally...
> 
> Yes.
> I know.
> 
> This was only a hint for don, where his error could come from!
> 

Sorry for the terse tone, I thought you were the OP.


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

Date: Thu, 17 Aug 2000 13:24:15 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: Mail processing
Message-Id: <3IRm5.156$DT4.3923957@nnrp2.clara.net>

In article <8ndn99$709$1@srvlis16.teleweb.pt>, "Nuno Santo" <nunosanto@netcabo.pt> wrote:
>news delivery service via e-mail. Does someone know hoe can i check the mail
>account and get the message so that i can insert it into the site?

I don't quite understand this, 'news' usually refers to what you just 
posted, 'mail' is e-mail. The two use different protocols.

But, to help a little (hopefully) have a look at the modules available on 
CPAN http://www.cpan.org/ for retrieving and sending news/e-mail.

Col.


---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC


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

Date: Thu, 17 Aug 2000 14:44:25 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: MS Access
Message-Id: <399bfa48.5d3$ff@news.op.net>

In article <399bd9f1.113181756@news.kopteri.net>,
Mauri Heinonen <mauri.heinonen@kopteri.net> wrote:
>How I can you in WinNT MS Access in my own perl-scripts wich i make
>with activeperl? Wich is that module and where i can download it???

I think yo uneed to get the 

        DBI
and
        DBD::ODBC

modules.  You can get them from cpan.perl.org.

Also see

        http://www.perl.com/pub/1999/10/DBI.html
        `A Short Guide to DBI'



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

Date: Thu, 17 Aug 2000 15:42:43 +0100
From: "Greg Griffiths" <gregory_griffiths@cargill.com>
Subject: Re: MS Access
Message-Id: <8ngtlb$5jn$1@mercury.cargill.com>

try the DBI or Win32::ODBC (part of the ActivePERL install) for this

Mauri Heinonen <mauri.heinonen@kopteri.net> wrote in message
news:399bd9f1.113181756@news.kopteri.net...
> Hi
>
> How I can you in WinNT MS Access in my own perl-scripts wich i make
> with activeperl? Wich is that module and where i can download it???
>
> I hope someone helps me!!!
>
> Mauri Heinonen
> mauri.heinonen@kopteri.net




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

Date: Thu, 17 Aug 2000 13:33:21 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: need help with  s///
Message-Id: <BQRm5.157$DT4.3924122@nnrp2.clara.net>

In article <slrn8pl9b6.73q.rgarciasuarez@rafael.kazibao.net>, rgarciasuarez@free.fr (Rafael Garcia-Suarez) wrote:
>Eric Surin wrote in comp.lang.perl.misc:
>\%0D is not a special character. It is the literal string "%0D".
>You meant s/\x0D\x0A/+++/g.

Unless we're talking about URLencoding (and hey, so many people these days 
do) In which case:

s/%0[AD]/+++/g;


---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC


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

Date: Thu, 17 Aug 2000 13:12:21 GMT
From: Rodney Engdahl <red_orc@my-deja.com>
Subject: Re: newbie - documentation
Message-Id: <8ngob6$mv7$1@nnrp1.deja.com>

In article <399BCC62.11639713@gundam.com>,
  Gecco th Ruled <gecco@gundam.com> wrote:
> where i can find the dicumentation onf Net:IRC?

same place you can get the module:  www.cpan.org:

http://search.cpan.org/search?mode=module&query=Net%3A%3AIRC


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 17 Aug 2000 13:38:27 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: Newbie: DBI gives "Begin Failed " error
Message-Id: <nVRm5.158$DT4.3924245@nnrp2.clara.net>

In article <rnOm5.35789$c5.1332081@news2.rdc1.on.home.com>, "bjg" <bGhassemlou@home.com> wrote:
>Can't locate loadable object for module DBI in @INC (@INC contains:
>Can someone explain what is the problem?????

You don't have DBI installed properly. Er In fact:

># If you get an error here like "Can't find loadable object ..."
># then you haven't installed the DBI correctly. Read the README
># then install it again.
>bootstrap DBI;

That's exactly what it says here. *sigh* I bet you really have to have this 
working by yesterday too, right? Please, please, *read* what is in front of 
you. You will need to reinstall it. Since you're on windows I suspect you'll 
need to use PPM to install it ... 

Col.


---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC


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

Date: 17 Aug 2000 07:18:32 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Nothing wrong with newbies (was Re: Negativity in Newsgroup...Newbie Perspective)
Message-Id: <m1em3oots7.fsf_-_@halfdome.holdit.com>

>>>>> "Ben" == Ben Kennedy <bkennedy99@home.com> writes:

Ben> With all due respect, I think you may have been missing his
Ben> point.  He used variable scoping to illustrate the point that
Ben> some people just don't "get it".  This wasn't directed to the new
Ben> user who is first learning about variables or hobbyists, but at
Ben> people who chose programming as as profession - this was the
Ben> thrust of the message.  Its definitely true that some people
Ben> don't have a mind for programming, and they probably shouldn't
Ben> try to pass themselves off as professionals.  I wouldn't want
Ben> people who don't know how to drive to be cab drivers either, nor
Ben> would I want people who can't swim to be a lifeguard.  I do find
Ben> it annoying when people who really non-programmers wastes my time
Ben> interviewing for a programmer position, or uses this newsgroup as
Ben> a substitute for actually learning this language.  Now if it was
Ben> a complex concept, such as say Perl internals, then it would be
Ben> an arrogant thing to say - but variable score is a pretty basic
Ben> and vital concept, which every professional should understand
Ben> well.

Yes, this was precisely my point.  I fully encourage everyone who can
deal in abstract reasoning and wants to be a programmer to hone their
skills.  But I've seen some people being paid to be a programmer who
*cannot* deal adequately with the abstract reasoning and mindset and
discipline required to do the job (or at least be paid for it :).

There's NOTHING WRONG with not being able to write programs
effectively because you don't have the aptitude.  I'll never be a
professional artist.  Seriously.  No matter how much I study art, I'm
still gonna be stuck at boring stick figures.  I don't see what the
artist sees.  My brain just isn't "wired" for it.  So I'm more than
happy to "know that I don't know that", and defer all such work to
people who grapple making cool looking things as well as I hack code,
and there are plenty of them out there.  Now suppose drawing pictures
paid better than programming... if I were to try to pass myself off as
an artist, I should rightfully get laughed out of the interview.  And
if I started going on the net, asking questions about "how do you know
whether to use a light green or an orange next to a blue box?", I
should be quickly diagnosed as someone who "just doesn't get it".

Admittedly, Usenet is a poor medium to make these calls accurately,
but there are often a lot of obvious signals.

So, to summarize again:

1) people that seem to have a capacity to learn (indicated in part by
formulating an intelligent question and providing evidence of
having tried to self-research the problem) ARE WELCOME HERE, no matter
what their skill level

2) people that don't have a capacity to learn or that seem to want to
use this as a substitute for their brain, either because of a missing
apititude or because they are lazy (not in the Larry sense of "Lazy")
ARE NOT WELCOME HERE

How hard is that to follow?

And yes, it's my personal opinion.  (I bet it's shared by most of the
other people that answer questions here though.)  It's because I want
to know that my posting is making a difference, not just getting
someone off today's emergency only to have them show back up tomorrow
with a different one.

Perhaps some of us are too quick to put someone in category 2.  I
admit I've done that when I'm tired and trying to answer the sixth
posting in a day (that's why I limit myself to one or two a day now).
Maybe some of us see the entire world in category 2. :) I don't, I
have a lot of hope for the world, or else I couldn't stand up in front
of a room each week and see how many people I can help by telling them
jokes to distract them from the fact that they're actually learning
something. :)

Maybe even out of this post, I'll be trying harder to see each person
first in category 1 until proven otherwise.

Just another Perl hacker and trainer and writer and believer in people,

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Thu, 17 Aug 2000 15:27:00 +0100
From: Alex Buell <alex.buell@tahallah.clara.co.uk>
Subject: Re: perl 5.6
Message-Id: <3btnps0co1082jgh7s1khrq4l6uo38dnla@4ax.com>

On 17 Aug 2000 12:30:57 GMT, ebohlman@netcom.com (Eric Bohlman) wrote:

>Randal L. Schwartz (merlyn@stonehenge.com) wrote:
>: >>>>> "Eric" == Eric Bohlman <ebohlman@netcom.com> writes:

>: 5.7.x is for Perl developer internal use (odd middle digit).
>: 5.6.x is for Perl stable releases (even middle digit).

[Replying to this one as I'm missing Merlyn's original post - sick
news server :o( ]

I'm interested in knowing if one can run two different versions of
Perl on the same box, in a similar way to how GCC handles things.

In GCC, I can run the specific compiler package by specifying the
version, i.e

gcc -V 2.7.2.3 file.c -o file
gcc -V 2.95.2 file.c -o file

So it would be a nice thing to have:

perl -V 5.6.0 foobar.pl
perl -V 5.7.2 foobar.pl

Summat like that..

Cheers,
Alex.
-- 
If you can't dazzle 'em with brilliance
Baffle em' with bullshit 

http://www.tahallah.clara.co.uk


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

Date: Thu, 17 Aug 2000 16:23:32 +0200
From: "Elhanan Maayan" <jmaayan@isdn.net.ilt>
Subject: Perl Flashes window
Message-Id: <8ngovq$gvg$1@news.ibm.net.il>

hi...
i have active state perl 5.6

when i try to enter print "Hello World!\n"; in a file named hello.pl and
execute it all i see a quick black window which dissappears after a second,
what's going on?






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

Date: Thu, 17 Aug 2000 09:25:20 -0400
From: "Tom Kralidis" <tom.kralidis@ccrs.nrcan.gcDOTca>
Subject: Re: Perl Flashes window
Message-Id: <8ngp40$gho9@nrn2.NRCan.gc.ca>

"Elhanan Maayan" <jmaayan@isdn.net.ilt> wrote in message
news:8ngovq$gvg$1@news.ibm.net.il...
> hi...
> i have active state perl 5.6
>
> when i try to enter print "Hello World!\n"; in a file named hello.pl and
> execute it all i see a quick black window which dissappears after a second,
> what's going on?
>

How are you executing the command?  If you open a DOS window and run the
program, you won't get this.

 ..Tom




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

Date: Thu, 17 Aug 2000 16:18:12 +0200
From: "Fillem" <fillem@dl2.org>
Subject: Re: Perl Flashes window
Message-Id: <8ngs8t$pmh$1@weber.a2000.nl>

it actually opens up a dos window, executes the program then closes the
window again, really fast :o)

what you can do is just add this final line to your program:

<STDIN>

or just

<>

so this is what your hello world would look like:

print "Hello World!\n";

<>

now all you have to do is press a key (could be the Enter key) and the
windows closes...

Fillem


"Elhanan Maayan" <jmaayan@isdn.net.ilt> wrote in message
news:8ngovq$gvg$1@news.ibm.net.il...
> hi...
> i have active state perl 5.6
>
> when i try to enter print "Hello World!\n"; in a file named hello.pl and
> execute it all i see a quick black window which dissappears after a
second,
> what's going on?
>
>
>
>




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

Date: Thu, 17 Aug 2000 15:41:20 +0100
From: "Greg Griffiths" <gregory_griffiths@cargill.com>
Subject: Re: Perl Flashes window
Message-Id: <8ngtjh$pms$1@mercury.cargill.com>

Or you can change the Association to something like :

command.com /k C:\Perl\bin\Perl.exe "%1" %*

this opens a command window and then runs the PERL prog, so when PERL
completes you are still in the window

Elhanan Maayan <jmaayan@isdn.net.ilt> wrote in message
news:8ngovq$gvg$1@news.ibm.net.il...
> hi...
> i have active state perl 5.6
>
> when i try to enter print "Hello World!\n"; in a file named hello.pl and
> execute it all i see a quick black window which dissappears after a
second,
> what's going on?
>
>
>
>




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

Date: Thu, 17 Aug 2000 16:53:33 +0200
From: "Stefan Soller" <Stefan.Soller@gmx.ch>
Subject: Perl Pfad
Message-Id: <8ngua4$nhp$1@news1.sunrise.ch>

$database_dir = "/www/nsi/_md/meinlink.de/data/";

wie oben muss ich den pfad der datenbank angeben, wo sich meine *.csv
dateien befinden! Doch ich will der pfad nicht so definieren sondern ich
will z.b. "http://www.meinlink.de/data" angeben können! Wie muss ich das
machen?
Sobald ich dies angebe $database_dir = "http://www.meinlink.de/data"; kommt,
dass er die datei *.csv nicht öffnen kann obwohl der pfad stimmt!! Könnt ihr
mir helfen?

DANKE





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

Date: Thu, 17 Aug 2000 14:25:27 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: PERL/TK AND WIDGETS
Message-Id: <7absysj76v.fsf@merlin.hyperchip.com>


Jeffrey Scott Dunfee II <dunfeeje@pilot.msu.edu> writes:

> I'm trying to find a function that will return the name of a button I
> have created, or some type of identifier that lets me know what button I
> have pressed.  Perhaps return the label on the button, that would be
> ideal. But I can not find any functions like this. Does anybody know
> anything about PERL/TK enough to tell me if a function like this
> exists... thanks

I think you are confused. Step back, and tell us the global picture and
what you would like to do. There's probably a better way to do what you
want.

When you create a button (or any other widget), you get a reference to
the widget object that you just created:

	my $button = $mw->Button(...)->pack;

Now, you can use this object (referred to by $button) anywhere in your
program.

You should also send you Tk-related questions to comp.lang.perl.tk.

--Ala


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

Date: Thu, 17 Aug 2000 09:31:41 -0500
From: "Paul R. Andersen" <panderse@us.ibm.com>
Subject: Re: PERL/TK AND WIDGETS
Message-Id: <399BF74D.55302DDF@us.ibm.com>

Jeffrey Scott Dunfee II wrote:
> 
> I'm trying to find a function that will return the name of a button I
> have created, or some type of identifier that lets me know what button I
> have pressed.  Perhaps return the label on the button, that would be
> ideal. But I can not find any functions like this. Does anybody know
> anything about PERL/TK enough to tell me if a function like this
> exists... thanks
> 
> -jeff dunfee
> dunfeeje@pilot.msu.edu
It would help if you showed us what you have tried.  I'm not sure what
you mean by a function that will return the name of the button.  What
kind of button are we talking about?  If you are talking about a basic
button, just off-hand, the only way I can think of to get informatin is
to have the button invoke a callback and do something in there to put
the button name someplace.  Wishy-washy I know.  Show me some code and I
can help more.
-- 
Paul Andersen
+++++++++++++
The difference between theory and practice is that in theory there is no
difference between theory and practice; but in practice there is.


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

Date: Thu, 17 Aug 2000 13:20:08 GMT
From: brian.russo@nextel.com
Subject: Reading remote files
Message-Id: <8ngopm$nci$1@nnrp1.deja.com>

Does anyone know if there is a way to read a file from a remote
(trusted) host? I would like to read the remote file(s) and avoid nfs
mounting the directory.

Is there a perl module that can do this?

Thanks,

-Brian


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 17 Aug 2000 08:47:49 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Reading remote files
Message-Id: <87k8dggfsq.fsf@limey.hpcc.uh.edu>

>> On Thu, 17 Aug 2000 13:20:08 GMT,
>> brian.russo@nextel.com said:

> Does anyone know if there is a way to read a file from a
> remote (trusted) host? I would like to read the remote
> file(s) and avoid nfs mounting the directory.

> Is there a perl module that can do this?

How do you intend to get the remote file?  ftp? scp?
kerberised ftp? something else?

t
-- 
"I'm not easily impressed.  Wow!  A blue car!"
                                               Homer Simpson


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

Date: Thu, 17 Aug 2000 14:37:15 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: Regex Alternation Question
Message-Id: <399bf89b.577$365@news.op.net>

In article <399BB4B9.B779C6F0@ppi.de>,
Jonas Reinsch  <Jonas.Reinsch@ppi.de> wrote:
>The best solution I could think of is something like:
>
>for ($i = 0; $i<@parens; $i++) {
>    if ($parens[$i]) {$part = $alt[$i];last}
>}
>Is there a more direct way to do this? 

That's the only way I know of to do it, and when I've showed it in my
classes at the Perl conference nobody has ever suggested a better way.


Note that you should replace
        if ($parens[$i])

with
        if (defined $parens[$i])

or else it might not work properly if one of the parens matches '0' or
the empty string.  This might also be marginally faster.

Note also that if any of the original patterns contain (...) you have
to change them to contain (?:...) instead or you will get the wrong
value of $i.

>But with alternations consisting of many parts it becomes
>rather slow.

I'm very surprised by that.  I use it regularly on alternations with a
few thousand parts and I have not noticed that it is slow.  My feeling
is that if it is slow to run a simple loop over an array, then you
have a more serious problem.  How many alternatives do you have?
Are you sure that this is the slow part of the program?  Have you done
any profiling tests?





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

Date: Thu, 17 Aug 2000 14:41:10 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: Regex Alternation Question
Message-Id: <399bf985.5be$38a@news.op.net>

Oh, I see one thing you're doing wrong:

>I do a match like this:
>
>@parens = $string =~ /$alt/;

Do the match like this:

 @parens = $string =~ /$alt/o;

otherwise you throw away the whole benefit of using one pattern
instead of one zillion patterns.



Of course, an alternative approach is to do something like:

        @pat = map {qr($_)} @alt;
        for $i (0 .. $#pats) {
          if ($string =~ /$pat[$i]/) {
            $part = $alt[$i]; last;
          }
        }


This only works if you have a Perl that supports qr().


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

Date: Thu, 17 Aug 2000 14:47:50 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: Regex Alternation Question
Message-Id: <7a7l9gj65j.fsf@merlin.hyperchip.com>


Jonas Reinsch <Jonas.Reinsch@ppi.de> writes:

> I have an alternation $alt consisting of parenthesized parts 
> $p1, $p2, $p3, ..., $pn (stored in an array @alt):
> 
> @alt = ($p1, $p2, $p3, ..., $pn);
> $alt = "(" . join(")|(", ($p1, $p2, $p3, ... , $pn)) . ")";
> 
> Now let's say (for the sake of simplicity) that no part $pi 
> contains any further parentheses apart from non-catching-ones
> like "(?:...)".
> I do a match like this:
> 
> @parens = $string =~ /$alt/;
> 
> It's easy to get the part of $string that was matched by $alt
> with $&, but the opposite (which part $pi of $alt matched) 
> seems to be far more tricky.
> The best solution I could think of is something like:
> 
> for ($i = 0; $i<@parens; $i++) {
>     if ($parens[$i]) {$part = $alt[$i];last}
> }
> 
> But with alternations consisting of many parts it becomes
> rather slow.
> Is there a more direct way to do this? (Perhaps a missing
> feature?) Sorry if I'm a bit naive, but I didn't implement
> a regex engine yet :-)

I'm not sure if this solution will be faster, or more efficient, but it
will prevent you from hitting a limitation in the regexp engine. Regexps
can not compile to more than 32767 bytes. So, if your array @alt is big
enough, Perl will complain and die with a 'regexp too big' message.

Plus, if you don't know the content of @alt before hand, then you should
ultimately gain using this approach.

My solution is to create an anonymous sub on the fly:

	my $string = 'sub { my $x = shift ; my @arr; ';
	for my $pat (@alt) {
	        $string .= "push \@arr, \[\$1, '$pat'\] if \$x =~ /($pat)/o;";
	}
	$string .= 'return @arr }';
	my $sub = eval $string;

Then, you can use $sub like so:

	my @matches = $sub->($string);
	for my $i (@matches) {
		my ($match, $part) = @$i;
		# do whatever ..
	}

--Ala


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

Date: 17 Aug 2000 10:51:30 -0500
From: tzz@iglou.com (Teodor Zlatanov)
Subject: Re: Regex Alternation Question
Message-Id: <399bfbf2$1_2@news.iglou.com>

<399BB4B9.B779C6F0@ppi.de>:Jonas Reinsch (Jonas.Reinsch@ppi.de):comp.lang.perl.misc:Thu, 17 Aug 2000 11:47:37 +0200:quote:
: I have an alternation $alt consisting of parenthesized parts 
: $p1, $p2, $p3, ..., $pn (stored in an array @alt):
: 
: @alt = ($p1, $p2, $p3, ..., $pn);
: $alt = "(" . join(")|(", ($p1, $p2, $p3, ... , $pn)) . ")";
: 
: Now let's say (for the sake of simplicity) that no part $pi 
: contains any further parentheses apart from non-catching-ones
: like "(?:...)".
: I do a match like this:
: 
: @parens = $string =~ /$alt/;
: 
: It's easy to get the part of $string that was matched by $alt
: with $&, but the opposite (which part $pi of $alt matched) 
: seems to be far more tricky.
: The best solution I could think of is something like:
: 
: for ($i = 0; $i<@parens; $i++) {
:     if ($parens[$i]) {$part = $alt[$i];last}
: }
: 
: But with alternations consisting of many parts it becomes
: rather slow.

perldoc perlfaq6: How do I efficiently match many regular expressions at
once?

(excerpt)
As of the 5.005 release, there's a much better approach, one which makes use
of the new `qr//' operator:

           # use spiffy new qr// operator, with /i flag even
           use 5.005;
           @popstates = qw(CO ON MI WI MN);
           @poppats   = map { qr/\b$_\b/i } @popstates;
           while (defined($line = <>)) {
               for $patobj (@poppats) {
                   print $line if $line =~ /$patobj/;
               }
           }

This is much faster than your way because alternate patterns generally take
longer than separate matching, and because of the precompilation.  You can
omit the precompilation, and it will still be faster than alternation, not
to mention that you can tell exactly what matched.

-- 
Teodor Zlatanov <tzz@iglou.com>
"Brevis oratio penetrat colos, longa potatio evacuat ciphos." -Rabelais


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

Date: 17 Aug 2000 13:43:09 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Sorting is very slow
Message-Id: <8ngq5d$lll$1@lublin.zrz.tu-berlin.de>

Gwyn Judd <tjla@guvfybir.qlaqaf.bet> wrote in comp.lang.perl.misc:

>As a sidenote, does anyone else feel Perl needs something like Haskell's
>"zip", "unzip" and related functions? For the uneducated, zip takes two
>lists and joins them into a two dimensional array (well list actually
>but why split hairs) by forming pairs of items. unzip does the reverse.

There are lots of functions that work on two or more lists
simultaneously that are occasionally useful.  One problem with
them is, there are so many of them, it's hard to decide which
are wanted frequently enough to include them in the Perl core.
The pat answer is: "None."

Another problem is, that many are only well defined when all
lists have the same length.  Your zip is an example.  A general
implementation would have to decide what to do if they aren't.
Stop where the shorter list ends?  Act as if there were so many
undef's on the shorter list?  Who knows what's more useful in
practice.

>I don't think I've explained this well so here is a poor example:

Well, it doesn't do much to clear things up, because it doesn't
do anything close to what you describe.

>sub zip
>{
>    my (@a, @b) = ($_[0], $_[1]);

Now you have two elements in @a and none in @b.

>    return (map {shift @b => $_} @b);

Even if @a and @b were the lists given in the call of zip, you are
now using the elements of @b twice and ignoring those in @a.  Change
the first @b to @a.  Further, the block you are giving to map will
(in list context) interpolate one element from @a and one from @b into
the result at each step.  You are interleaving the two lists, not
building a two-dimensional array.  Use [] instead of {} and add
a comma after the brackets (it's now an expression).  That would
come closer.

The code you gave for unzip is, if anything, even farther from
doing anything useful.  I'm not trying to correct it, so

[snip]

Anno


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

Date: Thu, 17 Aug 2000 14:05:22 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Sorting is very slow
Message-Id: <CiSm5.7254$K5.121925@typhoon.austin.rr.com>

In article <399B5F82.42E16A26@ust.hk>, Jim Chim  <mecks@ust.hk> wrote:
>-=-=-=-=-=-
>
>Hi,
>    I have write a code to sort some meteorological data which contain
>281560 data point.
>And write a sortin scheme to sort it. I know bubble sort only. I found
>that it take more
>than 10 hours to sort the data in PIII 800MHz machine. Can anyone give
>me some idea
>of how to improve the scheme so that it work faster. Thanks.
>    My code is attached in this message.

One thing to consider if you have large datasets is the PDL module (which has
qsort in PDL::Primitive).  This module can save considerable memory space and
give you speed improvements compared to using "native" perl datatypes.  See
http://pdl.perl.org/ for more.

The other replies to your question may well be sufficient, this is just 
another way to try it.

Hope this helps,

Mike
-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |
GPG PGP Key 1024D/059913DA         | Fingerprint      0570 71CD 6790 7C28 3D60
stok@colltech.com (CT - work)      |                  75D2 9EC4 C1C0 0599 13DA


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

Date: Thu, 17 Aug 2000 14:51:48 GMT
From: decklin+usenet@red-bean.com (Decklin Foster)
Subject: Re: Sorting is very slow
Message-Id: <8_Sm5.800$CW2.7662@news1.rdc1.ct.home.com>

Sean Malloy <srmalloy@home.com> writes:

> example is O(n ln(n)) -- for a data volume n, the amount of time it

Minor nitpick: ln is natural log; the base should be unspecified, as
in "O(n log n)". You wouldn't write "O(2.71828n)", because constant
terms are unimportant. Anyway, in this case the base is 2.

-- 
There is no TRUTH. There is no REALITY. There is no CONSISTENCY. There
are no ABSOLUTE STATEMENTS. I'm very probably wrong. -- BSD fortune(6)


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

Date: Thu, 17 Aug 2000 08:54:49 -0500
From: "Paul R. Andersen" <panderse@us.ibm.com>
Subject: Two pipes and only one runs, why?
Message-Id: <399BEEA9.A5A0779C@us.ibm.com>

The code below is about the minimum I could come up with that
demonstrates the problem I am having.  I clipped this from the program I
am working on (and simplified stuff) so while it looks kind of strange
now, it has the elements in it I need.  The goal is for the first pipe
to let the user know that something is happening (and keep the window
refreshed after it was covered for example).  The second pipe is
representative of one of several sequential processes that would be
fairly long running (20-30 minutes each).

I am expecting output that looks about like:
LP is underway.
XXX
LP did something.
XXX
LP did something.
XXX
 .
 .
 .

but I am seeing:
LP is underway.
LP did something.
XXXXXXXXXXXXXXXXXXXXXXXX

So can someone please explain to me first where this is getting stuck
and second how to fix it?
I am running on an RS/6000 under AIX 4.3 using Perl 5.005_02 and it is
installed by our IT folks on a shared file system serving the entire
site (so I can't tweek much, but I can lean on IT if something is
wrong).

#!/usr/contrib/bin/perl -w
use strict;
use Tk;
require Tk::ROText;

my $main = new MainWindow;
$main->configure('-title' => "Demo of failure");
my $checkdata = $main->Scrolled("ROText")
                     ->pack(-side => 'top', -fill => 'both');
$main->Button(-text => 'Runit',
	      -command => sub{RunTest(); }
             ) ->pack(-side => 'left');
MainLoop;

sub RunTest
{
  my $cmd = "TimeUpdate.pl";
  open PIPE, "$cmd |" or die "Open error: $!";
  # Create a fileevent that will capture output from the pipe
  $checkdata->fileevent(\*PIPE,
                 'readable' => sub
                 {
                   my ($stat, $UpdateBlock);
                   while ($stat = sysread PIPE, $UpdateBlock, 2)
                   { # update the screen
                     chomp $UpdateBlock;
                     $checkdata->insert('end',$UpdateBlock);
                     $checkdata->see('end');
                     $checkdata->update();
                   }
                   # Die if the read failed
                   die "sysread error: $!" unless defined $stat;
                 }
                );
  # ======================
  $cmd = "DummyProcess.pl";
  open READPRIME, "$cmd |" or
      die "Pipe for long running thing failed to open: $!\n";
  while (<READPRIME>)
  {
    $checkdata->insert('end',$_);
    $checkdata->see('end');
    $checkdata->update();
  }
  close READPRIME;
  $checkdata->fileevent(\*PIPE, 'readable' => '');
  close PIPE;
  print "Test ending\n";
}

This is TimeUpdate.pl

#!/usr/contrib/bin/perl -w
use strict;
select (STDOUT); $| = 1;
while (1 == 1)
{  sleep(2); print "X\n"; }

and this is DummyProcess.pl

#!/usr/contrib/bin/perl -w
use strict;
select (STDOUT); $| = 1;
print "LP is underway.\n";
for (my $i = 0; $i < 10; $i++)
{  sleep(6); print "LP did something.\n"; }

--
Thanks 
Paul Andersen
+++++++++++++
The difference between theory and practice is that in theory there is no
difference between theory and practice; but in practice there is.


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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.

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 V9 Issue 4045
**************************************


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