[7011] in Perl-Users-Digest
Perl-Users Digest, Issue: 636 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 19 16:26:46 1997
Date: Thu, 19 Jun 97 13:00:24 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 19 Jun 1997 Volume: 8 Number: 636
Today's topics:
"odd number of elements" warning with {} <asparks@nss.harris.com>
Re: "odd number of elements" warning with {} (Brian Wheeler)
Re: "odd number of elements" warning with {} <jhi@alpha.hut.fi>
Re: "odd number of elements" warning with {} (Quentin Fennessy)
Re: appending two files into one? (Bob Wilkinson)
Re: Can't find *** in @INC ....Help Please (Dave Cross)
Re: Can't find *** in @INC ....Help Please (Andrew M. Langmead)
Re: CGI.pm and multiple spaces in html. <dbenhur@egames.com>
Re: DBD and Oracle 7.3.2.3 build problem! (John D Groenveld)
Echo Etc. Q (Brad Johnson)
find2perl and find produce different results on AIX 3.2 (Owen Crow)
Free, efficient db for WWW database on NT and Unix? (David Weller)
How to convert TCL to perl 5.3 or above <jsyre@dcaca091.ca.boeing.com>
Install PERL5 <cyberdh@post2.tele.dk>
Re: Install PERL5 <jhi@alpha.hut.fi>
Job Advert (Aaron Savage - Web Architect)
Re: Julian Date Function Needed (Jeff Godden)
Re: leading zeroes (Brad Johnson)
Re: leading zeroes (Bob Wilkinson)
Llama question (Gilbert Midonnet)
Perl 5 regexps as independant package? (Chris Thompson)
Re: Perl Reg Exp (Bob Wilkinson)
perlNT and NTMail <jan@virtualf.com>
Re: Reading from STDIN pipe & Keyboard (Andrew M. Langmead)
Returning string with the XSUB mechanism <joop@polder.ubc.kun.nl>
Re: Returning string with the XSUB mechanism (Nathan V. Patwardhan)
set-u-id perl script (Yuan-fang Wang)
Re: System command (Scott McMahan)
Trouble opening a file with date modified <mvale@vanoise.sps.mot.com>
Re: Trouble opening a file with date modified <jhi@alpha.hut.fi>
Unexpected -X filetest behavior no.junk@mail.thank.you
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 13 Jun 1997 13:57:50 -0700
From: Alan Sparks <asparks@nss.harris.com>
Subject: "odd number of elements" warning with {}
Message-Id: <33A1B44E.17FE@nss.harris.com>
I've the following line in a script:
%foo = {};
Perl (5.004) complains:
Odd number of elements...
I don't think that's so odd... Besides, zero is even. So says my
math teacher anyway.
Why does this assignment deserve this warning? Or it there a more
appropriate way to initialize a hash?
Thanks in advance... I'd prefer any comments to e-mail, but will take
what I can get... :-)
-Alan
-------------------------------
Alan Sparks, IS Engineering Support asparks@harris.com
Harris Network Support Systems, Camarillo CA 93012 (805) 389-2430
------------------------------
Date: 19 Jun 1997 19:00:05 GMT
From: bdwheele@indiana.edu (Brian Wheeler)
Subject: Re: "odd number of elements" warning with {}
Message-Id: <5obvjl$q63$2@dismay.ucs.indiana.edu>
In article <33A1B44E.17FE@nss.harris.com>,
Alan Sparks <asparks@nss.harris.com> writes:
>I've the following line in a script:
>
> %foo = {};
>
>Perl (5.004) complains:
>
> Odd number of elements...
>
>I don't think that's so odd... Besides, zero is even. So says my
>math teacher anyway.
>
>Why does this assignment deserve this warning? Or it there a more
>appropriate way to initialize a hash?
>
>Thanks in advance... I'd prefer any comments to e-mail, but will take
>what I can get... :-)
It odd, though. You're assigning the hash foo to a _hash reference_,
which is a single item, therefore odd. If you want to assign an empty hash,
just use %foo=().
Brian
>
>-Alan
>-------------------------------
>Alan Sparks, IS Engineering Support asparks@harris.com
>Harris Network Support Systems, Camarillo CA 93012 (805) 389-2430
--
Brian Wheeler
bdwheele@indiana.edu
------------------------------
Date: 19 Jun 1997 22:13:12 +0300
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: "odd number of elements" warning with {}
Message-Id: <oee67vatnhz.fsf@alpha.hut.fi>
: I've the following line in a script:
:
: %foo = {};
:
: Perl (5.004) complains:
:
: Odd number of elements...
:
: I don't think that's so odd... Besides, zero is even. So says my
: math teacher anyway.
There are no _zero_ elements on the right hand side. There is _one_
element on the right hand side. A reference to a hash (which is,
incidentally, an empty one), one reference to an empty hash.
: Why does this assignment deserve this warning? Or it there a more
: appropriate way to initialize a hash?
You can think of a hash as an array of even size. Every odd array
element (using your math teacher's terminology here) is a key and
every even array element is a value.
Therefore, to 'zero' a hash you assign an empty list.
%hash = ();
: Thanks in advance... I'd prefer any comments to e-mail, but will take
: what I can get... :-)
Sorry but USENET news is not a helpdesk where you are called back.
If you want to ask questions it is considered good manners to wait for
the answers.
--
$jhi++; # http://www.iki.fi/~jhi/
# There is this special biologist word we use for 'stable'.
# It is 'dead'. -- Jack Cohen
------------------------------
Date: 19 Jun 1997 19:08:32 GMT
From: quentin@remington.amd.com (Quentin Fennessy)
Subject: Re: "odd number of elements" warning with {}
Message-Id: <5oc03g$6m4$1@amdint2.amd.com>
(cc'ed to poster)
In article <33A1B44E.17FE@nss.harris.com>,
Alan Sparks <asparks@nss.harris.com> wrote:
>I've the following line in a script:
> %foo = {};
>
>Perl (5.004) complains:
> Odd number of elements...
Alan-
You can initialize an empty hash with () like this:
%h = ();
--
Quentin Fennessy AMD, Austin Texas
------------------------------
Date: Wed, 18 Jun 1997 15:15:56 +0100
From: b.wilkinson@pindar.co.uk (Bob Wilkinson)
Subject: Re: appending two files into one?
Message-Id: <b.wilkinson-1806971515560001@ip57-york.pindar.co.uk>
In article <01bc7b8e$48946af0$338c0481@dna>, "Kirk Rogers"
<kirkr@trant.sp.trw.com> wrote:
> I know ill get flamed for this one but how do I append two files together.
>
> sorry for such newbie questions, but I cant find an example in the book
>
> thanks
> --
> Kirk
Hello,
If you use Unix, then you don't use perl, you use cat. e.g.
cat file1 file2 > newfile
Bob
--
Do what thou wilt shall be the whole of the law.
------------------------------
Date: Thu, 19 Jun 1997 13:38:47 GMT
From: Dave.Cross@gb.swissbank.com (Dave Cross)
Subject: Re: Can't find *** in @INC ....Help Please
Message-Id: <DAVE.CROSS.97Jun19143848@ln4d110swk.gb.swissbank.com>
In article <5oai91$21k_004@interaccess.interaccess.com> shelle@interaccess.com (Shelle) writes:
> Having been through all of the manuals, FAQs, and online documents regarding
> Perl on Windows95, I have yet to find a suitable answer for why I get errors
> such as:
>
> Can't locate XXXXX/XXXX.pm in @INC at filename.pl line ##.
>
Michelle,
One of your scripts is trying to include a module (with a 'use' or
'require' command) that it can't find. To find where Perl is looking
for the module run a short script to print the contents of the @INC array,
somthing like:
perl -e 'print(join("\n", @INC), "\n")'
should do it. Then compare the list of directories you get from this to the
directory where your XXXXX/XXXX.pm module is actually installed. If you
find a discrepancy you can address it in one of two ways, either move
XXXXX/XXXX.pm into one of the @INC directories or change @INC to include
the directory that contains XXXXX/XXXX.pm. The easiest way to do this is
by setting a PERL5LIB environment variable that contains the names of the
directories you need to add (not sure how this is achieved under Win95).
Hope this helps, if you need any more details please shout.
Dave... .. .
--
Opinions are mine, not the company's - hell I don't think the
company even knows who I am.
Dave.Cross@gb.swissbank.com
------------------------------
Date: Thu, 19 Jun 1997 14:28:25 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Can't find *** in @INC ....Help Please
Message-Id: <EC11JE.I6E@world.std.com>
shelle@interaccess.com (Shelle) writes:
>Having been through all of the manuals, FAQs, and online documents regarding
>Perl on Windows95, I have yet to find a suitable answer for why I get errors
>such as:
> Can't locate XXXXX/XXXX.pm in @INC at filename.pl line ##.
>Actually I thought I found a couple of solutions but none seemed to solved
>this problem. Suggestions appreciated.
>P.S. Yes, I've "R" so many versions "OTFM" in the past week or so I need an
>eye exam;
Maybe you just need to figure the right places to look.
When you get an error message from a perl script, the first thing that
you should do is to check the "perldiag" man page. It lists _every_
diagnostic message that perl emits (and a few that it
doesn't. Sometimes people think that shell error messages or http
server error messages are from the perl interpreter. The authors of
the man pages threw some of thos in too in an attempt to reduce
traffic in comp.lang.perl.misc)
The perldiag man page points you to the entry for "require" in the
perlfunc man page. In it, you find that the "require" and "use"
functions look for their specified file in every directory specified
in the @INC array. You could try printing out @INC:
perl -e "print join qq[\n], @INC"
This prints out a bunch of directories. Take a look at them in the
Windows Explorer. Is there a directory named "XXXXX" with a file named
"XXXXX.pm" in it? If not, do you know where the file is? Is it a
standard module? Or is it something that needs to be added by you.
If it is a standard (it comes with the perl distribution) module, that
it would seem to me that your copy of perl was not installed
correctly. Try it again. If you still have no success, I'd suggest to
check with the people on the Activeware mailing list. The address to
join is in the "readme.txt" file in the "docs\Perl-Win32" directory of
the Activeware perl distribution.
If it is a non-standard module and you don't have it, get it. Look in
<URL:http://www.perl.com/CPAN/modules/by-module/Win32> for it. If you
do have it, make sure it that it is in one of the directories in which
perl is looking for it.
--
Andrew Langmead
------------------------------
Date: Thu, 19 Jun 1997 10:39:58 -0700
From: Devin Ben-Hur <dbenhur@egames.com>
To: "Michael S. Coulman" <mcoulman@citilink.com>
Subject: Re: CGI.pm and multiple spaces in html.
Message-Id: <33A96EEE.30BA@egames.com>
[mail&post]
Michael S. Coulman wrote:
> >>>>> "Daniel" == Daniel Lortie <dlortie@nt.com> writes:
> Daniel> [...] but I wish there was a 'nbsp' tag or something like
> Daniel> nbsp(3) to insert three spaces.
>
> Use the perl repeat (`x') operator:
>
> my ($nbsp) = ' ';
> print $nbsp x 3; # prints ` '
You'll have more widely understood output if you use:
my ($nbsp) = ' '; # non-breaking space
instead.
Many older browsers didn't understand the nbsp entity, but
honor the numerically expressed equivalent just fine
(notably Netscrape 2.x, of which there's a suprising number
still in use).
[followups directed to ciwah since this is no longer
perl related]
HTH
--
Devin Ben-Hur <dbenhur@egames.com>
eGames.com, Inc. http://www.egames.com/
eMarketing, Inc. http://www.emarket.com/
Warning: Dates in Calendar are closer than they appear.
------------------------------
Date: 19 Jun 1997 12:59:16 -0400
From: groenvel@cse.psu.edu (John D Groenveld)
Subject: Re: DBD and Oracle 7.3.2.3 build problem!
Message-Id: <5oboh4$plh$1@tholian.cse.psu.edu>
In article <866470180.10098@dejanews.com>, <davramenko@dlj.com> wrote:
> what the problem is? Please let me know. Does anybody have a sucessfull
> build of DBD against Oracle 7.3.2.3 ?
I have, I have. Oracle is now at 7.3.3 and you can obtain the latest DBI
and DBD::Oracle from a CPAN near you. See http://www.perl.com/CPAN/.
Happy Perl'ng,
John
groenvel@cse.psu.edu
------------------------------
Date: 19 Jun 97 17:30:21 GMT
From: bgjohnso@unix.amherst.edu (Brad Johnson)
Subject: Echo Etc. Q
Message-Id: <33a96cad.0@amhnt2.amherst.edu>
I'm trying to write a little specialized ftp-automater
on perl for dos (sample code below),
but I'd like to be able to echo system
commands to the screen; i.e. I use the line
`ftp -s:ftpscript.txt $server1`;
which tells the ftp to use ftpscript.txt for commands
but I don't get to see the messages ftp generates.
Using a .bat file, the same line as above (w/o the perl
stuff) spits the "sending file to server..." etc. messages
to the screen, which is what I want.
Is there some way to get my remote responses?
btw
`ftp -s:ftpscript.txt $server1` >> STDOUT;
doesn't give any useful screen output.
# sample from ftper.pl
#!c:\perl\bin\perl
...
print "About to send:\n";
open (FTP, ">c:\\ftpscript.txt");
print FTP "$username\n$passwd\n\n";
print FTP<<END;
cd $remotedir
send $localdir$localfile
END
}
close(FTP);
print "Send files? (y/n) ";
$_ = <STDIN>;
if(/^y/i) {
print "sending to www1...\n";
`ftp -s:c:\\ftpscript.txt $server1`;
}
--
------------------------Nullus Oppidenda Est--------------------------
brad johnson (bgjohnso@unix.amherst.edu) 'Disc, God, Country, Pork'
http://www.amherst.edu/~bgjohnso/ 'Chickens! No Cynics!'
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
------------------------------
Date: 19 Jun 1997 19:11:43 GMT
From: ocrow@bermuda.io.com (Owen Crow)
Subject: find2perl and find produce different results on AIX 3.2.5
Message-Id: <5oc09f$ri9$1@nntp-2.io.com>
I'm sure I've missed something trivial, but...
When I do a simple "find2perl / -print" and run it through Perl, I get very
different results compared to a regular find. Here are some test
commands I ran on an AIX 3.2.5 system:
----------------------------------------------------------------------
# perl -v
This is perl, version 5.004
Copyright 1987-1997, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5.0 source kit.
# uname -a
AIX h320e1 2 3 000099153500
# oslevel
Processing.....Please Wait.
>3250
# perl -e "`find2perl / -print`" > /tmp/found.perl
# wc -l /tmp/found.perl
16859 /tmp/found.perl
# find / -print > /tmp/found.find
# wc -l /tmp/found.find
60967 /tmp/found.find
----------------------------------------------------------------------
In general, find2perl doesn't descend into filesystems other than /.
Notable exceptions are NFS directories which it does traverse.
I have created a File::Find version of the search as well, but I still
only get about 16800 files.
A similar test on an AIX 4.1.3 system does not have this problem (find and
find2perl agree).
Is this a known bug or just something I'm doing? Thanks for your time,
Owen
------------------------------
Date: 19 Jun 1997 11:05:45 -0500
From: dweller@news.imagin.net (David Weller)
Subject: Free, efficient db for WWW database on NT and Unix?
Message-Id: <5oblcp$1lp7$1@prime.imagin.net>
To expand on the subject line:
We're looking for a free database program to use for a potentially
commercial project. If possible, we'd like to have several to compare
side by side. The purpose is to support a WWW-based tool. We're not
talking millions of records, nor are we talking anything beyond simple
queries. I'm seeing a lot of references to ndbm, sdbm, gdbm, Berkeley
db, PostgreSQL, etc. All have variations of the word "free", but
we're not sure if 1) there's more choices out there and 2) if somebody
has already compared these products and published the results.
Any help would be mucho appreciated...
------------------------------
Date: Thu, 19 Jun 1997 01:20:20 GMT
From: "J. Syre" <jsyre@dcaca091.ca.boeing.com>
Subject: How to convert TCL to perl 5.3 or above
Message-Id: <33A88954.943@dcaca091.ca.boeing.com>
Does anyone know of any freely available tools to convert TCL
to perl 5.003 or above?
I looked around with the search engines and in Dejanews and
did not find anything.
Reply by email is fine. Thanks in advance.
J. Syre
jsyre@dcaca091.ca.boeing.com
------------------------------
Date: 19 Jun 1997 18:16:09 GMT
From: "Dennis Hansen" <cyberdh@post2.tele.dk>
Subject: Install PERL5
Message-Id: <01bc7cdc$bd6b33a0$6b96efc2@default>
Help
My server haven't PERL5, where can I get it??
Please mail me at cyberdh@post2.tele.dk
Yours
Dennis Hansen
Denmark
------------------------------
Date: 19 Jun 1997 22:32:36 +0300
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
To: "Dennis Hansen" <cyberdh@post2.tele.dk>
Subject: Re: Install PERL5
Message-Id: <oee205ytmln.fsf@alpha.hut.fi>
"Dennis Hansen" <cyberdh@post2.tele.dk> writes:
> My server haven't PERL5, where can I get it??
http://www.perl.com/CPAN/src/latest.tar.gz
--
$jhi++; # http://www.iki.fi/~jhi/
# There is this special biologist word we use for 'stable'.
# It is 'dead'. -- Jack Cohen
------------------------------
Date: Wed, 18 Jun 1997 09:57:44 GMT
From: ^Aaron^@bluewave.co.uk (Aaron Savage - Web Architect)
Subject: Job Advert
Message-Id: <33a7b01c.691906401@pub.news.uk.psi.net>
-----------------------------------------------------------------------------------------------------
Those not interested in a job in the UK should stop reading now
------------------------------------------------------------------------------------------------------
Attention Techies
We are a large and successful Web Design House based in central London
UK.
Our clients include, TNT Express Worldwide, National Grid, British
Energy
and FTSE International. Due to exceptional growth we have a vacancy
for a Web programmer.
The skills required for working on our client sites are
predominantly PERL although experience of Java, Javascript, Visual
Basic, ActiveX, C and VBscript programming are distinct advantages.
We are a very close young dynamic team of 17 people and we don't sub
contract anything. Consequently our selection process is quite
strenuous but pleasantly fast.
The rewards are definitely here for the taking.
If you can tell me the difference between the Internet, Extranet and
Intranet, and also explain how successful business will use all three,
I want to talk with you.
Please reply by email enclosing your CV and a few lines explaining why
you
would like to be part of the Bluewave team.
e-mail to richard@bluewave.co.uk
See our web site on www.bluewave.co.uk
------------------------
It is pointless dividing people into Good and Bad
People are either tedious or charming
------Oscar Wilde-------
BTW remove the ^s to reply....
I hate and object to SPAM
------------------------------
Date: 19 Jun 1997 16:27:27 GMT
From: godden@u.washington.edu (Jeff Godden)
Subject: Re: Julian Date Function Needed
Message-Id: <5obmlf$10gk@nntp6.u.washington.edu>
Mike Stok <mike@stok.co.uk> wrote:
>In article <33a8bbbb.1597349@news.earthlink.net>,
>Frank Fisher <frank@primemail.com> wrote:
>>I need to count days into the future; example, today() + 45 days to
>>get a mm/dd/yy date. Is there a julian date function I can use or
>>some other perl function that will do the same thing?
>
>There are several Date and Time manipulating functions in modules
>available from CPAN, the comprehensive perl archive network (on the web
>point your browser at http://www.perl.com/CPAN/ )
or if you're like me, a module-weenie (too much bloat/too much "module
X must be installed to get module Y"), just use the following
subroutine with your eyes open to it's deficiencies:
# ----- this will return day number 719469 for 1970/1/1
sub jday {
# note screwed up american date element ordering
my($month,$day,$year) = @_;
my($y) = $year + ($month-3)/12;
int(367*$y+0.625)-2*int($y)+int($y/4)-int($y/100)+int($y/400)+$day;
}
--
good luck,
jeff
godden@u.washington.edu
------------------------------
Date: 19 Jun 97 17:41:35 GMT
From: bgjohnso@unix.amherst.edu (Brad Johnson)
Subject: Re: leading zeroes
Message-Id: <33a96f4f.0@amhnt2.amherst.edu>
DCrouse495 (dcrouse495@aol.com) wrote:
: Mariana Wuerz <mariana.wuerz@fernuni-hagen.de> writes:
: > $four=04
: >
: > How can I get $four=4?
: $stuff = <STDIN>;
: $stuff = &nozeros($stuff);
: sub nozeros
: { # star sub nozeros
: local($string) = @_;
: return $string if (substr($string,0,1) ne "0");
: return &nozeros(substr($string,1));
: } # end sub nozeros
how 'bout using
s/^0*//g
?
or even
s/^0*|\b0*//g
?
--bradj.
------------------------Nullus Oppidenda Est--------------------------
brad johnson (bgjohnso@unix.amherst.edu) 'Disc, God, Country, Pork'
http://www.amherst.edu/~bgjohnso/ 'Chickens! No Cynics!'
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
------------------------------
Date: Wed, 18 Jun 1997 15:10:26 +0100
From: b.wilkinson@pindar.co.uk (Bob Wilkinson)
Subject: Re: leading zeroes
Message-Id: <b.wilkinson-1806971510260001@ip57-york.pindar.co.uk>
In article <19970617221501.SAA00992@ladder02.news.aol.com>,
dcrouse495@aol.com (DCrouse495) wrote:
A translation for the non-German speakers.
> Mariana Wuerz <mariana.wuerz@fernuni-hagen.de> writes:
>
> > $four=04
> >
> > How can I get $four=4?
>
> Marianna, Ich habe hier ein subroutine. Es ist einfach recursive und man
> kann es einfach in Programm stecken. zB
Marianna, I have here a subroutine, It is simply recursive and you can easily
place it in a program. e.g.
>
> $stuff = <STDIN>;
> $stuff = &nozeros($stuff);
>
> ####################################################
> # DMC: 1-23-97
> ####################################################
> sub nozeros
> { # star sub nozeros
> local($string) = @_;
> return $string if (substr($string,0,1) ne "0");
> return &nozeros(substr($string,1));
> } # end sub nozeros
>
> und, es mach nichts wie viele zeroes es gab.
and, it doesn't matter how many zeroes it's given.
--
Do what thou wilt shall be the whole of the law.
------------------------------
Date: 19 Jun 1997 14:28:00 -0400
From: glm@panix.com (Gilbert Midonnet)
Subject: Llama question
Message-Id: <5obtng$de0@panix2.panix.com>
Hello all,
I'm having a problem with the questions at the end of chapter 3.
I've searched through deja news. I don't think anybody has asked
this question in a while :>
The concept is simple. Take some inputted strings and print out the
list in reverse.
I set up my own little script. It didn't work, nor did any of the
modifications. I copied Randal Schwartz' example. That too did not
work.
The script is as follows. (from page 199)
#!/usr/local/bin/perl5
print "Enter the list of strings:\n";
@list = <STDIN>;
@reverselist = reverse(@list);
print @reverselist;
The problem in this example is in the input of information. There
is no end to the list desired.
If I input the data using a scalar variable and then put the scalar
variable into an array, and ask the program to print out the array
variable, that too doesn't work.
EXAMPLE:
$a = <STDIN>;
...
@a = ($a,$b,$c);
print @a;
TIA
Gilbert Midonnet
------------------------------
Date: 19 Jun 1997 18:10:55 GMT
From: cet1@cus.cam.ac.uk (Chris Thompson)
Subject: Perl 5 regexps as independant package?
Message-Id: <5obsnf$hib@lyra.csx.cam.ac.uk>
Is there an independant package implementing perl5-style regular
expressions that could be incorporated in other programs? It doesn't
seem to be easy to make one out of the perl5 source itself.
Chris Thompson
Email: cet1@cam.ac.uk
------------------------------
Date: Wed, 18 Jun 1997 14:54:45 +0100
From: b.wilkinson@pindar.co.uk (Bob Wilkinson)
Subject: Re: Perl Reg Exp
Message-Id: <b.wilkinson-1806971454450001@ip57-york.pindar.co.uk>
In article <5o67c0$vta@r02n01.cac.psu.edu>, bxb121@psu.edu (Brett Borger) wrote:
> In my continuing battle against a mangled version of 4.??? perl for
> Novell:
>
> I'm trying to perform a s// on a file....here is the string I want to
> find:
> isNew(60,"somedatehere")
> where somedatehere is a date that I don't know ahead of time.
> I want to replace it with:
> isNew(60, "newdate")
> where newdate is what you would expect. The line I'm using is:
> $temp=~s/isNew\(+\)/isNew(60,"$date")/o;
>
> But this doesn't find the line. Why?
Because the regexp is wrong!
$temp=~s/isNew\([^)]+\)/isNew(60,"$date")/;
^^^^ ^
would be better. The first insertion states that you want to match any character
but a ")" i.e. [^)] (I think that the ")" doesn't need to be escaped within the
character class - I've not tested the code. The second edit says that you
shouldn't use the "o" modifier - it may work here, but with variable
matching and susbstitution it can lead to strange results, since the pattern
is only compiled once.
> Also, what is a good net.resource to learn the RegExp rules?
http://rhine.ece.utexas.edu/~kschu/perls/perlre.html
>I'm pretty
> much guessing at these.
>
> Thanks,
> Brett Borger
> OPP Webmaster, Penn State University
--
Do what thou wilt shall be the whole of the law.
------------------------------
Date: 19 Jun 1997 15:02:05 GMT
From: "Yanco" <jan@virtualf.com>
Subject: perlNT and NTMail
Message-Id: <01bc7d03$0c12bde0$166083c1@london22>
hi all,
does anybody have any ideas on how to interact ntmail with perlnt ?
ie config, perl script specifics.
jan
------------------------------
Date: Thu, 19 Jun 1997 13:41:14 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Reading from STDIN pipe & Keyboard
Message-Id: <EC0zCq.92u@world.std.com>
"Ronald Klimaszewski" <microsys@IntNet.net> writes:
>Is it possible to send a bunch of info/data to a Perl script via stdin,
>then, after all info is sucked
>in, get addt'l info from the keyboard?
Most unix systems have a "/dev/tty" which refers to the process'
controlling terminal, even if STDIN has been redirected elsewhere.
--
Andrew Langmead
------------------------------
Date: 19 Jun 1997 16:03:30 GMT
From: "Joop Jansen" <joop@polder.ubc.kun.nl>
Subject: Returning string with the XSUB mechanism
Message-Id: <01bc7cca$5c1fb0b0$2415ae83@beemster>
Hello,
I am trying to extend Perl with some C-code. One of the functions needs to
return a string of unpredictable length. The function should be used in my
Perl script as:
&API::getString($string);
What do I need to do in the .xs (or .c-file generated from it) to realize
this. I tried to edit the C-file as follows, but that does not work:
XS(XS_API_getString)
{
dXSARGS;
if (items != 1)
croak("Usage: API::getString(cp)");
{
char cp[10000];
getString(cp);
SvGROW((SV*)ST(0), strlen(cp)); <--- This gives asegmentation fault
sv_setpv((SV*)ST(0), cp);
}
XSRETURN_EMPTY;
}
Is there a standard solution???
Thanks in advance,
Joop Jansen
------------------------------
Date: 19 Jun 1997 16:38:05 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Returning string with the XSUB mechanism
Message-Id: <5obn9d$8tj@fridge-nf0.shore.net>
Joop Jansen (joop@polder.ubc.kun.nl) wrote:
: Is there a standard solution???
Well, there's a solution that I found to be effective - you'll
actually find it in perlcall, which gives some examples where a list
is returned. I've used this where variable paramaters can be passed
using "..." (see perlxs for this).
--
Nathan V. Patwardhan
nvp@shore.net
------------------------------
Date: 19 Jun 1997 11:03:13 -0700
From: yfwang@cs.ucsb.edu (Yuan-fang Wang)
Subject: set-u-id perl script
Message-Id: <5obs91$nmr@tao.cs.ucsb.edu>
Folks:
I hope someone can help me with this:
I have a perl CGI-script that I run the following way:
I created a C program which contains a single line just to exec perl on
this CGI-script. And the C program has the set-user-id bit turned on. This
is a trick I learned from Perl security FAQ's. The reason is to have
the perl script runs as me (instead of as user WWW) and be able to
access my personal directory.
However, the same script which runs fine as WWW developed problems
when runs as me through the above set-u-id mechanism. I traced the
problem to a line which says:
$date = `date`;
In fact, any line which use `` (backquote) does work. I suspect
this might be some protection problem. Any one has any experience
with this problem?
thanks in advance.
--yfwang@cs.ucsb.edu
------------------------------
Date: 19 Jun 1997 15:20:32 GMT
From: scott@lighthouse.softbase.com (Scott McMahan)
Subject: Re: System command
Message-Id: <5obio0$144$2@mainsrv.main.nc.us>
George M. Pieri (george.pieri@mci.com) wrote:
: Instead of
: system "dir > output.file" ;
: Want
: system "dir > @my_array " ;
Just use your brain and think it through step by step. The pieces are
all there, you just have to assemble them in the right order. You want
the file in an array, right? What does that? Reading the file in an
array context!
Try:
system "dir > output.file" ;
open(X, "output.file");
@my_array=<X>;
close(X);
Of course, this is overkill for reading a directory when you can use
opendir and readdir and get the contents into an array without even
spawning external processes or including system dependancies.
Scott
------------------------------
Date: Thu, 19 Jun 1997 15:40:26 +0200
From: Manuel Valente <mvale@vanoise.sps.mot.com>
Subject: Trouble opening a file with date modified
Message-Id: <33A936CA.2501@vanoise.sps.mot.com>
Hi !
Perl allows me to modify the modification date of a file (utime
function), not the creation date. But if the modified date is before the
creation date, Perl won't open the file any more whereas Unix still
does.
Is it on purpose ?
------------------------------
Date: 19 Jun 1997 22:05:56 +0300
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: Trouble opening a file with date modified
Message-Id: <oee7mfqtnu3.fsf@alpha.hut.fi>
> Perl allows me to modify the modification date of a file (utime
> function), not the creation date. But if the modified date is before the
If you talking about UNIX there is no creation date of a file.
I repeat. There is no creation date of a file.
There are three timestamps on a file: last modification (write), last
access (read), last metadata change (chmod, chown, utime, rename,
link, unlink).
You may be confusing the last change timestamp with a creation timestamp.
> But if the modified date is before the creation date,
Modified date is before the change date if the data of the file has
been modified since the metadata has changed.
> Perl won't open the file any more whereas Unix still does.
What do you mean by "Perl won't open the file any more"?
Any error messages?
Have you tried the -w option of Perl?
Could you please show your code? Most of us, we are not psychics.
--
$jhi++; # http://www.iki.fi/~jhi/
# There is this special biologist word we use for 'stable'.
# It is 'dead'. -- Jack Cohen
------------------------------
Date: 19 Jun 1997 16:50:16 GMT
From: no.junk@mail.thank.you
Subject: Unexpected -X filetest behavior
Message-Id: <5obo08$qdp$1@trotsky.cig.mot.com>
Greetings all,
I have a question about the behavior of the various -X
file tests. I have some code that looks at $ARGV[0] using
some of the -X file tests. I get unexpected results when I
don't supply an $ARGV[0].
What are the various differences between these invocations:
1. my_code (no file given)
2. my_code good_file
3. my_code nonexistent_file
1. is where the unexpected results occur. There is no $ARGV[0]
but (-e $ARGV[0]) returns a 1. (-s $ARGV[0]) returns the size
of the current directory. Perlfunc says if the argument is
omitted, $_ is tested. But when I print out $_, I get nothing
(or at least nothing that will print). Is this a default -X
behavior question, something to do with $ARGV[0], or ...?
Can anyone help me out? Test code and results below.
Thanks for your time,
Steve
--
sie fke @ cig. mot. com (remove the spaces to reply)
Here's the snippet I run with the above command lines:
#! /usr/misc/bin/perl
print "\n \$ARGV[0] is: $ARGV[0]\n";
print " \$_ is: $_\n";
print " -e \$ARGV[0] returns:",(-e $ARGV[0]),"\n";
print " -s \$ARGV[0] returns:",(-s $ARGV[0]),"\n";
print " -z \$ARGV[0] returns:",(-z $ARGV[0]),"\n";
(-e $ARGV[0]) || die "\nFile '$ARGV[0]' not found. \n\n";
Here are the results:
1. % my_code
$ARGV[0] is:
$_ is:
-e $ARGV[0] returns:1
-s $ARGV[0] returns:1536 (size of current dir, per ls -l)
-z $ARGV[0] returns:
2. % my_code my_code
$ARGV[0] is: my_code
$_ is:
-e $ARGV[0] returns:1
-s $ARGV[0] returns:364 (correct size of my_code)
-z $ARGV[0] returns:
3. % my_code nonexistent_file
$ARGV[0] is: nonexistent_file
$_ is:
-e $ARGV[0] returns:
-s $ARGV[0] returns:
-z $ARGV[0] returns:
File 'nonexistent_file' not found.
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 636
*************************************