[16884] in Perl-Users-Digest
Perl-Users Digest, Issue: 4296 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 12 11:07:19 2000
Date: Tue, 12 Sep 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: <968771111-v9-i4296@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 12 Sep 2000 Volume: 9 Number: 4296
Today's topics:
[ANNOUNCE] XML::XPath 1.0 <matt@sergeant.org>
Re: avoiding do {} while() <gopalan@cs.sc.edu>
Re: avoiding do {} while() <peter@wastholm.com>
CHMOD Help <Parrott@UGSolutions.com>
Re: CHMOD Help <Peter.Dintelmann@dresdner-bank.com>
Re: CHMOD Help huw_watkins@my-deja.com
Re: CHMOD Help (Randal L. Schwartz)
Compiling cgi scripts <BennyS@GuruNet.com>
DBM file build in perl blows chunks philip@tildesoftware.com
Eliminate Duplicates shollins@my-deja.com
executing pg_dump from a cgi <scottdellar@hotmail.com>
Re: Incremental HTML output as script is running <bart.lateur@skynet.be>
min function <Ribordy_Shawn_C@cat.com>
Re: min function (Tom Christiansen)
Re: min function <jeffp@crusoe.net>
Re: min function <Ribordy_Shawn_C@cat.com>
Re: min function (Randal L. Schwartz)
Re: min function (Tom Christiansen)
Re: Not matching regex strings <nomail@hursley.ibm.com>
Re: Not matching regex strings <tina@streetmail.com>
Re: Perl and System Environment Variables lim_k@my-deja.com
Re: Perl substraction weird result <colapso@usa.net>
Re: Perl substraction weird result (Gwyn Judd)
Re: Perl substraction weird result (Tom Christiansen)
Re: Perl substraction weird result (Gwyn Judd)
Re: Prune doesn't work in find brianr@liffe.com
Re: Resolving IP's Q: Does this IP actually exist? <garry@zvolve.com>
Re: Resolving IP's Q: Does this IP actually exist? (David Wall)
Script To automate ftp uploading <moshe@u4all.com>
Re: Script To automate ftp uploading (Cameron Laird)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 12 Sep 2000 11:21:38 +0100
From: Matt Sergeant <matt@sergeant.org>
Subject: [ANNOUNCE] XML::XPath 1.0
Message-Id: <srscqn8qct696@corp.supernews.com>
Changes in this release:
- Major cleanup of some parts of the code to remove memory leaks.
- Implement getAttribute/setAttribute as per the DOM spec.
README follows:
NAME
XML::XPath - a set of modules for parsing and evaluating XPath
statements
DESCRIPTION
This module aims to comply exactly to the XPath specification at
http://www.w3.org/TR/xpath and yet allow extensions to be added
in the form of functions. Modules such as XSLT and XPointer may
need to do this as they support functionality beyond XPath.
SYNOPSIS
use XML::XPath;
use XML::XPath::XMLParser;
my $xp = XML::XPath->new(filename => 'test.xhtml');
my $nodeset = $xp->find('/html/body/p'); # find all paragraphs
foreach my $node ($nodeset->get_nodelist) {
print "FOUND\n\n",
XML::XPath::XMLParser::as_string($node),
"\n\n";
}
DETAILS
There's an awful lot to all of this, so bear with it - if you
stick it out it should be worth it. Please get a good
understanding of XPath by reading the spec before asking me
questions. All of the classes and parts herein are named to be
synonimous with the names in the specification, so consult that
if you don't understand why I'm doing something in the code.
API
The API of XML::XPath itself is extremely simple to allow you to
get going almost immediately. The deeper API's are more complex,
but you shouldn't have to touch most of that.
new()
This constructor follows the often seen named parameter method
call. Parameters you can use are: filename, parser, xml, ioref
and context. The filename parameter specifies an XML file to
parse. The xml parameter specifies a string to parse, and the
ioref parameter specifies an ioref to parse. The context option
allows you to specify a context node. The context node has to be
in the format of a node as specified in the
XML::XPath::XMLParser manpage. The 4 parameters filename, xml,
ioref and context are mutually exclusive - you should only
specify one (if you specify anything other than context, the
context node is the root of your document). The parser option
allows you to pass in an already prepared XML::Parser object, to
save you having to create more than one in your application (if,
for example, you're doing more than just XPath).
my $xp = XML::XPath->new( context => $node );
It is very much recommended that you use only 1 XPath object
throughout the life of your application. This is because the
object (and it's sub-objects) maintain certain bits of state
information that will be useful (such as XPath variables) to
later calls to find(). It's also a good idea because you'll use
less memory this way.
*nodeset* = find($path, [$context])
The find function takes an XPath expression (a string) and
returns either an XML::XPath::NodeSet object containing the
nodes it found (or empty if no nodes matched the path), or one
of XML::XPath::Literal (a string), XML::XPath::Number, or
XML::XPath::Boolean. It should always return something - and you
can use ->isa() to find out what it returned. If you need to
check how many nodes it found you should check $nodeset->size.
See the XML::XPath::NodeSet manpage. An optional second
parameter of a context node allows you to use this method
repeatedly, for example XSLT needs to do this.
findnodes($path, [$context])
Returns a list of nodes found by $path, optionally in context
$context. In scalar context returns an XML::XPath::NodeSet
object.
findnodes_as_string($path, [$context])
Returns the nodes found reproduced as XML. The result is not
guaranteed to be valid XML though.
findvalue($path, [$context])
Returns either a `XML::XPath::Literal', a `XML::XPath::Boolean'
or a `XML::XPath::Number' object. If the path returns a NodeSet,
$nodeset->to_literal is called automatically for you (and thus a
`XML::XPath::Literal' is returned). Note that for each of the
objects stringification is overloaded, so you can just print the
value found, or manipulate it in the ways you would a normal
perl value (e.g. using regular expressions).
matches($node, $path, [$context])
Returns true if the node matches the path (optionally in context
$context).
$XML::XPath::Namespaces
Set this to 0 if you *don't* want namespace processing to occur.
This will make everything a little (tiny) bit faster, but you'll
suffer for it, probably.
Node Object Model
See the XML::XPath::Node manpage, the XML::XPath::Node::Element
manpage, the XML::XPath::Node::Text manpage, the
XML::XPath::Node::Comment manpage, the
XML::XPath::Node::Attribute manpage, the
XML::XPath::Node::Namespace manpage, and the
XML::XPath::Node::PI manpage.
On Garbage Collection
XPath nodes work in a special way that allows circular
references, and yet still lets Perl's reference counting garbage
collector to clean up the nodes after use. This should be
totally transparent to the user, with one caveat: If you free
your tree before letting go of a sub-tree, consider that playing
with fire and you may get burned. What does this mean to the
average user? Not much. Provided you don't free (or let go out
of scope) either the tree you passed to XML::XPath->new, or if
you didn't pass a tree, and passed a filename or IO-ref, then
provided you don't let the XML::XPath object go out of scope
before you let results of find() and its friends go out of
scope, then you'll be fine. Even if you do let the tree go out
of scope before results, you'll probably still be fine. The only
case where you may get stung is when the last part of your
path/query is either an ancestor or parent axis. In that case
the worst that will happen is you'll end up with a circular
reference that won't get cleared until interpreter destruction
time. You can get around that by explicitly calling $node-
>DESTROY on each of your result nodes, if you really need to do
that.
Mail me direct if that's not clear. Note that it's not doom and
gloom. It's by no means perfect, but the worst that will happen
is a long running process could leak memory. Most long running
processes will therefore be able to explicitly be careful not to
free the tree (or XML::XPath object) before freeing results.
AxKit, an application that uses XML::XPath, does this and I
didn't have to make any changes to the code - it's already
sensible programming.
If you *really* don't want all this to happen, then set the
variable $XML::XPath::SafeMode, and call $xp->cleanup() on the
XML::XPath object when you're finished, or $tree->dispose() if
you have a tree instead.
Example
There are some complete XPath examples on
http://xml.sergeant.org/xpath.xml
Support/Author
This module is copyright 2000 Fastnet Software Ltd. This is free
software, and as such comes with NO WARRANTY. No dates are used
in this module. You may distribute this module under the terms
of either the Gnu GPL, or under specific licencing from Fastnet
Software Ltd. Special free licencing consideration will be given
to similarly free software. Please don't flame me for this
licence - I've put a lot of hours into this code, and if someone
uses my software in their product I expect them to have the
courtesy to contact me first.
Full support for this module is available from Fastnet Software
Ltd on a pay per incident basis. Alternatively subscribe to the
Perl-XML mailing list by mailing lyris@activestate.com with the
text:
SUBSCRIBE Perl-XML
in the body of the message. There are lots of friendly people on
the list, including myself, and we'll be glad to get you
started.
Matt Sergeant, matt@sergeant.org
SEE ALSO
the XML::XPath::Literal manpage, the XML::XPath::Boolean
manpage, the XML::XPath::Number manpage, the
XML::XPath::XMLParser manpage, the XML::XPath::NodeSet manpage,
the XML::XPath::PerlSAX manpage, the XML::XPath::Builder
manpage.
--
<Matt/>
Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org | AxKit: http://axkit.org
------------------------------
Date: Tue, 12 Sep 2000 09:26:01 -0400
From: Gopi Sundaram <gopalan@cs.sc.edu>
Subject: Re: avoiding do {} while()
Message-Id: <Pine.OSF.4.21.0009120920240.4893-100000@pearl.cs.sc.edu>
On Mon, 11 Sep 2000, Larry Rosler wrote:
> In article <Pine.OSF.4.21.0009111718410.915-100000@onyx.cs.sc.edu> on
> Mon, 11 Sep 2000 17:26:04 -0400, Gopi Sundaram <gopalan@cs.sc.edu>
> says...
<snip>
> > do # Choose a file, making
> > { # sure that it is a
> > $index = rand ($#sigs + 1); # text file.
> > } while ( !defined $sigs[$index] || ! -T $sigs[$index] );
> ^^^^^^^^^^^^^^^^^^^^^^^^^^
> That seems unnecessary; all the elements of @sigs are defined.
It's a bit of legacy code that accidentally stayed in from when I was
trying to do the one-liner.
> First of all, as written, you have the possibity of an infinite
> loop if none of the files in the directory is a text file.
Didn't even think of that. Aah, the assumptions I make!
> my @sigs = grep -T, </path/to/files/*>;
> my $index = rand @sigs;
I looked at the perldoc for grep, and I couldn't find anything that
looks like the syntax you used above, except for this cryptic clue:
>>>In particular, it is not limited to using regular expressions.<<<
What other "features" does grep have?
> my @try = my @sigs = </path/to/files/*>;
> my $found;
> 1 while @try && ! -T ($found = splice @try, rand @try, 1);
> @try or die "All files tried!\n";
>
> The name of the desired file is in $found.
That was very educational. It took me a worthy while to understand
that. Just one question: is @sigs necessary? It doesn't seem to be
used anywhere.
Gopi.
--
Gopi Sundaram
gopi@cs.sc.edu
------------------------------
Date: Tue, 12 Sep 2000 14:28:08 GMT
From: Peter Wastholm <peter@wastholm.com>
Subject: Re: avoiding do {} while()
Message-Id: <39BE3CEC.A946B629@wastholm.com>
Gopi Sundaram wrote:
>
> > my @sigs = grep -T, </path/to/files/*>;
> > my $index = rand @sigs;
>
> I looked at the perldoc for grep, and I couldn't find anything that
> looks like the syntax you used above, except for this cryptic clue:
>
> >>>In particular, it is not limited to using regular expressions.<<<
grep can use anything that returns a true or false value. E.g.:
my @administrators = grep ($_->is_admin, @users);
/Peter
------------------------------------------------------------------------
Peter Wastholm Parkinson's First Law: Work expands to fill the time
peter@wastholm.com available. C. Northcote Parkinson
"Aphorisms Galore!" -- Feed Your Wit http://www.aphorismsgalore.com/
------------------------------
Date: Tue, 12 Sep 2000 12:42:35 +0100
From: "Neil Parrott" <Parrott@UGSolutions.com>
Subject: CHMOD Help
Message-Id: <39be163b@usenet.ugsolutions.com>
Hi,
I have a script that creates HTML files in a directory but I'm finding that
the permissions are wrong if I want to change them later.
Is it possible to put a command into the script to set the permissions of
the HTML file when it is created?
Neil
------------------------------
Date: Tue, 12 Sep 2000 14:26:30 +0200
From: "Dr. Peter Dintelmann" <Peter.Dintelmann@dresdner-bank.com>
Subject: Re: CHMOD Help
Message-Id: <8pl7d5$sl43@intranews.bank.dresdner.net>
Hi,
Neil Parrott schrieb in Nachricht <39be163b@usenet.ugsolutions.com>...
>Is it possible to put a command into the script to set the permissions
of
>the HTML file when it is created?
'perldoc -f sysopen' shows that sysopen() has this feature.
Have an additional look at umask().
Regards,
Peter Dintelmann
------------------------------
Date: Tue, 12 Sep 2000 13:18:57 GMT
From: huw_watkins@my-deja.com
Subject: Re: CHMOD Help
Message-Id: <8plafa$cbs$1@nnrp1.deja.com>
One way to do it - call chmod directly from your script:
`chmod $mask $myfile`; # where $mask is 666, or whatever you need
Huw Watkins
huw@sharpsoftware.co.uk
--
Learning Perl? http://perltutor.com
In article <39be163b@usenet.ugsolutions.com>,
"Neil Parrott" <Parrott@UGSolutions.com> wrote:
> Hi,
>
> I have a script that creates HTML files in a directory but I'm
finding that
> the permissions are wrong if I want to change them later.
>
> Is it possible to put a command into the script to set the
permissions of
> the HTML file when it is created?
>
> Neil
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 12 Sep 2000 07:33:49 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: CHMOD Help
Message-Id: <m1snr5ptma.fsf@halfdome.holdit.com>
>>>>> "huw" == huw watkins <huw_watkins@my-deja.com> writes:
huw> One way to do it - call chmod directly from your script:
huw> `chmod $mask $myfile`; # where $mask is 666, or whatever you need
Ouch! Why not call the perl built-in:
chmod $value, $myfile or warn "cannot chmod $value $myfile: $!";
More secure, faster, works on Windows, better error control, and you
aren't calling backquotes in a void context (considered bad form).
huw> Huw Watkins
huw> huw@sharpsoftware.co.uk
huw> --
huw> Learning Perl? http://perltutor.com
If that's what they teach you there, I don't think much of that site
now. In fact, I'd recommend people stay AWAY from it.
--
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: Tue, 12 Sep 2000 16:03:55 +0300
From: "Benny Siegelov" <BennyS@GuruNet.com>
Subject: Compiling cgi scripts
Message-Id: <39be2899$1@news.barak.net.il>
I can't compile any script makes use CGI; line
I have tried both backend and frontend(perlcc) compilers
It types "No definition for sub CGI::(all CGI modules sub names)"
Help me plz
------------------------------
Date: Tue, 12 Sep 2000 14:44:47 GMT
From: philip@tildesoftware.com
Subject: DBM file build in perl blows chunks
Message-Id: <8plfgo$ift$1@nnrp1.deja.com>
I'm getting the following error while building a DBM file with several
million records (3843131 to be exact).
+> ndbm store returned -1, errno 27, key "4789474235363013
22.00 999.00 210140
What does this error indicate? What would cause this? Has anyone else
run into this problem?
Here's an excerpt of the code that I'm using to build the file. The file
WAMU is a simple text file containing records with a single field (like
the key above).
...
dbmopen(%wamu, "/exports/wamu", 0666);
...
while (<WAMU>)
{
$wamu{$_}=$_;
}
...
Thanks for your input.
Please reply to philip@tildesoftware.com
Thanks!
PG..
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 12 Sep 2000 14:42:32 GMT
From: shollins@my-deja.com
Subject: Eliminate Duplicates
Message-Id: <8plfci$ids$1@nnrp1.deja.com>
I am writing a perl program that will convert a
text file into a .dbf file. However, there are
duplicate fields in the text file. How can a
eliminate duplicates and only pull in unique
fields?
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 12 Sep 2000 21:39:48 +1100
From: "Scott Dellar" <scottdellar@hotmail.com>
Subject: executing pg_dump from a cgi
Message-Id: <8pl15r$1h6$1@news.latrobe.edu.au>
Hey there all,
I am having trouble executing the 'pg_dump' utility from within a cgi.
The local server has Postgres 6.5.1 if that helps.
I have tried all manner of wrappers, exec, system, used setuid, and even
tried SSIs to do it, all to no effect.
I think something is strange, very strange about the way pg_dump works.
As an aside, I hope to use it in conjuction with the 'psql -e' option to
backup and restore the database from the web (so the user doesn't have to
get their hands dirty at the unix command line).
I may be able to supply more information, just ask...
Thanks,
Scott
------------------------------
Date: Tue, 12 Sep 2000 14:38:57 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Incremental HTML output as script is running
Message-Id: <otfsrsg4ekg3hgvl0vp3nt9j3emhh3lqlk@4ax.com>
Andy Flisher wrote:
>The script itself can take around two minutes to complete, and is
>initiated by the customer clicking a link from an HTML form.
>
>Because of the length of time the script takes I would like to output
>various status lines as HTML to keep the customer informed as to what
>stage the script is at.
<http://www.stonehenge.com/merlyn/WebTechniques/col20.html>
--
Bart.
------------------------------
Date: Tue, 12 Sep 2000 07:44:37 -0500
From: Shawn Ribordy <Ribordy_Shawn_C@cat.com>
Subject: min function
Message-Id: <39BE2535.5BF72AF3@cat.com>
I have looked all over the place, and I cannot find a min function. Can
anyone help?
Shawn
------------------------------
Date: 12 Sep 2000 07:16:45 -0700
From: tchrist@perl.com (Tom Christiansen)
Subject: Re: min function
Message-Id: <39be2cbd$1@cs.colorado.edu>
In article <39BE2535.5BF72AF3@cat.com>,
Shawn Ribordy <Ribordy_Shawn_C@cat.com> wrote:
>I have looked all over the place, and I cannot find a min function. Can
>anyone help?
Are you saying you don't know how to write one?
--tom
------------------------------
Date: Tue, 12 Sep 2000 09:24:14 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: min function
Message-Id: <Pine.GSO.4.21.0009120923030.12441-100000@crusoe.crusoe.net>
[posted & mailed]
On Sep 12, Shawn Ribordy said:
>I have looked all over the place, and I cannot find a min function. Can
>anyone help?
Do you know what the min() function would do? If you mean a function to
find the minimum of a list of numbers, you should be able to construct one
on your own. If I gave you a list of numbers,
4 0 21 3 -2 18
how would YOU determine the smallest? Write your function in the same
manner.
--
Jeff "japhy" Pinyan japhy@pobox.com http://www.pobox.com/~japhy/
PerlMonth - An Online Perl Magazine http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc. http://www.perlarchive.com/
CPAN - #1 Perl Resource (my id: PINYAN) http://search.cpan.org/
------------------------------
Date: Tue, 12 Sep 2000 08:39:42 -0500
From: Shawn Ribordy <Ribordy_Shawn_C@cat.com>
Subject: Re: min function
Message-Id: <39BE321E.5324273C@cat.com>
Tom Christiansen wrote:
> In article <39BE2535.5BF72AF3@cat.com>,
> Shawn Ribordy <Ribordy_Shawn_C@cat.com> wrote:
> >I have looked all over the place, and I cannot find a min function. Can
> >anyone help?
>
> Are you saying you don't know how to write one?
>
> --tom
Of course I could write one! - but why reinvent the wheel right! Isn't
laziness still a virtue of all programmers.
Thanks for the response - you answered my question.
Shawn
------------------------------
Date: 12 Sep 2000 07:30:37 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: min function
Message-Id: <m1zoldptrm.fsf@halfdome.holdit.com>
>>>>> "Jeff" == Jeff Pinyan <jeffp@crusoe.net> writes:
Jeff> Do you know what the min() function would do? If you mean a function to
Jeff> find the minimum of a list of numbers, you should be able to construct one
Jeff> on your own. If I gave you a list of numbers,
Jeff> 4 0 21 3 -2 18
Jeff> how would YOU determine the smallest? Write your function in the same
Jeff> manner.
(Fires up Squeak)
(open workspace)
{4. 0. 21. 3. -2. 18} min
(press command-P for "print it")
Ahh, it's -2
(ducking... :-)
--
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: 12 Sep 2000 08:59:31 -0700
From: tchrist@perl.com (Tom Christiansen)
Subject: Re: min function
Message-Id: <39be44d3$1@cs.colorado.edu>
In article <39BE321E.5324273C@cat.com>,
Shawn Ribordy <Ribordy_Shawn_C@cat.com> wrote:
>Of course I could write one! - but why reinvent the wheel right!
Reinvent what wheel? If this requires invention, you're working
far, far too hard. That's like asking whether someone knows how
to determine whether a number is odd, and not liking that there's
no plug-and-pray module to throw at it. Trivial problems should
not require canned, opaque solutions.
--tom
------------------------------
Date: Tue, 12 Sep 2000 11:05:43 +0100
From: Derek Fountain <nomail@hursley.ibm.com>
Subject: Re: Not matching regex strings
Message-Id: <39BDFFF7.BBEF5FAB@hursley.ibm.com>
> Perhaps you want
>
> /(?!<xyz)I-WANT-THIS(?!xyz)/
>
> That assumes that "xxyzI-WANT-THISxyzxxxxx" is also bad, and
> that "xyz I-WANT-THIS xyz" is good.
>
> This is the third time this month I've had this conversation. I
> wonder why it is that people asking this question (a) never provide a
> realistic example and (b) never say clearly what they want?
Thanks, that's just what I needed. In answer to your
wonderings:
a) The code I'm writing is looking for various types of
strings in HTML which are, or are not, surrounded by various
types of tags. Rather than explain that lot I thought I'd
give an example. Then found I couldn't think of a simple
one. :-)
b) I thought I did. You got the gist OK and supplied the
correct answer first time. I suppose the correct question
would be "how do I formulate a negative lookbehind
assertion?", but I didn't have a clue such a thing existed
until I followed up your post in the relevant documentation.
But thanks again. The code looks almost readable now. :)
------------------------------
Date: 12 Sep 2000 14:18:42 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: Not matching regex strings
Message-Id: <8ple02$dhnjb$2@ID-24002.news.cis.dfn.de>
hi,
In comp.lang.perl.misc Derek Fountain <nomail@hursley.ibm.com> wrote:
>> Perhaps you want
>>
>> /(?!<xyz)I-WANT-THIS(?!xyz)/
>>
>> That assumes that "xxyzI-WANT-THISxyzxxxxx" is also bad, and
>> that "xyz I-WANT-THIS xyz" is good.
>>
>> This is the third time this month I've had this conversation. I
>> wonder why it is that people asking this question (a) never provide a
>> realistic example and (b) never say clearly what they want?
> Thanks, that's just what I needed. In answer to your
10:18am tina@syracus:~/public_html/cgi-bin > perl -e'
$_ ="yoohooI-WANT-THISxyz";
print "not ok\n" unless /(?!<xyz)I-WANT-THIS(?!xyz)/'
not ok
so I thought the above string would be ok...
the solution contains two lookaheads but you need
one lookbehind and one lookahead.
tina
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \__,_\___/\___/_| /__/ perception
please don't email unless offtopic or followup is set. thanx
------------------------------
Date: Tue, 12 Sep 2000 13:18:19 GMT
From: lim_k@my-deja.com
Subject: Re: Perl and System Environment Variables
Message-Id: <8plae5$cbe$1@nnrp1.deja.com>
In article <MPG.14281bfcb296029598977b@localhost>,
jason <elephant@squirrelgroup.com> wrote:
> lim_k@my-deja.com <lim_k@my-deja.com> wrote ..
> >I know this question has been asked before, but I must have missed
the
> >posting. How would you pass system environment variables in a PERL
> >script for a cron'ed process?
>
> pass them to where ?
Pass them to the cron'ed account. Given that the cron'ed
process is running under no environment variables.
>
> >I have tried:
> >
> >$ENV{PATH} = "/yadda/yadda/yadda:/blah/blah/blah:";
> >
> >print "PATH=$ENV{PATH};
>
> this will not work because you are missing a double-quote .. but it
will
> work perfectly well if you add that back
my mistake in mistyping the print statement, it does have
double quotes.
>
> --
> jason -- elephant@squirrelgroup.com --
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 12 Sep 2000 12:43:26 +0200
From: COLAPSO <colapso@usa.net>
Subject: Re: Perl substraction weird result
Message-Id: <39BE08CE.E0989932@usa.net>
A little PERL code:
#!/usr/bin/perl
for($i=0;$i<=16;$i++){
$d=$i+0.4;
print ($d-$i ."\n");
}
the output is:
0.4
...
0.4
0.399999...
So, with number between 0.4 to 15.4 the operation is exact (That is a
byte.byte number,)
When the int part of the number is greater than 1 byte the representation
is not exact.
But PERL can "represent" 0.4 exactly. Number above 15.4 (I mean 16.4)
can't be exactly represented by PERL.
Sorry for my english and for your shock.
Edu
Gwyn Judd wrote:
> I was shocked! How could COLAPSO <colapso@usa.net>
> say such a terrible thing:
>
> >
> >So, is possible to represent 0.4 numbers. C do.
>
> No it doesn't. I suggest you read the documentation (start with "man 3
> printf". This is off topic anyway.
------------------------------
Date: Tue, 12 Sep 2000 12:34:56 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Perl substraction weird result
Message-Id: <slrn8rs8nc.c88.tjla@thislove.dyndns.org>
(rearranged for legibility).
COLAPSO if you can please reply to messages below the text you are
replying to (as I have), it makes the discussion a lot easier to follow
and understand.
I was shocked! How could COLAPSO <colapso@usa.net>
say such a terrible thing:
>Gwyn Judd wrote:
>
>> I was shocked! How could COLAPSO <colapso@usa.net>
>> say such a terrible thing:
>>
>> >
>> >So, is possible to represent 0.4 numbers. C do.
>>
>> No it doesn't. I suggest you read the documentation (start with "man 3
>> printf". This is off topic anyway.
Did you read the document? The bit where it talks about the %f format
string you may find edifying.
>A little PERL code:
>#!/usr/bin/perl
>
>for($i=0;$i<=16;$i++){
> $d=$i+0.4;
> print ($d-$i ."\n");
>}
>
>the output is:
>0.4
>...
>0.4
>0.399999...
>
>So, with number between 0.4 to 15.4 the operation is exact (That is a
>byte.byte number,)
You're just confusing yourself with science. In any number
representation there are certain numbers it is not possible to
represent with a finite number of digits, even if in other
representations it is possible. A prime example is "0.4" which can be
represented in base 10 quite easily but in binary it is an infinite
decimal expansion.
Given that it is not possible to represent "0.4" exactly, is it any
surprise that it is not possible to accurately do arithmetic with it?
You will get similar results no matter what language you use, ergo this
discussion is off-topic (although interesting).
>When the int part of the number is greater than 1 byte the representation
>is not exact.
False.
>But PERL can "represent" 0.4 exactly. Number above 15.4 (I mean 16.4)
>can't be exactly represented by PERL.
So you are saying the number
1*10^-10000000000000000000000000000000000000000 can be represented
accurately by perl?
Try running this program:
perl -e '$i = 0.a_string_consisting_of_three_hundred_zeroes_1'
and see what happens.
>Sorry for my english and for your shock.
Your english is fine...if I could speak your language as well as you do
mine I'd be happy.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
The duration of passion is proportionate
with the original resistance of the woman.
-- Honor‚ de Balzac, "The Physiology of Marriage", 1829
------------------------------
Date: 12 Sep 2000 07:20:15 -0700
From: tchrist@perl.com (Tom Christiansen)
Subject: Re: Perl substraction weird result
Message-Id: <39be2d8f$1@cs.colorado.edu>
In article <slrn8rs8nc.c88.tjla@thislove.dyndns.org>,
>Given that it is not possible to represent "0.4" exactly, is it any
>surprise that it is not possible to accurately do arithmetic with it?
"Accuracy" is not a boolean notion. It accepts quantifiiers.
For example, "how accurate" or "accurate to within four decimal points".
That's why we have rounding.
% perl -e 'printf "%.20f\n", .4**4'
0.02560000000000000470
% perl -e 'printf "%.4f\n", .4**4'
0.0256
Serious students should pick up texts on numerical analysis and
read over where they discuss the accumulation of round-off error.
This *is* a FAQ, you know.
--tom
------------------------------
Date: Tue, 12 Sep 2000 13:37:36 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Perl substraction weird result
Message-Id: <slrn8rscct.cmq.tjla@thislove.dyndns.org>
I was shocked! How could Tom Christiansen <tchrist@perl.com>
say such a terrible thing:
>In article <slrn8rs8nc.c88.tjla@thislove.dyndns.org>,
>>Given that it is not possible to represent "0.4" exactly, is it any
>>surprise that it is not possible to accurately do arithmetic with it?
>
>"Accuracy" is not a boolean notion. It accepts quantifiiers.
>For example, "how accurate" or "accurate to within four decimal points".
Sorry. I meant "exactly" in the sense of "perfectly precisely" or "with
complete accuracy".
>This *is* a FAQ, you know.
Yes. Sometimes people like to discuss FAQ's when they are bored :)
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
We don't understand the software, and sometimes we don't understand the
hardware, but we can *___see* the blinking lights!
------------------------------
Date: 12 Sep 2000 13:36:21 +0100
From: brianr@liffe.com
Subject: Re: Prune doesn't work in find
Message-Id: <vtpum96b3u.fsf@liffe.com>
mnelsen@nc.rr.com (Mike Nelsen) writes:
> Don't want to search in sub-directories if a -nosub option. I couldn't
> get the File::Find::prune=1 to work. It didn't give me any files in
> the starting directory just the directory itself. Here's the simple
> example that should just display the files in $sourceDir and no
> sub-directories below:
>
> find(\&wanted, $sourceDir);
>
> #********************************************************
> sub wanted
> {
> $sourcePath = $File::Find::dir;
> print "$sourcePath\\$_\n";
> if ($opt_nosub) {
> $File::Find::prune=1;
> }
> }
sub wanted {
print "$File::Find::name\n";
$File::Find::prune=1 if -d && $opt_nosub;
}
Should work
--
Brian Raven
Yes, we have consensus that we need 64 bit support. :-)
-- Larry Wall in <199710291922.LAA07101@wall.org>
------------------------------
Date: Tue, 12 Sep 2000 06:45:19 -0400
From: "Garry T. Williams" <garry@zvolve.com>
Subject: Re: Resolving IP's Q: Does this IP actually exist?
Message-Id: <Pine.SOL.4.21.0009120620380.20854-100000@zweb>
On Tue, 12 Sep 2000, Richard Lawrence wrote:
> I tried using IO::Socket to make a connection however setting the
> Timeout value to 5 still causes the code to hang for up to two minutes
> trying to connect a site that either doesn't exist or is very slow at
> being looked up.
You don't show any code. You also don't mention what version of
IO::Socket you're using. This is significant, because there have been
problems like yours reported in older versions of IO::Socket. You
posted from Deja, so perhaps a search of that site for your problem
would help.
$ perl -MIO::Socket -e'print"$IO::Socket::VERSION\n";'
1.26
I have no problem timing out attempting to connect to a non-existent
host with this version.
$ cat try
#!/usr/local/bin/perl -w
use strict;
use IO::Socket;
my $socket = IO::Socket::INET->new(
Proto => "tcp",
Timeout => 5,
Type => SOCK_STREAM,
PeerAddr => "10.1.2.56",
PeerPort => 2560
) or die $@;
$ time perl try
IO::Socket::INET: Timeout at try line 4.
real 0m5.27s
user 0m0.17s
sys 0m0.06s
-Garry Williams
------------------------------
Date: 12 Sep 2000 10:07:27 -0400
From: darkon@one.net (David Wall)
Subject: Re: Resolving IP's Q: Does this IP actually exist?
Message-Id: <8FAD6CE62darkononenet@206.112.192.118>
ralawrence@my-deja.com (Richard Lawrence) wrote in
<8pkrv8$s89$1@nnrp1.deja.com>:
>Can anyone advise me if it is possible to find out whether a site
>exists quickly and easily within a certain amount of alloted time? If
>anyones solution doesn't require connecting to a port then thats fine,
>because it means I can test first and then connect to the port
>afterwards.
How about Net::Ping?
--
David Wall
darkon@one.net
------------------------------
Date: Tue, 12 Sep 2000 17:06:49 +0200
From: "Moshe Eshel" <moshe@u4all.com>
Subject: Script To automate ftp uploading
Message-Id: <39be38a4@news.bezeqint.net>
Hi!
I need some help to create a script that will connect to a remote server and
upload all the files in a certain directory.
I know how to do the basic stuff like the connect and upload issues,
what I really need help with are all the special cases... How to deal with
Errors on the remote server, how to know when file upload has finished
and do a size check to determine if the file made it to the other side...
And if failed to retry... etc...
Any help would be appriciated...
Any examples in any shell language Perl or Tcl would be greatly
appriciated...
Thanks a lot in advance
Moshe Eshel
moshe@u4all.com
------------------------------
Date: 12 Sep 2000 09:22:36 -0500
From: claird@starbase.neosoft.com (Cameron Laird)
Subject: Re: Script To automate ftp uploading
Message-Id: <8D2807E404236D05.932B7BF5ADC34AA5.EA2EC1FE543A01FE@lp.airnews.net>
In article <39be38a4@news.bezeqint.net>, Moshe Eshel <moshe@u4all.com> wrote:
>Hi!
>
>I need some help to create a script that will connect to a remote server and
>upload all the files in a certain directory.
.
.
.
<URL:http://starbase.neosoft.com/~claird/comp.unix.programmer/ftp_automation.html>
--
Cameron Laird <claird@NeoSoft.com>
Business: http://www.Phaseit.net
Personal: http://starbase.neosoft.com/~claird/home.html
------------------------------
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 4296
**************************************