[8366] in Perl-Users-Digest
Perl-Users Digest, Issue: 1983 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 27 05:07:23 1998
Date: Fri, 27 Feb 98 02:00:43 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 27 Feb 1998 Volume: 8 Number: 1983
Today's topics:
Re: "Or" Operator? (Martien Verbruggen)
Re: "Or" Operator? (Earl Hood)
Re: better way to do this? <metcher@spider.herston.uq.edu.au>
Re: better way to do this? (Craig Berry)
Re: better way to do this? <uri@sysarch.com>
Re: CGI.pm a part of Perl (was Re: Cookies) (Martien Verbruggen)
Re: CGI_lib.pl and upload bug ? on Enterprise 3 (Martien Verbruggen)
Re: CGI_lib.pl and upload bug ? on Enterprise 3 (Johannes la Poutre')
Re: checking versions of dll files (Martien Verbruggen)
Re: Copying to a NT-server using C$ <metcher@spider.herston.uq.edu.au>
Re: Easy way to "clean" an array <dfetter@shell4.ba.best.com>
Re: Getting Directory Listing (Martien Verbruggen)
help- Can't modify hash file? <seven7seas@ibm.net>
How do I store a directory tree <abdo.hashem@teradyne.com>
How do I store a directory tree <abdo.hashem@teradyne.com>
Re: How do I store a directory tree <zenin@best.com>
Re: Installing Problem? (Martien Verbruggen)
Re: Is perl -e broken? I found out, thanks <rscarce@hq.caci.com>
Is perl -e broken? <rscarce@hq.caci.com>
Re: Is perl -e broken? (Michael J Gebis)
Is there a way??? (Schreffman)
many ways but i can not find one <star@sonic.net>
Matching with the //o option (Bart Lateur)
Re: Matching with the //o option <uri@sysarch.com>
Re: Matching with the //o option (Earl Hood)
Re: Musings on English.pm (Andrew M. Langmead)
Netiquette <metcher@spider.herston.uq.edu.au>
Re: No. of days?? <corky@ma.ultranet.com>
Re: removing new line (\n) <grimoire@oaktree.net>
RPC example(perlxs) question/Extracting C struct gupit@yahoo.com
Re: Running SQL from within Perl (Brian Lavender)
seeking and changing /etc/passwd <shankeyp@charlestoncounty.org>
seeking and changing /etc/passwd <shankeyp@charlestoncounty.org>
Re: seeking and changing /etc/passwd (Michael Martin)
Re: seeking and changing /etc/passwd <grimoire@oaktree.net>
Re: Simple Perl replacement for sendmail <Russell_Schulz@locutus.ofB.ORG>
Two questions about POD Gerben_Wierda@RnA.nl
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 26 Feb 1998 22:52:13 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: "Or" Operator?
Message-Id: <6d4rmt$886$6@comdyn.comdyn.com.au>
In article <34F5D10C.291C0B5F@uswest.com>,
Ryan Rucker <rxruck2@uswest.com> writes:
> if ($var1 ne 'value1' || $var1 ne 'value 2') {
> print ('$var1 is not equal to value 1 or value 2',"\n");
> } else {
> print ('$var 1 is equal to either value 1 or value 2',
> "\n");
> }
Apart from a few spaces which shouldn't be there:
I think you have your logic wrong. You probably want &&, not ||. or
you could reverse the tests (NOTE: These two mean opposite things):
if ($var1 eq 'value1' || $var1 eq 'value2')
if ($var1 ne 'value1' && $var1 ne 'value2')
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | In a world without fences, who needs
Commercial Dynamics Pty. Ltd. | Gates?
NSW, Australia |
------------------------------
Date: 26 Feb 1998 23:35:32 GMT
From: ehood@medusa.acs.uci.edu (Earl Hood)
Subject: Re: "Or" Operator?
Message-Id: <6d4u84$g7u@news.service.uci.edu>
[mail and posted]
In article <34F5D10C.291C0B5F@uswest.com>,
Ryan Rucker <rxruck2@uswest.com> wrote:
> if ($var1 ne 'value1' || $var1 ne 'value 2') {
> print ('$var1 is not equal to value 1 or value 2',"\n");
> } else {
> print ('$var 1 is equal to either value 1 or value 2',
>"\n");
> }
>
>I having problems when perl evaluates $var1. With this if statement,
>even when $var1 is equal to either value 1 or value 2, it won't drop
>through to the else portion. Instead, it executes the first print
>statement.
You need && in your if condition. || will only short-circuit when
the current expression be evaluated is true. Hence, when $var1
equals "value1", the second part of the || will still get evaluated
since the first part is false. And the second part will return
true causing the first print statement to be executed.
BTW, you print statement should say:
'$var1 is not equal to value 1 and value 2'
-----------------------------------^^^
I think you have symptoms of Boolean dyslexia. I get my &&'s and
||'s mixed on occassion too.
--ewh
--
Earl Hood | University of California: Irvine
ehood@medusa.acs.uci.edu | Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME
------------------------------
Date: Fri, 27 Feb 1998 09:51:11 +1100
From: Jaime Metcher <metcher@spider.herston.uq.edu.au>
Subject: Re: better way to do this?
Message-Id: <34F5F1DF.67F25B2C@spider.herston.uq.edu.au>
Craig Berry wrote:
>
snip
>
> /\.(.*?)$/
>
> In English, that read "A literal dot, followed by the least-length run of
> zero or more non-newline characters, ending at the end of string." That
> sounds weird because with that $ anchor right afterward, the non-greedy ?
> modifier doesn't mean anything. Eliminating it gives us
>
> /\.(.*)$/
>
> which means "A literal dot, followed by a run of zero or more non-newline
> characters, followed by the end of string (or a newline just before it)."
>
My Blue Camel, which has a lovely list of pattern matching rules in
order of precedence, doesn't mention non-greedy modifiers. The online
docs do, but don't have the list of rules. The Camel's list of rules
says that matching early takes precedence over greediness. Are you
saying here that matching early also takes precedence over stinginess?
(I think you are, I just want to hear you say it - working with
computers makes one pedantic, non?).
Something for the next camel, perhaps?
--
Jaime Metcher
------------------------------
Date: 27 Feb 1998 00:36:24 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: better way to do this?
Message-Id: <6d51q8$mpr$1@marina.cinenet.net>
Jaime Metcher (metcher@spider.herston.uq.edu.au) wrote:
: My Blue Camel, which has a lovely list of pattern matching rules in
: order of precedence, doesn't mention non-greedy modifiers.
You need a new Camel, I guess. Mine (2nd edition, 9/96) has it on page
63.
: The online
: docs do, but don't have the list of rules. The Camel's list of rules
: says that matching early takes precedence over greediness. Are you
: saying here that matching early also takes precedence over stinginess?
Basically. The leftmost match always wins. Greediness or non-greediness
only changes what (and how much) text matches from that leftmost point.
In other words, if we have
$a = 'abcd123x123xdxdx';
($b) = $a =~ /d(.*)x/;
($c) = $a =~ /d(.*?)x/;
then both $b and $c start with the leftmost 'd', but $b is 'd123x123xdxd'
(being greedy) while $c is 'd123' (being non-greedy).
: (I think you are, I just want to hear you say it - working with
: computers makes one pedantic, non?).
Obsessive-compulsive, I'd call it. :)
: Something for the next camel, perhaps?
Or even the current one...
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: 26 Feb 1998 19:55:34 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: better way to do this?
Message-Id: <x7n2fd27eh.fsf@sysarch.com>
Jaime Metcher <metcher@spider.herston.uq.edu.au> writes:
> My Blue Camel, which has a lovely list of pattern matching rules in
> order of precedence, doesn't mention non-greedy modifiers. The online
> docs do, but don't have the list of rules. The Camel's list of rules
> says that matching early takes precedence over greediness. Are you
> saying here that matching early also takes precedence over stinginess?
> (I think you are, I just want to hear you say it - working with
> computers makes one pedantic, non?).
>
> Something for the next camel, perhaps?
see blue camel, page 63 for a table with non-greedy modifiers and a
paragraph on the bottom explaining them.
and if you want more than you ever wanted to know about regexes, get
mastering regular expresions by jeff friedl. a masterfully written and
thoroughly enjoyable book. technically not a perl book but it has a 100
page chapter on perl RE. and the author (whom i met at the perl
conference) definitely like perl's re the best.
uri
--
Uri Guttman SYStems ARCHitecture and Software Engineering
uri@sysarch.com Have Perl, Will Hack
http://www.sysarch.com (781) 643-7504 x*2 FAX: (781) 643-2710
Try the Best Search Engine on the Net --------> http://www.northernlight.com
------------------------------
Date: 26 Feb 1998 22:32:48 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: CGI.pm a part of Perl (was Re: Cookies)
Message-Id: <6d4qig$886$3@comdyn.comdyn.com.au>
In article <34f528af.3187407@news.tornado.be>,
bart.mediamind@tornado.be (Bart Lateur) writes:
> mgjv@comdyn.com.au (Martien Verbruggen) wrote:
>
>>What about the core modules, like CORE, UNIVERSAL, SUPER, Dynaloader,
>>Exporter, etc.. etc.. Are they not part of perl? What about the
>>pragmatic modules? strict? diagnostics? vars? builtin?
>
> Somehow I have difficulty to see "strict" as a module.
It really is a module. It's one of the pragmatic modules, but that
doesn't alter the fact that it is a module. If you have a look at the
source, and at the perlmodlib documentation, you will see that both in
implementation and definition, strict.pm is a module.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | In a world without fences, who needs
Commercial Dynamics Pty. Ltd. | Gates?
NSW, Australia |
------------------------------
Date: 26 Feb 1998 22:57:30 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: CGI_lib.pl and upload bug ? on Enterprise 3
Message-Id: <6d4s0q$886$8@comdyn.comdyn.com.au>
In article <6d40fp$k6u$1@nnrp2.dejanews.com>,
mgui@iname.com writes:
> I use the CGI_lib.pl module to upload files on Netscape Enterprise 3.0I et
> 3.5.1 on NT 4.0 SP 3 and the binmode command failed the upload. The same
> script on Netscape Enterprise 2.0 don't bug? Have-you the same problem?
Since perl doesn't seem to have any problems (after all, it runs with
NS E 2), this cannot be a perl issue. You should ask this question on
a newsgroup where they talk about netscape servers. Try
news:secnews.netscape.com
or one of the comp.infosystems.www.* groups.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | In a world without fences, who needs
Commercial Dynamics Pty. Ltd. | Gates?
NSW, Australia |
------------------------------
Date: Fri, 27 Feb 1998 00:37:25 +0100
From: jlpoutre@inter.NL.net (Johannes la Poutre')
Subject: Re: CGI_lib.pl and upload bug ? on Enterprise 3
Message-Id: <jlpoutre-ya02408000R2702980037260001@news.leiden.nl.net>
In article <6d40fp$k6u$1@nnrp2.dejanews.com>, mgui@iname.com wrote:
>I use the CGI_lib.pl module to upload files on Netscape Enterprise 3.0I et
>3.5.1 on NT 4.0 SP 3 and the binmode command failed the upload. The same
>script on Netscape Enterprise 2.0 don't bug? Have-you the same problem?
>
>In my script i use :
><FORM ACTION METHOD="POST" ENCTYPE="multipart/form-data">
><INPUT type="file" name="UploadedFiles" size="30">
>
I don't know of any CGI_lib.pl module, but if you are talking about the
cgi_lib.pl library you *might* take a look at the CGI.pm moduel, esp. the
"compatibility" mode with the old cgi_lib stuff.
If you're using Perl 5.004 (and you do, don't you ;-) it's already
installed: type perldoc CGI.
--
Johannes la Poutre', NL
------------------------------
Date: 26 Feb 1998 22:54:36 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: checking versions of dll files
Message-Id: <6d4rrc$886$7@comdyn.comdyn.com.au>
In article <6d44il$mcs$1@nnrp2.dejanews.com>,
hillr@ugsolutions.com writes:
> I am a newbe to programming/perl and I would like to know if anyone has a way
> to check the version number of a dll file for windows NT using perl for WNT.
You might want to have a look at the Win32 specific perl modules on CPAN:
http://www.perl.com/CPAN/modules/
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | Very funny Scotty, now beam down my
Commercial Dynamics Pty. Ltd. | clothes.
NSW, Australia |
------------------------------
Date: Fri, 27 Feb 1998 10:52:30 +1100
From: Jaime Metcher <metcher@spider.herston.uq.edu.au>
Subject: Re: Copying to a NT-server using C$
Message-Id: <34F6003E.80D0C569@spider.herston.uq.edu.au>
fabian.van.der.spek@psb.nl wrote:
>
> Can anyone tell me how I can copy files to another machine?
>
> The DOS-batch I use works fine, but I cannot call the batch from a
> Perl-script, the dos-batch is:
>
> for /F %i% in (servlist.txt) do xcopy ..\somedir\*.htm
> \\%i%\c$\inetpub\wwwroot\samedir\home
>
> The perl syntax I have tried is:
>
> @test2=("for", "\/F", "\%i", "in", "($serverlist)", "do", "xcopy",
> "c\:\\distribu\.tie\\somedir\\home\\\*\.htm",
> "\\\\%i\\c\$\\inetpub\\wwwroot\\samedir\\home"); system(@test2);
>
> The $serverlist refers to a file with servernames.
>
> Thanks for helping!
>
> Fabian
>
1. Try using single quotes: "\%i" eq '%i'
This will save you a lot of backslashing.
2. "\\\\%i\\c\$\\inetpub\\wwwroot\\samedir\\home" should begin with
*five* backslashes. The first two pairs boil down to \\, so there's
nothing escaping the %. *However*, there seems to be another level of
interpolation happening in system(), so you really need to say:
'\\\\%i\\c$\\inetpub\\wwwroot\\samedir\\home' - note single quotes.
3. If you're doing this from PerlScript, meaning a web browser, you'll
probably run into file permission hassles.
4. As an alternative suggestion, why not just put the whole ugly mess
into a .bat file and say
system ('ugly.bat');
5. As an even wilder alternative, why not write the whole thing in perl?
--
Jaime Metcher
------------------------------
Date: 26 Feb 1998 23:19:49 GMT
From: David Fetter <dfetter@shell4.ba.best.com>
Subject: Re: Easy way to "clean" an array
Message-Id: <6d4tal$bth$1@nntp1.ba.best.com>
Schwitter Ruedi <Ruedi.Schwitter@schweiz.org> wrote:
> Hi
> I have a sorted array with duplicated entrys, like
> 006621
> 006621
> 006622
> 006623
> 006623
> 006623
> 006624 usf.
> Witch is the easiest way to check out the duplicated entrys ?
> --
> Regards Ruedi
> ----------------------------------------------------------------
> Ruedi.Schwitter@schweiz.org Tel: +41 56 205 59 40
> Haselstrasse Fax: +41 56 205 21 21
> CH-5400 Baden
> ---------------------------------------------------------------
--
David Fetter 888 O'Farrell Street Apt E1205
shackle@ren.glaci.com San Francisco, CA 94109-7089 USA
http://www.best.com/~dfetter +1 415 567 2690 (voice)
print unpack ("u*",q+92G5S="!!;F]T:&5R(%!E<FP@2&%C:V5R"@``+)
Cuius testiculos habes, habeas cardia et cerebellum.
------------------------------
Date: 26 Feb 1998 22:37:10 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Getting Directory Listing
Message-Id: <6d4qqm$886$4@comdyn.comdyn.com.au>
In article <34F53C05.A9898472@haifa.vnet.ibm.com>,
Naama Kraus <naamah@haifa.vnet.ibm.com> writes:
> Alex wrote:
>
>> Anyone know howto read a directory listing into an array?
>> Thanks.
>
> @Array = `ls`;chomp @Array;
> Naama. --> naamah@haifa.vnet.ibm.com
I want my script to run on VMS or a Mac. Hey.. your solution doesn't
work? Odd. It doesn't even work on NT. Odd.
There is a solution that doesn't require system specific calls. other
people have already posted it.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | In a world without fences, who needs
Commercial Dynamics Pty. Ltd. | Gates?
NSW, Australia |
------------------------------
Date: Thu, 26 Feb 1998 18:52:25 -0500
From: spooler <seven7seas@ibm.net>
Subject: help- Can't modify hash file?
Message-Id: <34F60039.2E20@ibm.net>
hello all,
My sixth sense tells me I'm doing something very wrong
here and the lack of output is another realiable indication |:-)
It's just an initial HoH exercise with the purpose of changing
one or more fields in a given hash file. The field in question
is 'packed=599' to change to say 'packed=199'. It happens
in memory but that's where Hash o'Hash becomes My o'My
... or words to that effect.
Sorry about the whole clip being here but I know the likely
response temperatures that would else a-rise.
Thanks, email appreciated also.
=================================
Please remove the 7 from my address
=================================
-|- Who, has loved us more? -|-
--------------------------------------------------------------
#!/usr/local/bin/perl
print"Content-type:text/html\n\n";
print"<html><head><title>HashHash-Practice</title></head>";
print"<body background=\"/media/gen/gif/bg8.gif\" text=\"#000000\"
link=\"#0000ff\"vlink=\"#ff0000\">";
#file mydat.txt {just 2 lines}
#thisbarcode: packed=599 quant=to-overwrite pictureloc=/gif/
kilos=0.61
#stamps: zip=64536475 exchange=1.28 country=us language=perl
#inevitable output:
#read-file mydat.txt thisbarcode: packed = 599
#change $hashmap{"thisbarcode"}{"packed"} to 199
#read-memory HoHo thisbarcode: packed = 199
#write 199 to file hoho.txt
#read-file hoho.txt thisbarcode: packed = 599
$readid="mydat.txt";
$writeid="mydat.txt";
#$readid="hoho.txt"; #tried every which way but right!
#$writeid="hoho.txt";
$nuval=199;$hashmap="HoHo";
print "read-file $readid ";&readhash;&printhash;
print"change \$hashmap{\"thisbarcode\"}{\"packed\"} to $nuval<br>";
$hashmap{"thisbarcode"}{"packed"}=$nuval;
print "read-memory $hashmap ";&printhash;&writehash;
print "write $nuval to file $writeid <br>";
$readid=$writeid;
print "read-file $readid ";&readhash;&printhash;
sub readhash {
open (Pandora, "</usr/local/httpd/strdat/$readid");
while (<Pandora>){
next unless s/^(.*?):\s*//;
$header=$1;
$rec = {};$hashmap{$header}=$rec;
for $fieldpair (split){
($keyfield, $valuefield) = split /=/, $fieldpair;
$hashmap{$header}{$keyfield}=$valuefield;
$rec->{$keyfield} = $valuefield;}}
close (Pandora);}
sub writehash {
open (Pandora, ">/usr/local/httpd/strdat/$writeid");
foreach $header (sort keys %hashmap) {
print Pandora "$header: ";
foreach $keyfield (keys%{$hashmap{$header}}){
print Pandora "$keyfield=$hashmap{$header}{$keyfield} ";
print Pandora"\n";}
close(Pandora);}
sub printhash {
foreach $header (sort keys %hashmap){
if ($header eq "thisbarcode"){
print"$header: ";}
foreach $keyfield (sort keys %{$hashmap{$header}}){
if ($keyfield eq "packed"){
print"$keyfield = $hashmap{$header}{$keyfield}<br>";}}}}}
print"</body></html>";
----------------------------------------------------------------
------------------------------
Date: Thu, 26 Feb 1998 14:08:22 -0500
From: Abdo Hashem <abdo.hashem@teradyne.com>
Subject: How do I store a directory tree
Message-Id: <34F5BDA6.98CEC6C3@teradyne.com>
I am trying to write code to store the following tree structure in PERL
and
seem to have hit a roadblock.
This would be similar to storing a directory tree.
Given the following list of indexes
1
1.1
1.2
1.2.1
1.2.2
1.2.3
1.3
1.3.1
1.3.2
1.4
2.0
3.0
etc...
How can I store this in a hash (or any data struct) which will show the
relationship between the different indices as I traverse the tree. And
to be able to dynamically
go down to lower levels in the tree.
i.e.
1 ---> 1.1
|
| ---> 1.2 ---> 1.2.1
| |---> 1.2.2
| |---> 1.2.3
|
| ---> 1.3 |---> 1.3.1
| |---> 1.3.2
|
| ---> 1.4
2 ---->
3 --- >
Thanks in Advance
Abdo
------------------------------
Date: Thu, 26 Feb 1998 14:06:11 -0500
From: Abdo Hashem <abdo.hashem@teradyne.com>
Subject: How do I store a directory tree
Message-Id: <34F5BD22.2F80BF4A@teradyne.com>
I am trying to write code to store the following tree structure in PERL
and
seem to have hit a roadblock.
This would be similar to storing a directory tree.
Given the following list of indexes
1
1.1
1.2
1.2.1
1.2.2
1.2.3
1.3
1.3.1
1.3.2
1.4
2.0
3.0
etc...
How can I store this in a hash (or any data struct) which will show the
relationship between the different indices as I traverse the tree. And
to be able to dynamically
go down to lower levels in the tree.
i.e.
1 ---> 1.1
|
| ---> 1.2 ---> 1.2.1
| |---> 1.2.2
| |---> 1.2.3
|
| ---> 1.3 |---> 1.3.1
| |---> 1.3.2
|
| ---> 1.4
2 ---->
3 --- >
Thanks in Advance
Abdo
------------------------------
Date: 27 Feb 1998 01:18:39 GMT
From: Zenin <zenin@best.com>
Subject: Re: How do I store a directory tree
Message-Id: <888542672.884286@thrush.omix.com>
Abdo Hashem <abdo.hashem@teradyne.com> wrote:
: How can I store this in a hash (or any data struct) which will show the
: relationship between the different indices as I traverse the tree. And
: to be able to dynamically go down to lower levels in the tree.
man perlref, perllol, and perldsc
--
-Zenin
zenin@best.com
------------------------------
Date: 26 Feb 1998 22:47:14 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Installing Problem?
Message-Id: <6d4rdi$886$5@comdyn.comdyn.com.au>
In article <34F4344D.A5A3A132@mbone1.kreonet.re.kr>,
manhee lee <mhlee@mbone1.kreonet.re.kr> writes:
> Hello,
>
> Does anyone know why I would be getting two 'FAILED' messages when
> running 'make
> test' for a perl 5.003 installation on a Solaris 2.5 machine?
Why are you trying to compile 5.003 when 5.004_04 is the current
version? It fixes lots of bugs, and adds some things. get it.
> There is no error in ./configure and make.
> but in 'make test', there are following 2 failed test.
> op/rand......FAILED on test 2
You probably have the wrong guess for RANDBITS. See 'man rand' for the
value you should give to the configure script. (On Solaris, probably
15)
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | I took an IQ test and the results were
Commercial Dynamics Pty. Ltd. | negative.
NSW, Australia |
------------------------------
Date: Thu, 26 Feb 1998 19:03:59 -0500
From: Reed Scarce <rscarce@hq.caci.com>
Subject: Re: Is perl -e broken? I found out, thanks
Message-Id: <34F602E8.DD2C507A@hq.caci.com>
HEY I downloaded all the headers and found the answers. Thanks alot,
they were from february 12th on.
Reed Scarce wrote:
> I'd like to run some one liners but I never get any std out or std
> error.
> From the prompt ('95 or NT)....
> C:\perl:>perl -e 'print "hello world\n";'
> C:\perl>
>
> that's all there is to it. -c tells me the syntax is fine, it does
> it
> in 5.? or 4.31. Many variations of quoting and content have resulted
> in
> errors or more of the same. More experienced perlsters have reported
> the same result.
>
> Is the -e switch broken?
>
> Thanks,
> Reed
------------------------------
Date: Thu, 26 Feb 1998 18:48:13 -0500
From: Reed Scarce <rscarce@hq.caci.com>
Subject: Is perl -e broken?
Message-Id: <34F5FF34.1419F71F@hq.caci.com>
I'd like to run some one liners but I never get any std out or std
error.
>From the prompt ('95 or NT)....
C:\perl:>perl -e 'print "hello world\n";'
C:\perl>
that's all there is to it. -c tells me the syntax is fine, it does it
in 5.? or 4.31. Many variations of quoting and content have resulted in
errors or more of the same. More experienced perlsters have reported
the same result.
Is the -e switch broken?
Thanks,
Reed
------------------------------
Date: 27 Feb 1998 01:36:33 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: Is perl -e broken?
Message-Id: <6d55b1$mog@mozo.cc.purdue.edu>
Reed Scarce <rscarce@hq.caci.com> writes:
}I'd like to run some one liners but I never get any std out or std
}error.
}From the prompt ('95 or NT)....
}C:\perl:>perl -e 'print "hello world\n";'
}C:\perl>
}that's all there is to it. -c tells me the syntax is fine, it does it
}in 5.? or 4.31. Many variations of quoting and content have resulted in
}errors or more of the same. More experienced perlsters have reported
}the same result.
}Is the -e switch broken?
You should probably know something right now: whenever working on '95
or NT, you are usually safe blaming MS for your troubles. Learn this
lesson quickly, for it will serve you well.
Take a gander at the perlrun man page. Executive summary: You have to
change your style of quoting, but it's difficult to explain how, since
MS really never made it clear in the first place.
This works for me:
perl -e "print qq{hello world\n};"
If it also works for you, the blame appears to lie in Redmond.
Oh yeah, you should probably be chastized for not looking in the
documentation yourself, but I consider the fact that you're trapped in
NT punishment enough.
--
Mike Gebis gebis@ecn.purdue.edu mgebis@eternal.net
------------------------------
Date: Fri, 27 Feb 1998 01:13:56 GMT
From: kschreff@harborcom.net (Schreffman)
Subject: Is there a way???
Message-Id: <34f712bf.5430572@nntp.harborcom.net>
In a Perl script running on NT, I want to check if another
process is running. For example, I want to check if xyz.exe is
currently executing?? Can this be done???
Thanks,
Ken
------------------------------
Date: Thu, 26 Feb 1998 15:16:51 -0800
From: ~arthur <star@sonic.net>
Subject: many ways but i can not find one
Message-Id: <34F5F7DF.7627@sonic.net>
one newbe said to the other
"i be newbe 2"
I am what some call a newbe. i kinda like it! But I need help!-please-
with formating.
Here is my program i am trying to print out a column of strings indented
by an amount the person inputs.
#!/usr/bin/perl -w
print "indent how much? ";
$i=<stdin>;
chomp $i;
$y=$i;
print "a list";
chomp (@a=<STDIN>);
foreach $x (@a) {
printf "%/$y/)s\n", $x;
}
i do not know printf (and can not find the man page)
Thanks,
~arthur Jacobs
star@sonic.net
------------------------------
Date: Thu, 26 Feb 1998 23:05:31 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Matching with the //o option
Message-Id: <34f5f2d3.12195107@news.tornado.be>
The //o option allows me to generate a pattern on the fly, and use this
efficiently in a regular expression matching. I assume that a regex has
a state with a boolean field, indicating if the pattern is already
compiled.
What I miss are the following possibilities:
* Detecting when the regex is compiled, e.g. to display a message with
the pattern. (read access to state)
* Having the possibility to reset this state, e.g. to use a certain
pattern for, say, all lines in a file, and then having the possibility
to change the pattern, and do the same for another file. Without having
to restart the entire script. (write access to state)
Now. Have I overlooked something, in other words: does this possibility
already exist? If not, would other people think this might be "nice", as
well?
Bart.
------------------------------
Date: 26 Feb 1998 19:26:20 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Matching with the //o option
Message-Id: <x7ogzt28r7.fsf@sysarch.com>
bart.mediamind@tornado.be (Bart Lateur) writes:
> The //o option allows me to generate a pattern on the fly, and use this
> efficiently in a regular expression matching. I assume that a regex has
> a state with a boolean field, indicating if the pattern is already
> compiled.
>
> What I miss are the following possibilities:
>
> * Detecting when the regex is compiled, e.g. to display a message with
> the pattern. (read access to state)
>
> * Having the possibility to reset this state, e.g. to use a certain
> pattern for, say, all lines in a file, and then having the possibility
> to change the pattern, and do the same for another file. Without having
> to restart the entire script. (write access to state)
>
> Now. Have I overlooked something, in other words: does this possibility
> already exist? If not, would other people think this might be "nice", as
> well?
most perl hackers who need the idea of /o and dynamically generated
regexes, use some form of eval to create them. this eliminates the
"restart" problem. the most common way is to generate an anonymous
subroutine which is passed the regex as an argument and does the regex
work. each one will have their own static regex.
untested example:
sub make_regex_sub {
my( $regex ) = @_ ;
return eval "sub { \$_[0] =~ /$regex/ }" ;
}
this has many problems (like / in the regex) but illustrates the idea.
you would use it like this:
$regex_sub = &make_regex_sub( $my_regex ) ;
@results = grep( &$regex_sub( $_ ), @input ) ;
hope this helps,
uri
--
Uri Guttman SYStems ARCHitecture and Software Engineering
uri@sysarch.com Have Perl, Will Hack
http://www.sysarch.com (781) 643-7504 x*2 FAX: (781) 643-2710
Try the Best Search Engine on the Net --------> http://www.northernlight.com
------------------------------
Date: 26 Feb 1998 23:50:12 GMT
From: ehood@medusa.acs.uci.edu (Earl Hood)
Subject: Re: Matching with the //o option
Message-Id: <6d4v3k$h3i@news.service.uci.edu>
In article <34f5f2d3.12195107@news.tornado.be>,
Bart Lateur <bart.mediamind@tornado.be> wrote:
>The //o option allows me to generate a pattern on the fly, and use this
>efficiently in a regular expression matching. I assume that a regex has
>a state with a boolean field, indicating if the pattern is already
>compiled.
...
> * Having the possibility to reset this state, e.g. to use a certain
>pattern for, say, all lines in a file, and then having the possibility
>to change the pattern, and do the same for another file. Without having
>to restart the entire script. (write access to state)
I encounter cases where I want a regex compiled once for a give
loop, but recompiled the first time the loop is entered.
The only way I know of to avoid the potential performance problems of
reevaluation each time is to use eval. The block of code in questions
can be built in a string with current regex to be used (with /o
modifier) and then evaled. That way the regex is compiled only once
for that particular execution of the block.
What I would like to have in Perl is to treat regex's as objects. This
way a regex can be compiled once, and then reused throughout your
code. I believe Python works this way. Maybe something like:
use Regex;
$regex = new Regex '^([\w\-]+):';
#...
($field) = $line =~ /$regex/;
($field2) = $line2 =~ /$regex/;
The key here is that $regex represents an already compiled regex.
So no regex compilation is needed in the pattern match operations
that use it.
--ewh
--
Earl Hood | University of California: Irvine
ehood@medusa.acs.uci.edu | Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME
------------------------------
Date: Thu, 26 Feb 1998 23:56:38 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Musings on English.pm
Message-Id: <Ep0FuE.F52@world.std.com>
schwern@starmedia.net writes:
>Why not make *MATCH, et al. a tied variable? The FETCH routine would use eval
>to cause $& not to be mentioned until $MATCH is actually used. Something
>like...
When someone wants to read from $English::MATCH, they expect it to
contain the matched text of the string. It gets that data by every
match operator making a copy and storing it. (It is the extra copy
that makes the script slow down.)
If you postpone accessing $& until runtime, then the copy is never
made, and the first access to $English::MATCH will not work correctly.
--
Andrew Langmead
------------------------------
Date: Fri, 27 Feb 1998 09:13:40 +1100
From: Jaime Metcher <metcher@spider.herston.uq.edu.au>
Subject: Netiquette
Message-Id: <34F5E914.C08866EE@spider.herston.uq.edu.au>
Off-topic - but in the hope of reducing off-topic traffic - I offer this
excerpt from "Rules for posting to Usenet", from news.announce.newusers.
quote:
It is never a good idea to
carry on "meta-discussions" about whether a given discussion is
appropriate -- such traffic mushrooms until nobody can find articles
that belong. If you are unhappy with what some user said, send him/her
mail, don't post it.
:unquote
Looking forward to lots of mail ;-)
--
Jaime Metcher
------------------------------
Date: Thu, 26 Feb 1998 20:19:48 -0500
From: Bob Trieger <corky@ma.ultranet.com>
To: "S. Sarkar" <s027119@income.com.sg>
Subject: Re: No. of days??
Message-Id: <34F614B4.2CCF@ma.ultranet.com>
S. Sarkar wrote:
>
> I am unable to find a way to calculate the nos. of days from today from any
> particular day in the past or the future. can any kind soul please help.
> the input format is yy/dd/mm or dd/mm/yy or mm/dd/yy
>
> need this done ASAP.
use the Date::DateCalc module.
It is included with Gurusamy Sarathy's port of perl for win32.
HTH
Bob Trieger
corky@ultranet.com
------------------------------
Date: Thu, 26 Feb 1998 21:08:02 -0500
From: Grimoire <grimoire@oaktree.net>
Subject: Re: removing new line (\n)
Message-Id: <Pine.LNX.3.95.980226210504.28416A-100000@harmony.oaktree.net>
On Sat, 21 Feb 1998, Zylbersztejn Nathan wrote:
> Hello,
>
> when I put the lines of a text in an @array how do i remove the "new
> line "(\n).
> s/\\n/ / doesn't work
> The problem is that when I want to print the last word of a line
>
> Nathan(brussels)
> http://www.imaginet.be/~nathan
I am fairly new to the whole Perl game, as it were, but it sounds like
your problem could be fixed by using 'chomp()'.
~grimoire
------------------------------
Date: Thu, 26 Feb 1998 18:56:38 -0600
From: gupit@yahoo.com
Subject: RPC example(perlxs) question/Extracting C struct
Message-Id: <6d5301$ejq$1@nnrp1.dejanews.com>
Hi,
I am trying to extend perl with a custom C library. I have been pouring over
all the XS documentation I could find.
In the perlxs manpage, I couldnot quite understand the difference between
T_PTROBJ and T_PTRREF in the context of the example presented.
The example typemaps the "struct netconfig*" return value of the function
getnetconfigent to a T_PTROBJ. As a result Perl considers netconfig* to
reference a blessed object. This allows the destructor to be called when this
reference goes out of scope.
My question is:
- The C function getconfigent returned a pointer to a structure. As far as
Perl is concerned, it just gets the pointer back from the C side. So how come
Perl can bless this object (structure) since it doenot understand structures.
- Next since getnetcopnfigent simply returns a pointer to a structure, perl
didnot really allocate any memory. So why should it bother to free it.
- There already exists a function freenetconfigent which is used to free the
structure previously allocated by getnetconfigent.
In the example destructor function code, free is used to deallocate the
memory. Shouldn't freeconfigent be called here?
- If I use T_PTRREF, what functionality am I losing?
I might be missing something simple here. Please do point it out to me in that
case.
Also,
The api I am working with, returns a pointer to a nested structure, ie a
structure within a structure.
- I don't want to write accessor functions to access the members of the
structure pointer returned. Is there an alternate way to access the members
of the C structure? I read that pack/unpack might not work as intended on
nested structures or even regular structures for that matter.
struct retstruct {
int a;
struct *nested b-array; /* This is an array of say 100 elements */
char c[10][10];
}
struct nested {
char d[100];
int e;
}
- I was thinking of walking the structure and repackaging it into a Perl data
structure. I was planning on using XPUSHs and sv_2mortal functions for this.
But I got stuck on how to push the b-array member on the stack.
- Also when a variable is tagged mortal and pushed onto stack, would it go
away after the current function call is complete.
Specifically,
@array = foo(....);
In foo, I use XPUSHs and sv_2mortal to push variable amount of data (returned
from a C function) on the stack. Now when foo comes back, would @array still
point to valid data? I am assuming it would, since @array still holds a
referece to it, even though it is on tmps_stack. Once I overwrite @array, only
then this data on tmps_stack would go away.
Please help.
Thanks in advance,
Gupit
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Fri, 27 Feb 1998 00:16:07 GMT
From: brian@brie.com (Brian Lavender)
Subject: Re: Running SQL from within Perl
Message-Id: <34f7053c.5094030@news.jps.net>
[mailed, posted]
Check my page
http://www.brie.com/coinduperl/
for an example of connecting to a database with perl. You can view the
source code. It uses mSQL written by David Hughes and the mSQL module
written by Andreas Koenig (sp?).
Brian
On Thu, 19 Feb 1998 20:10:42 -0500, "Kevin Bass"
<akil1@mindspring.com> wrote:
>How can I run a SQL program or script from within Perl? Please supply
>syntax and/or an example.
>
>Kevin
>
----------------
Brian Lavender http://www.brie.com/brian/
PO Box 19184, Sacramento,CA 95819-0814 (916) 443-6195
I am looking for a job in web development. See my home page.
CGI, PERL, HTML,SQL, GPS, GIS <--- Impressive or what :?
------------------------------
Date: Thu, 26 Feb 1998 19:37:57 -0500
From: Peter Shankey <shankeyp@charlestoncounty.org>
Subject: seeking and changing /etc/passwd
Message-Id: <34F60AE5.F4996301@charlestoncounty.org>
how can I seek a particular user in /etc/passwd then change the second
field from a "*" to a "!" when I only know the user's login name??
thanks
pete
------------------------------
Date: Thu, 26 Feb 1998 19:36:31 -0500
From: Peter Shankey <shankeyp@charlestoncounty.org>
Subject: seeking and changing /etc/passwd
Message-Id: <34F60A8F.78AEDA5E@charlestoncounty.org>
how can I seek a particular user in /etc/passwd then change the second
field from a "*" to a "!" when I only know the user's login name??
thanks
pete
------------------------------
Date: 27 Feb 1998 01:39:29 GMT
From: dmmartin@home.net (Michael Martin)
Subject: Re: seeking and changing /etc/passwd
Message-Id: <6d55gh$iqj$1@ha2.rdc1.sfba.home.com>
In article <34F60A8F.78AEDA5E@charlestoncounty.org>,
shankeyp@charlestoncounty.org says...
>
>how can I seek a particular user in /etc/passwd then change the second
>field from a "*" to a "!" when I only know the user's login name??
>
>thanks
>pete
>
try something like this:
__BEGIN__
$username = "foobar";
open(PASSWD, "+</etc/passwd");
while(<PASSWD>){
s/^$username:\*:/^$username:!:/;
last;
}
__END__
that snipit should work, although it is untested... Basicly it loops through
your shadowed password file and looks for the exact username you specified.
When it finds it, the script replaces the username and the * with the username
and a !.
HTH,
Philip Martin
------------------------------
Date: Thu, 26 Feb 1998 21:18:13 -0500
From: Grimoire <grimoire@oaktree.net>
Subject: Re: seeking and changing /etc/passwd
Message-Id: <Pine.LNX.3.95.980226211725.28416C-100000@harmony.oaktree.net>
On Thu, 26 Feb 1998, Grimoire wrote:
> On Thu, 26 Feb 1998, Peter Shankey wrote:
>
> > how can I seek a particular user in /etc/passwd then change the second
> > field from a "*" to a "!" when I only know the user's login name??
> >
> > thanks
> > pete
> I'm not sure if this is the correct answer, but it might point you in the
> right direction. This code bit is not tested.
>
>
> #!/usr/bin/perl -w
>
> $pw = '/etc/passwd';
> print "Login Name: ";
> chomp($login = <STDIN>);
> open(PW, $pw) || die "cannot open $pw: $!";
> while(<PW>){
> if (/^$a/oi){
^^ - should be $login
> ($user, $pass, $uid, $null, $rn, $home, $shell) =
> split(/:/, $_);
> if($pass eq "*"){
> $pass = '!';
> }
> }
> }
>
>
>
>
------------------------------
Date: Thu, 26 Feb 1998 23:07:20 +0000
From: Russell Schulz <Russell_Schulz@locutus.ofB.ORG>
Subject: Re: Simple Perl replacement for sendmail
Message-Id: <19980226.230720.6R6.rnr.w164w@locutus.ofB.ORG>
tucker@epnet.com (Kyle Tucker) writes:
> Here is Perl script written by Allen Canning of Pencom SA
> that does just what you want. Works very nicely.
I fear your opinion will change in almost 2 years.
> @rawdate = localtime(time);
> $date = "$Days{$rawdate[6]} $Months{$rawdate[4]} $rawdate[3]
> $rawdate[2]:$rawdate[1]:$rawdate[0]";
this will claim the year is `100' in 2000. the time structure, rather
unfortunately, has the `year-1900' as one of its elements, so you need
to undo this damage with `1900+'. of course, this means you can't do
it all via interpolation like this...
do you really want the times to look like `5:6:7'? I think a printf
is called for.
> # First we need our Greeting
> print STDOUT "$status{HELO} $hostname Server SMTP, Pleased to be
> speaking with you\n";
what happened to the CRLF (\015\010, not \r\n) RFC 821 specifies?
--
Russell_Schulz@locutus.ofB.ORG Shad 86c
------------------------------
Date: Fri, 27 Feb 1998 00:29:17 GMT
From: Gerben_Wierda@RnA.nl
Subject: Two questions about POD
Message-Id: <Ep0HCt.J6r@RnA.NL>
Hello World,
I am running 5.004.04
When I use POD to produce my man pages, and I write:
>=head1 DIAGNOSTICS
>
>=over 4
>
>=item Usage: gord_use.pl [--verbose=i] [--user=s] (active|inactive|test)
I get
>DIAGNOSTICS
>(active|inactive|test)
> Usage: gord_use.pl [--verbose=i] [--user=s]
How come? And can I do anything about that?
And my second question is, how come B<foo> doesn't produce boldface on my
system when I look at it, while I<bar> does produce an underline? What do I
have to change to make that work? (Bold does work on existing man pages).
Thanks,
--
Gerben_Wierda@RnA.nl (Gerben Wierda)
"If you don't know where you're going, any road will take you there"
Paraphrased in Alice in Wonderland, originally from the Talmud.
Dass man fuer die Philosophie ein Interesse zeigt, bezeugt noch keine
Bereitschaft zum Denken -- Martin Heidegger
------------------------------
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 1983
**************************************