[15461] in Perl-Users-Digest
Perl-Users Digest, Issue: 2871 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 26 18:06:36 2000
Date: Wed, 26 Apr 2000 15:05:23 -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: <956786723-v9-i2871@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 26 Apr 2000 Volume: 9 Number: 2871
Today's topics:
Re: 5.6.0: split() doesn't handle Unicode? (Ilya Zakharevich)
Re: [REGEXP] Extremely important please read! (Craig Berry)
Re: [REGEXP] Extremely important please read! <lr@hpl.hp.com>
Re: [REGEXP] Extremely important please read! (Tad McClellan)
Re: [REGEXP] Extremely important please read! <charles.henry@engineer2k.com>
Re: [REGEXP] Extremely important please read! <lauren_smith13@hotmail.com>
Re: [REGEXP] Extremely important please read! <charles.henry@engineer2k.com>
Re: [REGEXP] Extremely important please read! <lr@hpl.hp.com>
Re: [REGEXP] Extremely important please read! <mjcarman@home.com>
about perlxs <aqlott@db.csie.ncu.edu.tw>
AIX perl 5.6 compile <ccoving@uhc.com>
Re: calling a cgi <flavell@mail.cern.ch>
Re: confused by full package name and warning <gellyfish@gellyfish.com>
DLL attributes <dstiff@delanotech.com>
Re: Extracting part of a string mitiste@charlie.iit.edu
form to email <a@b.com>
freetype-1.3.1 <yaqoota@emirates.net.ae>
Help with Linux & Perl command line <davidk@excitehome.net>
Re: Help with Linux & Perl command line <rootbeer@redcat.com>
Re: Help with Linux & Perl command line <lr@hpl.hp.com>
Re: Help with Linux & Perl command line <davidk@excitehome.net>
Re: Help with Linux & Perl command line (Tad McClellan)
Re: inserting $line into the middle of a list... (Tad McClellan)
Re: inserting $line into the middle of a list... <lr@hpl.hp.com>
Re: inserting $line into the middle of a list... <lr@hpl.hp.com>
Installing Perl <mouimet@direct.ca>
Re: Installing Perl <lauren_smith13@hotmail.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 26 Apr 2000 18:46:04 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: 5.6.0: split() doesn't handle Unicode?
Message-Id: <8e7dhc$e7n$1@charm.magnus.acs.ohio-state.edu>
[A complimentary Cc of this posting was sent to Denis Haskin
<Denis.Haskin@bigfoot.com>],
who wrote in article <3906F0B7.818D9BF1@bigfoot.com>:
> Is this a bug in Unicode support in 5.6.0 or is my expectation
> incorrect? With the following test script:
>
> <CODE>
> use utf8;
>
> $x = "This contains \x{A7} a unicode char.";
>
> ($b, $a) = split(/\x{A7}/, $x);
> print "\$before: .$b.\n";
> print "\$after: .$a.\n";
>
> ($b, $a) = $x =~ /^(.+)\x{A7}(.+)$/;
> print "\$before: .$b.\n";
> print "\$after: .$a.\n";
> </CODE>
>
> I would expect the split() and the m// to have the same result, but they
> don't:
>
> $before: .This contains .
> $after: .§ a unicode char..
> $before: .This contains .
> $after: . a unicode char..
>
> Is this a known bug? Am I wrong in expecting split() to return the same
> result as m//?
I Cc it to perlbug. As far as I can guess, this is a runaway
optimization in split() when the REx is a constant string.
Ilya
------------------------------
Date: Wed, 26 Apr 2000 18:16:53 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: [REGEXP] Extremely important please read!
Message-Id: <sgecklb0qtj32@corp.supernews.com>
Charles Henry (charles.henry@engineer2k.com) wrote:
First, on your subject line: "Extremely important" to you, quite
possibly. But we have no way of ranking your 'importance' against all the
other posters who don't mention how critical their needs are, or for that
matter against those who claim "ULTIMATE LIFE-OR-DEATH IMPORTANCE - FATE
OF EARTH HANGS IN BALANCE" in *their* subject lines. In fact, many
experienced readers of this group will not see your post at all if you use
words and phrases like 'extremely', 'important', and 'please read' in your
subject line.
Choose a subject line which succinctly describes what you need. In your
case, an example might be "Extract domain name from URL?" or the
like.
: I am trying to extract the domain name off a url using Perl's
: implementation of RegEp.
:
: Here is what I did :
:
: $url =~s!http://([^/]+).*!$1!;
: $url =~m!([^\.]+\.[^\.]+)$!;
:
: It just works but it's not very clever obviously.
:
: Does anyone know how to do that effectively?
We know in any well-formed http url that the domain part will be the
first pair of strings matching [-A-Za-z0-9] separated by a . and followed
by a / or the end of the string. How about:
($domain) = $url =~ m!([-A-Za-z0-9]+\.[-A-Za-z0-9]+)(?:/|$)!;
Beware of using this for international TLDs and the like, since these can
give different meanings to the top and second level domains.
--
| Craig Berry - cberry@cinenet.net
--*-- http://www.cinenet.net/users/cberry/home.html
| "The road of Excess leads to the Palace
of Wisdom" - William Blake
------------------------------
Date: Wed, 26 Apr 2000 11:37:17 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: [REGEXP] Extremely important please read!
Message-Id: <MPG.1370d73367f893b698a989@nntp.hpl.hp.com>
In article <8e787o$hp8$1@brokaw.wa.com> on Wed, 26 Apr 2000 10:15:10 -
0700, Lauren Smith <lauren_smith13@hotmail.com> says...
> Charles Henry <charles.henry@engineer2k.com> wrote in message
> news:8e76ie$l30$1@reader1.fr.uu.net...
...
> > For example the regep should extract the string "domain.com" off the
> > following patterns :
...
> > http://www.domain.com
> > http://www.domain.com/
> > http://www.domain.com/abc
> > http://www.domain.com/a/abc.html
> > http://a.b.c.www.domain.com
> > http://a.b.c.www.domain.com/
> > http://a.b.c.www.domain.com/abc
>
> $domain = $1 if ($url =~ /\.([^.]*.\.com)/);
Why go to all that trouble? Just the following would do:
$domain = 'domain.com';
Your regex fails to produce the two highest-level domains on
'http://www.domain.org', and it yields the incorrect result 'foo.com' on
'http://www.foo.comdex.domain.com'. But it does produce 'domain.com' on
all the sample data provided, which is why I like my proposed solution
above better -- it does that also, with less effort.
I gave a useful regex in my previous post:
m!([^./]+\.[^./]+)(?:/|$)!
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 26 Apr 2000 13:41:35 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: [REGEXP] Extremely important please read!
Message-Id: <slrn8geaif.882.tadmc@magna.metronet.com>
On Wed, 26 Apr 2000 10:15:10 -0700, Lauren Smith <lauren_smith13@hotmail.com> wrote:
>> Re: [REGEXP] Extremely important please read!
>
>Well, that's not a very helpful title, now is it?
It is actually *anti*helpful.
I was poised to type in a helpful reply, until I
noticed the pleading.
Pleading in Subject lines has the *opposite* effect from
what most posters are trying to achieve.
Even the (still poor) Subject: REGEXP
would have been better than the original Subject.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 26 Apr 2000 21:18:01 +0200
From: "Charles Henry" <charles.henry@engineer2k.com>
Subject: Re: [REGEXP] Extremely important please read!
Message-Id: <8e7foo$15kf$1@news5.isdnet.net>
First of all I want to say a big THANK YOU to everyone who helped!! You
really are great guys!
> m!([^./]+\.[^./]+)(?:/|$)! and print "$1\n" for qw(
> http://www.domain.com
> http://www.domain.com/
> http://www.domain.com/abc
> http://www.domain.com/a/abc.html
> http://a.b.c.www.domain.com
> http://a.b.c.www.domain.com/
> http://a.b.c.www.domain.com/abc
> );
Didn't you mean :
m!([^\./]+\.[^\./]+)(?:/|$)!
rather than :
m!([^./]+\.[^./]+)(?:/|$)!
> You have a strange view of what gets people's help from Usenet. A
> subject that pleads importance to you doesn't change a thing.
> Everything is important to the person who submits it.
That is from your point of view, which you are untitled to. But personally,
I am more interested in helping a desperate person than anyone else. Maybe
it's a bad behaviour and I shouldn't act likewise but I'm just like that ...
> Capital letters don't help either. In fact, had you no lower-case
> letters, some people's software would have filtered your post away
> automatically.
That was done on purpose. I never type all caps so as not to be filtered.
> But I answered you anyway, despite the provocation. :-)
I am extremely greatful to you and everyone one else who helped! You are
extremely genererous guys and I mean it! Thanks to you my project is not
stalled anymore! I have some more monster regexps to type but thanks to your
answers, I now know which logic is to be used.
A great day to all of you!
--
Charles Henry
------------------------------
Date: Wed, 26 Apr 2000 13:05:07 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: [REGEXP] Extremely important please read!
Message-Id: <8e7i6b$mkb$1@brokaw.wa.com>
Charles Henry <charles.henry@engineer2k.com> wrote in message
news:8e7foo$15kf$1@news5.isdnet.net...
> Didn't you mean :
> m!([^\./]+\.[^\./]+)(?:/|$)!
> rather than :
> m!([^./]+\.[^./]+)(?:/|$)!
Without necessarily speaking for Larry, I'd have to venture that he didn't
slash those 'dots' because they are not special inside of character classes.
The 'dot' in this regex:
/[.]/
is not the same as the one in this regex:
/./
Lauren
------------------------------
Date: Wed, 26 Apr 2000 22:10:09 +0200
From: "Charles Henry" <charles.henry@engineer2k.com>
Subject: Re: [REGEXP] Extremely important please read!
Message-Id: <8e7iqk$g7a$1@news2.isdnet.net>
> The 'dot' in this regex:
>
> /[.]/
>
> is not the same as the one in this regex:
>
> /./
Darn that's pretty obfuscating :(
It would've been so much simpler/readable to keep the same meaning for 'dot'
inside a regexp.
--
Charles Henry
------------------------------
Date: Wed, 26 Apr 2000 13:31:28 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: [REGEXP] Extremely important please read!
Message-Id: <MPG.1370f1ff33d4d4d698a98f@nntp.hpl.hp.com>
In article <8e7foo$15kf$1@news5.isdnet.net> on Wed, 26 Apr 2000 21:18:01
+0200, Charles Henry <charles.henry@engineer2k.com> says...
> First of all I want to say a big THANK YOU to everyone who helped!! You
> really are great guys!
You're welcome, provided that 'guys' is understood as gender-inclusive.
> > m!([^./]+\.[^./]+)(?:/|$)! and print "$1\n" for qw(
> > http://www.domain.com
> > http://www.domain.com/
> > http://www.domain.com/abc
> > http://www.domain.com/a/abc.html
> > http://a.b.c.www.domain.com
> > http://a.b.c.www.domain.com/
> > http://a.b.c.www.domain.com/abc
> > );
>
> Didn't you mean :
> m!([^\./]+\.[^\./]+)(?:/|$)!
> rather than :
> m!([^./]+\.[^./]+)(?:/|$)!
I meant exactly what I wrote (and tested, of course). Your way is
correct too, but unnecessarily verbose. As described in perlre, within
a character class these are the only metacharacters (characters that
must be escaped to retain their literal significance):
\ anywhere
^ in the first character position
] except in the first character position (with optional ^ ahead)
- except in the first character position (with optional ^ ahead)
or in the last character position
$ or @ if followed by what might be an interpolation.
> > You have a strange view of what gets people's help from Usenet. A
> > subject that pleads importance to you doesn't change a thing.
> > Everything is important to the person who submits it.
>
> That is from your point of view, which you are untitled to. But personally,
> I am more interested in helping a desperate person than anyone else. Maybe
> it's a bad behaviour and I shouldn't act likewise but I'm just like that ...
I am interested in helping a gracious person who seems to have invested
some effort to help himself or herslef before posting.
> > Capital letters don't help either. In fact, had you no lower-case
> > letters, some people's software would have filtered your post away
> > automatically.
>
> That was done on purpose. I never type all caps so as not to be filtered.
So you do know what works and what doesn't work. :-)
> > But I answered you anyway, despite the provocation. :-)
>
> I am extremely greatful to you and everyone one else who helped! You are
> extremely genererous guys and I mean it! Thanks to you my project is not
> stalled anymore! I have some more monster regexps to type but thanks to your
> answers, I now know which logic is to be used.
>
> A great day to all of you!
And you certainly seem to be gracious. Glad to help.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 26 Apr 2000 15:29:48 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: [REGEXP] Extremely important please read!
Message-Id: <390751BC.A5B6E0AB@home.com>
Charles Henry wrote:
>
> Didn't you mean :
> m!([^\./]+\.[^\./]+)(?:/|$)!
> rather than :
> m!([^./]+\.[^./]+)(?:/|$)!
I'm sure he didn't. Inside a character class, '.' is just a period, not
'any char [other than newline unless /s is used].'
> > You have a strange view of what gets people's help from Usenet. A
> > subject that pleads importance to you doesn't change a thing.
> > Everything is important to the person who submits it.
>
> That is from your point of view, which you are untitled to.
^^
Interesting Freudian slip? ;-)
-mjc
------------------------------
Date: 26 Apr 2000 21:57:33 GMT
From: Ying-Hao Chang <aqlott@db.csie.ncu.edu.tw>
Subject: about perlxs
Message-Id: <8e7ood$lo4$1@db.csie.ncu.edu.tw>
Hello there,
Recently I was porting a c library for its perl interface with perlxs.
is there any possibility for perlxs to execute a perl subroutine in
the c api? that is, say, I have a c function named exec_me (a, b)
where a is a pointer to the function I'd like to execute, and b is the
parameter. Can I just straightly execute it in perl like this:
mymodule::exec_me (*mysub, $myparam)? will perlxs translate it auto-
matically for me?
Thanks for your response..
--
Moment went by, under the sea, dozens of roses bloomed _____ _____
---------------------------------------------------------- | \| _ \
R3-207, Database Lab, Inst of CSIE, NCU, Taiwan, R.O.C | | | _ <
Earving H. Chang (886) 3-4227151 ext 4693 |_____/|_____/
------------------------------
Date: Wed, 26 Apr 2000 15:52:15 -0500
From: Chris Covington <ccoving@uhc.com>
Subject: AIX perl 5.6 compile
Message-Id: <390756FF.B78971AA@uhc.com>
I am trying to compile perl5.6 on AIX 4.3 using gcc. I get an error
after configuration, a while into the "make":
ld: 0706-005 Cannot find or open file: libgcc.a
ld:open(): A file or directory in the path name does not exist.
gcc: file path prefix `/usr/local/lib/gcc-lib/32/egcs-2.91.66/'
never used
make: 1254-004 The error code from the last command is 1.
I am not an expert at compiling, hopefully this is trivially fixed.
Thanks in advance,
Chris
P.S. Unrelated info: The line "#include <time.h>" needed to be inserted
near the top of pp_sys.c in order for me to get this far.
--
Chris Covington, UnitedHealth Group, ccoving@uhc.com
------------------------------
Date: Wed, 26 Apr 2000 20:00:06 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: calling a cgi
Message-Id: <Pine.GHP.4.21.0004261936280.10315-100000@hpplus01.cern.ch>
I'm adjusting the arrow of time so that cause precedes effect, as
in the real world...
On Wed, 26 Apr 2000, Sid Mal wrote:
> morlou@my-deja.com wrote:
> > Exactly, I have an HTML form which has a POST action calling xxx.cgi,
> > then in xxx.cgi I'd like to call yyy.cgi with a parameter which is the
> > content of the buffer (Content of the HTML form).
You ought to be more precise than this. If yyy.cgi is a CGI script,
as its name implies, then it expects to be called in the CGI
environment, to receive properly formatted QUERY_STRING parameters and
to return proper headers. But if xxx.cgi is a CGI script too, then it
will already be returning its proper headers. So we would have to
understand what it is you really want when you say you want xxx.cgi
"to call" yyy.cgi.
> > This way, yyy.cgi
> > could process the information that is coming from the form... Somebody
> > knows how to do it???
This is a CGI issue and not a Perl issue. You really should be on the
comp.infosystems.www.authoring.cgi group. If your transaction is
non-idempotent, then you should not be wanting to do the
non-idempotent work via a GET transaction - this is fundamentally
broken in WWW terms.
As I recently discovered for myself, the popular browsers still have
not caught up with Lynx in the matter of handling a status 307
redirection in response to POST. (Any interested perlers are invited
to comment on my draft at
http://ppewww.ph.gla.ac.uk/~flavell/www/post-redirect.html , with
apologies for the off-topicness).
To come back to the actual question - I think this is another of those
"XY" questions, in which you have a problem X which you suppose could
best be addressed with Y, you're having difficulty with Y - but you
haven't told us what X is so that someone can suggest a more
appropriate approach to the whole problem.
> You could also try redirecting the browser.
If status 302 is acceptable then I agree, it does seem to be one
possible way of addressing what the user actually asked for; but
I'd still call attention to that idempotence principle.
> print "Location: http://www.domain.com/script.cgi?one=$in{'one'}\n\n";
What's that supposed to do?
The "content of the buffer" is presumably referring to the URLencoded
query (that was contained on stdin in their POST transaction), which
might be something like say:
foo=bar&curr=%A3&zoom=50%25
The questioner seems to be saying they want this fed to their second
script too.
If the questioner hasn't already worked out what they want to do, I'd
suggest re-formulating the question accordingly, on the CGI authoring
group.
good luck
------------------------------
Date: 26 Apr 2000 19:44:20 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: confused by full package name and warning
Message-Id: <8e7de4$9r3$1@orpheus.gellyfish.com>
On 5 Apr 2000 00:32:50 GMT lee.lindley@bigfoot.com wrote:
> Tom Phoenix <rootbeer@redcat.com> wrote:
> :>...or even to mention the variable an extra time in your main code:
>
> :> # Mentioning these variables merely to quiet the
> :> # 'used only once' warning
> :> () = ($fred::barney, $main::foo);
>
> :>...but that last is an ugly kludge, imho. Hope this helps!
>
> But it really isn't any uglier than doing a cast in C to shut up the
> compiler even though you know the right thing will happen
> automatically with the implicit cast. I do whatever I have to do to
> shut up the compiler so that it is easy to see when the compiler
> really is telling me about a legitimate problem.
Its strange going through the backlog of messages I have had over the
last two weeks that I should stumble upon this as I was just thinking
to myself 'Why is it that I always explicitly cast the pointer returns
from functions in C ?' - Pure superstition in most cases I would say ;-}
/j\
--
Well, you can't go wrong with cocktail weenies. They taste as good as they
look. And they come in this delicious red sauce. It looks like catsup-
it tastes like catsup. But brother, it ain't catsup!
--
fortune oscar homer
------------------------------
Date: Wed, 26 Apr 2000 15:01:42 -0400
From: "David Stiff" <dstiff@delanotech.com>
Subject: DLL attributes
Message-Id: <v2HN4.1159$pb6.1392@client>
Is there a way in Perl I can get the Company Name of a DLL? (The equivalent
of checking the Properties of the DLL in Windows).
Thanks.
------------------------------
Date: Wed, 26 Apr 2000 14:13:23 -0500
From: mitiste@charlie.iit.edu
Subject: Re: Extracting part of a string
Message-Id: <lqfegs06g48evsk7v47pvm5acin1q9l8to@4ax.com>
On Wed, 19 Apr 2000 00:06:55 -0500, Dan Olson
<theoddone@quakefiles.com> wrote:
<snip>
>> perldoc perlre
>> perldoc -f substr
>I had a similar problem. I added these two lines into my perl program,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>but they only generated errors. What am I doing wrong?
^^^^^^^^^^^^^^^^^^^^^^^^^ !!!
This is by far the BEST comment I read in this newsgroup :-)
------------------------------
Date: Wed, 26 Apr 2000 22:58:22 +0200
From: "[@@]~" <a@b.com>
Subject: form to email
Message-Id: <8e7okk$8nsgq$1@fu-berlin.de>
Anyone point me in the right direction to a free form to email script?
--
|\/\/\/\/|
| |
| (o)(o)
=========OOOO==========OOOO==--------------------------------------------
------------------------------
Date: Thu, 27 Apr 2000 01:02:36 +0400
From: "Quaid Joher" <yaqoota@emirates.net.ae>
Subject: freetype-1.3.1
Message-Id: <8e7lcs$6b63@news.emirates.net.ae>
While installing freetype-1.3.1 module I came accross an unknown error
message (atleast to me) that I have noted below. This message poped up when
I typed 'make' after configuring the module.
As I am setting up this program in my home directory, I used following
command for configure;
./configure --prefix=/usr/www/techno (my home path)
On typing 'make' following message followed;
...
*** Warning: inter-library dependencies are not known to be supported.
*** All declared inter-library dependencies are being dropped.
*** The inter-library dependencies that have been dropped here will be
*** automatically added whenever a program is linked with this library
*** or is declared to -dlopen it.
...
error code 1
Can you see where things have gone wrong
Thanks
QUAID
------------------------------
Date: Wed, 26 Apr 2000 13:13:04 -0600
From: "Dave Klingler" <davidk@excitehome.net>
Subject: Help with Linux & Perl command line
Message-Id: <8e7f42$rkn$1@news.NERO.NET>
I am trying to figure out how to write a one line Perl script which will
loop until a file is present on the system. I don't know enough about Perl
to know how to write this line. Does anyone have any ideas?
Thanks in advance,
Dave
------------------------------
Date: Wed, 26 Apr 2000 12:19:05 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Help with Linux & Perl command line
Message-Id: <Pine.GSO.4.10.10004261217370.25963-100000@user2.teleport.com>
On Wed, 26 Apr 2000, Dave Klingler wrote:
> I am trying to figure out how to write a one line Perl script which will
> loop until a file is present on the system. I don't know enough about Perl
> to know how to write this line. Does anyone have any ideas?
Learn more about perl until you know enough to be able to write this line.
:-)
But consider using sleep and one of the -X filetests. They're both
documented in the perlfunc manpage. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 26 Apr 2000 13:00:16 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Help with Linux & Perl command line
Message-Id: <MPG.1370eaa876a652b098a98d@nntp.hpl.hp.com>
In article <8e7f42$rkn$1@news.NERO.NET> on Wed, 26 Apr 2000 13:13:04 -
0600, Dave Klingler <davidk@excitehome.net> says...
> I am trying to figure out how to write a one line Perl script which will
> loop until a file is present on the system. I don't know enough about Perl
> to know how to write this line. Does anyone have any ideas?
UNTESTED (of course). Note that the two '-e's have nothing to do with
each other:
perl -e '1 until -e /whatever/file'
But what a resource hog that is. You might do it every so often:
perl -e 'sleep 1 until -e /whatever/file'
For intervals shorter than one second, look at the four-argument
select() function in perlfunc.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 26 Apr 2000 14:52:06 -0600
From: "Dave Klingler" <davidk@excitehome.net>
Subject: Re: Help with Linux & Perl command line
Message-Id: <8e7ktn$bc$1@news.NERO.NET>
That was the idea I needed. This is how I got it to work:
perl -e 'while (!(-e \"$storeid$extension\")){}'
Thank you to everyone for helping me out on this so quickly.
Larry Rosler <lr@hpl.hp.com> wrote in message
news:MPG.1370eaa876a652b098a98d@nntp.hpl.hp.com...
> In article <8e7f42$rkn$1@news.NERO.NET> on Wed, 26 Apr 2000 13:13:04 -
> 0600, Dave Klingler <davidk@excitehome.net> says...
> > I am trying to figure out how to write a one line Perl script which will
> > loop until a file is present on the system. I don't know enough about
Perl
> > to know how to write this line. Does anyone have any ideas?
>
> UNTESTED (of course). Note that the two '-e's have nothing to do with
> each other:
>
> perl -e '1 until -e /whatever/file'
>
> But what a resource hog that is. You might do it every so often:
>
> perl -e 'sleep 1 until -e /whatever/file'
>
> For intervals shorter than one second, look at the four-argument
> select() function in perlfunc.
>
> --
> (Just Another Larry) Rosler
> Hewlett-Packard Laboratories
> http://www.hpl.hp.com/personal/Larry_Rosler/
> lr@hpl.hp.com
------------------------------
Date: Wed, 26 Apr 2000 16:10:52 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Help with Linux & Perl command line
Message-Id: <slrn8gejac.8k1.tadmc@magna.metronet.com>
On Wed, 26 Apr 2000 13:13:04 -0600, Dave Klingler <davidk@excitehome.net> wrote:
>I am trying to figure out how to write a one line Perl script which will
>loop until a file is present on the system. I don't know enough about Perl
>to know how to write this line. Does anyone have any ideas?
perl -we '1 until -e "some.file"'
For more info, type:
perldoc -f -X
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 26 Apr 2000 14:05:21 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: inserting $line into the middle of a list...
Message-Id: <slrn8gebv1.882.tadmc@magna.metronet.com>
On Wed, 26 Apr 2000 18:05:26 +0100, Kourosh A Mojar <kmojar@bmjgroup.com> wrote:
>I am a novice perl programmer. I have a few scripts that read in and
>modify text files (SGML). In this particular script I want to insert all
>lines from a second file into the middle of the original file.
So you have already seen the applicable FAQ then?
Perl FAQ, part 5:
"How do I change one line in a file/
delete a line in a file/
insert a line in the middle of a file/
append to the beginning of a file?"
>My script
>works by reading in each line from original file into a list (@lines).
But it doesn't have to do it that way.
Slurping the whole file into a single scalar is "better"
(for some definitions of "better").
>foreach $line (@lines) {
You should have the "use strict;" pragma (compiler directive)
enabled.
You should also have warnings (-w) enabled.
These two things will catch many common mistakes for you.
Take all of the help that you can get.
With "use strict", you would need to change the line above:
foreach my $line (@lines) {
> foreach ($line =~ "</TABLEDATA>") {
This one is pretty strange.
It has a "simple strange":
letting Perl DWIM a string into a pattern match is bad for maintenance.
Just use an alternate delimiter to avoid backslashing the slash:
$line =~ m#</TABLEDATA>#
Or, be obvious with your pattern matching and backslash the slash:
$line =~ /<\/TABLEDATA>/
It also has a "really strange strange":
foreach() takes a list.
do you know what $line =~ "</TABLEDATA>" does in
a list context?
That loop isn't going to loop very many times (it will loop
zero or one times).
I think you want a conditional test (if) there instead of
a looping construct (foreach).
> open (TABLE_IN, $TABLEFILE) || die "Can't open $TABLEFILE.";
> @table_lines = <TABLE_IN>; # slurp file into array
> close (TABLE_IN); # close file now all lines in list
> foreach $table_line (@table_lines) {
> #?! insert $table_line into @lines list #?!
> }
>
>I know that "push (@lines, $table_line);" adds the $table_line's at the
>end of the array but don't know how to insert in the middle
perldoc -f splice
>while the
>loop is looking at the "$line =~ "</TABLEDATA>"".
So you are *guaranteed* that there is only one "</TABLEDATA>"
in the file then?
>If anyone can understand my problem and might be able to help me I would
>appreciate it ever so much. Thanking you in advance and for your kind
>attention.
#UNTESTED
{
local $/; # enable slurp mode (see perlvar.pod)
open (TABLE_IN, $tablefile) || die "Can't open '$tablefile' $!";
$entire_table = <TABLE_IN>;
close(TABLE_IN);
local $^I = '.bak'; # enable in-place editing (see perlvar.pod/perlrun.pod)
local(@ARGV) = qw/ mainfile.sgml /;
while (<>) {
print;
print $entire_table if m#</TABLEDATA>#;
}
}
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 26 Apr 2000 12:06:14 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: inserting $line into the middle of a list...
Message-Id: <MPG.1370ddfe8ca98b3f98a98b@nntp.hpl.hp.com>
In article <390721D6.56668298@bmjgroup.com> on Wed, 26 Apr 2000 18:05:26
+0100, Kourosh A Mojar <kmojar@bmjgroup.com> says...
...
> ... In this particular script I want to insert all
> lines from a second file into the middle of the original file. My script
> works by reading in each line from original file into a list (@lines).
>
> foreach $line (@lines) {
> foreach ($line =~ "</TABLEDATA>") {
I guess that 'foreach' is supposed to be 'if'. How odd!
> open (TABLE_IN, $TABLEFILE) || die "Can't open $TABLEFILE.";
> @table_lines = <TABLE_IN>; # slurp file into array
> close (TABLE_IN); # close file now all lines in list
You are reading the same file into the array @table_lines on every pass
through a loop. Why not read it once, ahead of the loop, and conserve
the universe's limited supply of resources?
> foreach $table_line (@table_lines) {
> #?! insert $table_line into @lines list #?!
> }
>
> I know that "push (@lines, $table_line);" adds the $table_line's at the
> end of the array but don't know how to insert in the middle while the
> loop is looking at the "$line =~ "</TABLEDATA>"".
Lauren Smith suggested splice(), but that requires knowledge of the
index at which to splice, which your program doesn't keep track of.
Also, I don't like modifying an array that is being looped over, even
though it may work.
> If anyone can understand my problem and might be able to help me I would
> appreciate it ever so much. Thanking you in advance and for your kind
> attention.
Who could resist such a pleasant request?
I would take a different approach. The function map() takes as input
one list and produces as output a second list, based on code that is
executed element-by-element on the input list. This seems like the
perfect approach to your problem. Here's a try (assuming you want to
insert ahead of each of the matched lines):
@lines = map { m!</TABLEDATA>! ? @table_lines : (), $_ } @lines;
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 26 Apr 2000 12:48:31 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: inserting $line into the middle of a list...
Message-Id: <MPG.1370e7e5464f6cdf98a98c@nntp.hpl.hp.com>
In article <slrn8gebv1.882.tadmc@magna.metronet.com> on Wed, 26 Apr 2000
14:05:21 -0400, Tad McClellan <tadmc@metronet.com> says...
...
> #UNTESTED
And maybe UNREAD also. :-)
> {
> local $/; # enable slurp mode (see perlvar.pod)
> open (TABLE_IN, $tablefile) || die "Can't open '$tablefile' $!";
> $entire_table = <TABLE_IN>;
> close(TABLE_IN);
}
{
> local $^I = '.bak'; # enable in-place editing (see perlvar.pod/perlrun.pod)
> local(@ARGV) = qw/ mainfile.sgml /;
You're still in slurp mode, unless you insert the brackets shown above.
And then you'll have to declare $entire_table ahead of the first block.
> while (<>) {
> print;
> print $entire_table if m#</TABLEDATA>#;
My guess is to print the table ahead of the terminating tag, nod after
it.
> }
> }
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 26 Apr 2000 21:30:23 GMT
From: "Marcus" <mouimet@direct.ca>
Subject: Installing Perl
Message-Id: <PdJN4.178108$Dv1.2147315@news1.rdc1.bc.home.com>
I have a dedicated server with Red Hat Linux 6.1 and I need to install
perl to work with my /home/httpd/cgi-bin directory. I have no idea where to
start.... Is perl a free program? I have only previously edited scripts and
uploaded them to a cgi-bin. Any help would be very appreciated.
------------------------------
Date: Wed, 26 Apr 2000 14:36:51 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: Installing Perl
Message-Id: <8e7nic$qbe$1@brokaw.wa.com>
Marcus <mouimet@direct.ca> wrote in message
news:PdJN4.178108$Dv1.2147315@news1.rdc1.bc.home.com...
> I have a dedicated server with Red Hat Linux 6.1 and I need to install
> perl to work with my /home/httpd/cgi-bin directory. I have no idea where
to
> start.... Is perl a free program? I have only previously edited scripts
and
> uploaded them to a cgi-bin. Any help would be very appreciated.
You made it to comp.lang.perl.misc. Did you think that www.perl.com
wouldn't work?
Lauren
------------------------------
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 2871
**************************************