[18999] in Perl-Users-Digest
Perl-Users Digest, Issue: 1194 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 26 06:05:43 2001
Date: Tue, 26 Jun 2001 03:05:10 -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: <993549910-v10-i1194@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 26 Jun 2001 Volume: 10 Number: 1194
Today's topics:
Are there subroutine constants whose scope is like my f (Carlos C. Gonzalez)
Re: Are there subroutine constants whose scope is like <pne-news-20010626@newton.digitalspace.net>
Re: Are there subroutine constants whose scope is like nobull@mail.com
can use telnet and xml together in one program? <liuhui@nortelnetworks.com>
CGI string parameter passing <glodalec@yahoo.com>
Re: counting number of patterns (Tony L. Svanstrom)
disallow duplicates - doesn't work properly? <davsoming@lineone.net>
Re: disallow duplicates - doesn't work properly? (Anno Siegel)
Re: E-mail help <pne-news-20010626@newton.digitalspace.net>
Re: Edit-In-Place? <vlad@vladathome.com>
Re: Edit-In-Place? (Tad McClellan)
Email attachment with sendmail? <davsoming@lineone.net>
Re: Email attachment with sendmail? (Brian Pontz)
Re: Error Message (Anno Siegel)
Re: How do I cope with pound (currency) sign? <Deneb.Pettersson@lmf.ericsson.se>
Re: How do I cope with pound (currency) sign? (Bernard El-Hagin)
How I can use CVS? <mauri@netland.fi>
How to get env $HOME use perl <feiyun-arthur.wang@nokia.com>
Re: How to get env $HOME use perl <liuhui@nortelnetworks.com>
Re: How to get env $HOME use perl (Bernard El-Hagin)
Re: How to get env $HOME use perl <liuhui@nortelnetworks.com>
Re: MySQL Question <SiStie@nuclear-network.com>
Re: Perl CGI - capturing return values with system call <bart.lateur@skynet.be>
Re: Perl variable <jurgenex@hotmail.com>
problam installing JPL okumura@cslab.kecl.ntt.co.jp
Re: Problem reading large files (dumb question?) (Richard J. Rauenzahn)
Re: Problem with Archive::Tar <bart.lateur@skynet.be>
Re: problems with reading a file from a directory (David Efflandt)
Re: puzzled over fork() doing something different to bo (Villy Kruse)
range operator in scalar context - how to make it true? <johnlin@chttl.com.tw>
Re: range operator in scalar context - how to make it t <joe+usenet@sunstarsys.com>
Re: range operator in scalar context - how to make it t <johnlin@chttl.com.tw>
reg expr <troyr@vicnet.net.au>
Re: reg expr <wyzelli@yahoo.com>
Solaris + Perl : function "system" <laeti@cotranet.com>
Re: splice/Join and split!! (Philip Lees)
weird hash behaviour. (Entropy)
Re: weird hash behaviour. <uri@sysarch.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 26 Jun 2001 05:59:42 GMT
From: miscellaneousemail@yahoo.com (Carlos C. Gonzalez)
Subject: Are there subroutine constants whose scope is like my for that subroutine??
Message-Id: <3b3823a2.3412993@news.edmonton.telusplanet.net>
Hi All,
Are there constants that I can define inside a subroutine that will
only be seen by code inside that sub???
use constant NUMBER => "0";
sub MyFunc
{
use constant NUMBER => "1";
...
}
where both NUMBER constants will retain their values and be distinctly
different in scope? The first NUMBER will be visitble outside of sub
MyFunc while the second NUMBER constant will only be visible inside
MyFunc??
Carlos
www.internetsuccess.ca
------------------------------
Date: Tue, 26 Jun 2001 09:52:28 +0200
From: Philip Newton <pne-news-20010626@newton.digitalspace.net>
Subject: Re: Are there subroutine constants whose scope is like my for that subroutine??
Message-Id: <rkfgjt0ii60etba4rhi06l8bvj77230mn7@4ax.com>
On Tue, 26 Jun 2001 05:59:42 GMT, miscellaneousemail@yahoo.com (Carlos
C. Gonzalez) wrote:
> use constant NUMBER => "0";
>
> sub MyFunc
> {
> use constant NUMBER => "1";
> ...
> }
>
> where both NUMBER constants will retain their values and be distinctly
> different in scope? The first NUMBER will be visitble outside of sub
> MyFunc while the second NUMBER constant will only be visible inside
> MyFunc??
I think not like that, since lexical subroutines aren't allowed in Perl
yet. (You could have lexical references to subroutines, but they
wouldn't be optimised in the same way as subroutines returning a
constant value).
However, you could use a variable, for example like this:
my $NUMBER = 0;
{ my $NUMBER = 1;
sub MyFunc
{
# use $NUMBER
}
}
The scope means that the inner $NUMBER is visible only to MyFunc, while
the outer $NUMBER is visible to other code.
Cheers,
Philip (or wait for Perl6 and "my $NUMBER is constant")
--
Philip Newton <nospam.newton@gmx.li>
Yes, that really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: 26 Jun 2001 09:09:22 +0100
From: nobull@mail.com
Subject: Re: Are there subroutine constants whose scope is like my for that subroutine??
Message-Id: <u9wv5z3bnx.fsf@wcl-l.bham.ac.uk>
miscellaneousemail@yahoo.com (Carlos C. Gonzalez) writes:
> Are there constants that I can define inside a subroutine that will
> only be seen by code inside that sub???
No. Constantants in Perl are implemented as functions (aka
subroutines). Functions in Perl are always package scope, there are
no lexically scoped subroutines (yet).
> use constant NUMBER => "0";
>
> sub MyFunc
> {
> use constant NUMBER => "1";
> ...
> }
>
> where both NUMBER constants will retain their values and be distinctly
> different in scope?
Only by giving MyFunc it's own package.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 26 Jun 2001 13:51:14 +0100
From: "Liu Hui" <liuhui@nortelnetworks.com>
Subject: can use telnet and xml together in one program?
Message-Id: <9h97t4$j1n$1@crchh14.us.nortel.com>
Somebody said we can not use Net::Telnet and XML::Simple together in one
program.
I am quite confusing about it and I do not know why.
Give me some advice.
Thanks!
------------------------------
Date: Tue, 26 Jun 2001 10:58:06 +0200
From: Marvin <glodalec@yahoo.com>
Subject: CGI string parameter passing
Message-Id: <MPG.15a26cf0f7b88f6d9896d5@news.siol.net>
Hi !
Is there any CGI function which translate regular string "bla bla bla"
into "bla+bla+bla". There is a lot of conversion needed (some characters
need to be translated into %<code> etc..), so I would use regular exp.
substitute as a final solution.
The reason I need this is to make reference manualy as an anchor rather
than thru <INPUT ... command.
Regards
------------------------------
Date: Tue, 26 Jun 2001 03:06:19 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: counting number of patterns
Message-Id: <1evlffz.v10709j1xaeyN%tony@svanstrom.com>
les ander <les_ander@yahoo.com> wrote:
> 1) how do i count the number of patterns in a string?
From ze friendly files that comes with ze installation...
$count = ($paragraph =~ s/Mister\b/Mr./g);
> 2) say i have a string called $pattern
>
> and i need to replace all occurences of $pattern in $str
Do a RTFM on 's' (as in the example above).
/Tony
--
########################################################################
I'm sorry, I'm sorry; actually, what I said was:
HOW WOULD YOU LIKE TO SUCK MY BALLS?
- South Park -
------------------------------
Date: Tue, 26 Jun 2001 05:08:28 +0100
From: "David Soming" <davsoming@lineone.net>
Subject: disallow duplicates - doesn't work properly?
Message-Id: <tjg29kk6l19eec@corp.supernews.co.uk>
########## CHECK EXISTING EMAIL ADDRESSES FOR DUPLICATES BEFORE WRITING TO
DATABASE ##########
open (EMAILS, ">>"."address.txt") or die ("Can't open $emails: $!"); #open
the file in read/write mode "."
flock (EMAILS, 2);
seek (EMAILS, 0, 0); # rewind
my $found = 0;
while (<EMAILS>) {
chomp;
if (/^$email{'address'}$/i) {
$found++;
last;
}
}
if ($found) {
$errormessage = "The address you entered, <B>$email{'address'}</B> is
already in our mailing list";
} else {
seek (EMAILS, 0, 2); # fast forward to eof
print EMAILS "$email\n";
}
close (EMAILS); # flock (EMAILS, 8) not needed or advised!
#------------------------------------------------------------
This is part of my perl program allowing users to subscribe to a newsletter
(complete with error checking etc.)
I wish to return $errormessage (defined globally) if any dupes found, and
NOT write to address.txt
However it still writes, despite the fact that a dup exists.
Could someone please explain or show me what might be wrong?
Thanks
--
David Soming
'Just a head-banger- doing what I do best'
______________
------------------------------
Date: 26 Jun 2001 08:29:31 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: disallow duplicates - doesn't work properly?
Message-Id: <9h9h5b$6s$1@mamenchi.zrz.TU-Berlin.DE>
According to David Soming <davsoming@lineone.net>:
> ########## CHECK EXISTING EMAIL ADDRESSES FOR DUPLICATES BEFORE WRITING TO
> DATABASE ##########
> open (EMAILS, ">>"."address.txt") or die ("Can't open $emails: $!"); #open
> the file in read/write mode "."
Your comment says "read/write" but your code says "append". You *do*
need read/write.
[rest snipped]
Anno
------------------------------
Date: Tue, 26 Jun 2001 08:57:29 +0200
From: Philip Newton <pne-news-20010626@newton.digitalspace.net>
Subject: Re: E-mail help
Message-Id: <q7cgjto1iehna8estsc9sb08sm3q23assf@4ax.com>
On Mon, 25 Jun 2001 17:00:55 -0400, tadmc@augustmail.com (Tad McClellan)
wrote:
> Blnukem <blnukem@hotmail.com> wrote:
> >print MAIL "Cc:$FORM{'cc1'}, $FORM{'cc2'}, $FORM{'cc3'}\n";
> ^^
> ^^
> Where's the space?
What space? RTFRFC :) [1]
Cheers,
Philip
[1] By my understanding, RFC 822 allows whitespace between any two
tokens, but does not require it if the tokens are unambiguously
separated. RFC 2822 is a bit more explicit about where FWS or CFWS
([comments plus] folding whitespace) are allowed, but even there, the
syntax is <"Cc:" address-list CRLF>, and the address-list consists of
things that ultimately start with [CFWS], i.e. optional CFWS. See also
example A.5 in RFC 2822 and comments (2) and (3) under that example.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
Yes, that really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Tue, 26 Jun 2001 02:00:59 GMT
From: Vladimir Jebelev <vlad@vladathome.com>
Subject: Re: Edit-In-Place?
Message-Id: <Pine.LNX.4.10.10106252156160.6339-100000@vladathome.com>
Hi Edward,
> Anyone have some pet PERL code to edit a document in place? In other words,
> take the document and edit it without making another file, the same way a
> text-editor or work-processor would do?
here is what I usually do to edit a file in place, e.g. to replace all
'dog' with 'cat':
perl -pi -e 's/dog/cat/g' file
Vlad Jebelev
------------------------------
Date: Mon, 25 Jun 2001 22:47:49 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Edit-In-Place?
Message-Id: <slrn9jftul.e4j.tadmc@tadmc26.august.net>
Edward K Dodge <ekdodge@plxw0541.pdx.intel.com> wrote:
>
>I like to do things "old school" with shell commands
Me too.
>because that is easier
>for me to do most of what I need to do. Unfortunately all this "power of
>UNIX" has seriously degraded what few PERL skills I do have.
I'm not following that part at all...
_I_ like command lines instead, 'cause if I have to be there to
click on something, it isn't automated enough :-)
>Anyone have some pet PERL code to edit a document in place? In other words,
>take the document and edit it without making another file, the same way a
>text-editor or work-processor would do?
# a crude dos2unix, for instance
perl -p -i -e 'tr/\r//d' file1 file2 ...
>Any help would be appreciated...
Read all about perl's handy command line switches:
perldoc perlrun
See also the Perl FAQ, part 5:
"How do I change one line in a file/
delete a line in a file/
insert a line in the middle of a file/
append to the beginning of a file?"
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 26 Jun 2001 05:53:19 +0100
From: "David Soming" <davsoming@lineone.net>
Subject: Email attachment with sendmail?
Message-Id: <tjg4tnir1kqvf0@corp.supernews.co.uk>
Email attachment with sendmail?
My program below works just fine but is it also possible to send an
attachment with sendmail?
How?
print "Content-type: text/html\n\n";
print "Your email address ($email) has been successfully entered for our
newsletter.\t";
print "Thank you. You will receive a confirmation email shortly.";
$from = "newsletter\@sorted2000-data-security.com";
open (MAIL, "|/usr/sbin/sendmail -t") || &ErrorMessage;
print MAIL "To: $email \nFrom: $from\n";
print MAIL "Confirmation Email\n\n";
print MAIL "Thank you for signing up. Your email address ($email) has
been added successfully!\n\n";
print MAIL "Have a nice day.\n";
close (MAIL);
sub ErrorMessage {
print "<P>The server has a problem. Aborting script. \n";
exit;
}
Thanks
--
David Soming
'Just a head-banger- doing what I do best'
______________
------------------------------
Date: Tue, 26 Jun 2001 06:01:48 GMT
From: pontz@NO_SPAMchannel1.com (Brian Pontz)
Subject: Re: Email attachment with sendmail?
Message-Id: <3b3824a5.293343337@news.ne.mediaone.net>
>Email attachment with sendmail?
>My program below works just fine but is it also possible to send an
>attachment with sendmail?
>How?
http://www.perl-news.com/search/search-perl?new=Sending+Attachments+Via+Sendmail
Brian
------------------------------
Date: 26 Jun 2001 10:01:33 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Error Message
Message-Id: <9h9mht$82v$1@mamenchi.zrz.TU-Berlin.DE>
According to Dale Bohl <dbohl@sgi.com>:
>
> Can anyone please explain what exactly this means?
> I'm seeing this in stdout when I run a piece of
> perl code.
>
> Subroutine _MIPS_FPSET redefined at (eval 46) line 1 (#1)
[snip]
What's to explain? You redefined a subroutine, that is, your code
executed "sub _MIPS_FPSET {..." when the sub _MIPS_FPSET was already
defined. Unless you actually intend to replace the subroutine by
something else at runtime, you are probably loading the same file
twice via "do", or you are loading two versions of the same file
via "require" or "use" (or a combination thereof).
Anno
------------------------------
Date: Tue, 26 Jun 2001 09:00:19 +0300
From: Deneb Pettersson <Deneb.Pettersson@lmf.ericsson.se>
Subject: Re: How do I cope with pound (currency) sign?
Message-Id: <3B3824F3.7968BCD0@lmf.ericsson.se>
> --
> @P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
> @p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
> ($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
> close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
Hmmm, have seen that code somewhere before........
------------------------------
Date: Tue, 26 Jun 2001 06:14:02 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: How do I cope with pound (currency) sign?
Message-Id: <slrn9jg9mo.112.bernard.el-hagin@gdndev25.lido-tech>
On Tue, 26 Jun 2001 09:00:19 +0300, Deneb Pettersson
<Deneb.Pettersson@lmf.ericsson.se> wrote:
>
>
>> --
>> @P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
>> @p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
>> ($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
>> close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
>
>Hmmm, have seen that code somewhere before........
Yes, in every MJD post.
Cheers,
Bernard
--
perl -l54e's yyw q q tvmrx "h\ywx ersxliv zivp legoiv"qiy;y #a-zA-Z#d-gu-z#
chefghijklmnopqrstuvwxyzcJab-def-uPwxyzc;s j j s u u s t t s r r s
ppevalpereeteueje'
------------------------------
Date: Tue, 26 Jun 2001 12:31:32 +0300
From: Mauri Heinonen <mauri@netland.fi>
Subject: How I can use CVS?
Message-Id: <3B385674.7B2510E0@netland.fi>
Help me!
How I can use CVS?
I can't set CVSROOT, how I can do that?
-mauri
------------------------------
Date: Tue, 26 Jun 2001 04:20:15 GMT
From: "Wang Feiyun-Arthur" <feiyun-arthur.wang@nokia.com>
Subject: How to get env $HOME use perl
Message-Id: <34UZ6.15070$cF.329723@news1.nokia.com>
In Perl file.
How can I get my env $HOME
I tried
$home=$HOME;
and
$home=`echo $HOME`;
but does not work.
------------------------------
Date: Tue, 26 Jun 2001 14:43:34 +0100
From: "Liu Hui" <liuhui@nortelnetworks.com>
Subject: Re: How to get env $HOME use perl
Message-Id: <9h9av5$kn7$1@crchh14.us.nortel.com>
try to use 'system' function. system($command)
e.g.
system("ls>file");
system('echo $HOME > file');
use perldoc to get more information
"Wang Feiyun-Arthur" <feiyun-arthur.wang@nokia.com> wrote in message
news:34UZ6.15070$cF.329723@news1.nokia.com...
> In Perl file.
>
> How can I get my env $HOME
>
> I tried
>
> $home=$HOME;
> and
> $home=`echo $HOME`;
>
> but does not work.
>
>
------------------------------
Date: Tue, 26 Jun 2001 06:59:14 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: How to get env $HOME use perl
Message-Id: <slrn9jgcbh.112.bernard.el-hagin@gdndev25.lido-tech>
On Tue, 26 Jun 2001 14:43:34 +0100, Liu Hui <liuhui@nortelnetworks.com> wrote:
>"Wang Feiyun-Arthur" <feiyun-arthur.wang@nokia.com> wrote in message
>news:34UZ6.15070$cF.329723@news1.nokia.com...
>> In Perl file.
>>
>> How can I get my env $HOME
>>
>> I tried
>>
>> $home=$HOME;
>> and
>> $home=`echo $HOME`;
>>
>> but does not work.
>
>try to use 'system' function. system($command)
>e.g.
>system("ls>file");
>
>system('echo $HOME > file');
>
>use perldoc to get more information
That's silly. Why not just use the special %ENV hash?
print $ENV{'HOME'};
Cheers,
Bernard
--
perl -l54e's yyw q q tvmrx "h\ywx ersxliv zivp legoiv"qiy;y #a-zA-Z#d-gu-z#
chefghijklmnopqrstuvwxyzcJab-def-uPwxyzc;s j j s u u s t t s r r s
ppevalpereeteueje'
------------------------------
Date: Tue, 26 Jun 2001 15:09:28 +0100
From: "Liu Hui" <liuhui@nortelnetworks.com>
Subject: Re: How to get env $HOME use perl
Message-Id: <9h9cfk$lhb$1@crchh14.us.nortel.com>
Or try to use Env.
Env - perl module that imports environment variables
use perldoc Env for more info
"Wang Feiyun-Arthur" <feiyun-arthur.wang@nokia.com> wrote in message
news:34UZ6.15070$cF.329723@news1.nokia.com...
> In Perl file.
>
> How can I get my env $HOME
>
> I tried
>
> $home=$HOME;
> and
> $home=`echo $HOME`;
>
> but does not work.
>
>
------------------------------
Date: Mon, 25 Jun 2001 19:30:29 +0200
From: Simon Stiefel <SiStie@nuclear-network.com>
Subject: Re: MySQL Question
Message-Id: <Pine.LNX.4.31.0106251929260.2058-100000@server.stiefel.priv>
On Mon, 25 Jun 2001, Todd Smith wrote:
> > So, now all ID's with the status "r" should be fetched in an array.
>
> > How can I do this?
>
> $dbh =3D DBI->connect( ... );
> $sth =3D $dbh->prepare("select ID from table where status =3D 'r'");
> $sth->execute;
> while ( ($ID) =3D $sth->fetchrow_array ) {
> ....
> }
> $sth->finish;
> $dbh->disconnect;
>
Yes, it really works... Thank you!
Mit freundlichen Gr=FC=DFen, .~. Open Minds.
with best regards /V\ Open Sources.
// \\ Open Future!
Simon Stiefel /( )\_ I N U X
^ ~ ^
--=20
|Simon Stiefel | Zwerbachstrasse 17 | 72555 Metzingen-Glems | Germany |
|SimonStiefel@nuclear-network.com | http://www.nuclear-network.com |
|ICQ#: 20196644 | phone: +49(0)7123/379070 | fax: +49(0)179/335990106 |
|Tux#: 114751 | PingoS - Linux-User helfen Schulen | Powered by LiNUX |
------------------------------
Date: Tue, 26 Jun 2001 08:05:11 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Perl CGI - capturing return values with system calls
Message-Id: <m2ggjto42cnfuuhptbddejant7bfm7tcdq@4ax.com>
Miles Davenport wrote:
>system (ssh server myScript.sh).
>
>This script is not being executed consistently, as the previous command:
>system (scp filename.tar server:/directory) does not ALWAYS (seems to be if
>the tar file is large) return.
>
>My queries include:
>
>Is there a reliable way to capture the return from a system call to the perl
>environment ?
You mean like
$stdout = `ssh server myScript.sh`;
?
You need tricks like "2>&1" to capture STDERR as well.
>Has anyone ever had problems making system(scp) calls when the filesize is
>large - this may prevent control being returned to the perl env ?
This doesn't sound right. Perhaps it's not what is happening. Perhaps
it's the fact that you're calling ssh, which may or may not behave
differently than an ordinary program.
Oh BTW, I've read that Net::Telnet can handle ssh as well. I haven't
tried it yet, but you might want to check out chapter 6 in Lincoln
Stein's book "Network Programming with Perl". You're in luck, this one
chapter is available online.
<http://www.modperl.com/perl_networking/sample/ch6.html>. Check out the
subsection "Using Net::Telnet for non-Telnet Protocols", and the code of
fig. 6.6.
--
Bart.
------------------------------
Date: Mon, 25 Jun 2001 18:26:47 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Perl variable
Message-Id: <3b37e4d8$1@news.microsoft.com>
"Thierry" <nobody@nowhere.com> wrote in message
news:9h71i0$fnm$1@s1.read.news.oleane.net...
> I want to get the output of of a call to system()
Did you RTFM?
perldoc -f system
yields
The return value is [...].
This is *not* what you want to use to capture the output from a command,
for that you should use merely ....
[the rest is being left as an exercise to the reader]
jue
------------------------------
Date: Tue, 26 Jun 2001 17:27:53 +0900
From: okumura@cslab.kecl.ntt.co.jp
Subject: problam installing JPL
Message-Id: <010626172753.M0327330@saimpc01.icl.kecl.ntt.co.jp>
HI all.
I tried to install the JPL with perl5.6.1 on the redhat-linux7.0 and jdk1.3.0.
I had the following error message when I worked the Sample program of JPL
and I couldn't work it.
Do anyone have a idea ?.
//### error message ###
[root Sample]# pwd
/usr/local/src/perl-5.6.1/jpl/Sample
[root Sample]# ls
Makefile Makefile_old Sample.class Sample.java Sample.pl
Makefile.PL Sample.c Sample.h Sample.jpl libSample.so
[root Sample]# java Sample
# # An unexpected exception has been detected in native code outside
the VM.# Program counter=0x488ec2ab
#
# Problematic Thread: prio=1 tid=0x804dc10 nid=0x5c3a runnable
#
aborted.
-----------------------------------------------------
//### output "perl -V" ###
[root Sample]# perl -V
Summary of my perl5 (revision 5.0 version 6 subversion 1)
configuration:
Platform:
osname=linux, osvers=2.2.16-22, archname=i686-linux
uname='linux perlsys.cslab.kecl.ntt.co.jp 2.2.16-22 #1 tue aug 22
16:49:06 edt 2000 i686 unknown '
config_args=''
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
Compiler:
cc='gcc', ccflags ='-fno-strict-aliasing -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64',
optimize='-O2',
cppflags='-fno-strict-aliasing'
ccversion='', gccversion='2.96 20000731 (Red Hat Linux 7.0)',
gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define,
longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=4, usemymalloc=n, prototype=define
Linker and Libraries:
ld='gcc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -lgdbm -ldl -lm -lc -lcrypt -lutil
perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil
libc=/lib/libc-2.1.95.so, so=so, useshrplib=true,
libperl=libperl.so
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef,
ccdlflags='-rdynamic
-Wl,-rpath,/usr/local/lib/perl5/5.6.1/i686-linux/CORE'
cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'
Characteristics of this binary (from libperl):
Compile-time options: USE_LARGE_FILES
Built under linux
Compiled at Jun 22 2001 15:43:47
%ENV:
PERL5LIB="/usr/local/src/perl-5.6.1/jpl/perl"
@INC:
/usr/local/src/perl-5.6.1/jpl/perl
/usr/local/lib/perl5/5.6.1/i686-linux
/usr/local/lib/perl5/5.6.1
/usr/local/lib/perl5/site_perl/5.6.1/i686-linux
/usr/local/lib/perl5/site_perl/5.6.1
/usr/local/lib/perl5/site_perl
-----------------------------------------------------
------------------------------
Date: 25 Jun 2001 17:12:34 GMT
From: nospam@hairball.cup.hp.com (Richard J. Rauenzahn)
Subject: Re: Problem reading large files (dumb question?)
Message-Id: <993489153.48692@hpvablab.cup.hp.com>
"John W. Krahn" <krahnj@acm.org> writes:
>"Richard J. Rauenzahn" wrote:
>>
>> Or, simply...
>>
>> #!/opt/perl5/bin/perl -w
>> use strict;
>>
>> open OUT, ">d.dat" || die;
> ^^^^^^
>This doesn't do what you seem to think it does. You need to use "open()"
>or "or". to get die to do anything. You should also include the $!
>variable for a meaningful message.
Thanks -- I usually surround the open parms with ()'s but had gotten
lazy.
Rich
--
Rich Rauenzahn ----------+xrrauenza@cup.hp.comx+ Hewlett-Packard Company
Technical Consultant | I speak for me, | 19055 Pruneridge Ave.
Development Alliances Lab| *not* HP | MS 46TU2
ESPD / E-Serv. Partner Division +--------------+---- Cupertino, CA 95014
------------------------------
Date: Tue, 26 Jun 2001 09:11:37 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Problem with Archive::Tar
Message-Id: <bsjgjtsq01433g36eoh0onrkom4avcthdf@4ax.com>
Mr. Sunray wrote:
>However, when I try and extract the tar file on the
>command line, all I get is: "tar: Record size = 2 blocks", presumably
>because there were 2 files in my test (though I'm guessing).
No. That doesn't seem right. You seem like a Windows user, try and open
the tar file with WinZip or a similar utility.
I've had cases with an Archive::Tar version creating a corrupt tar file,
in some cases. However, this seems to work alright for me, although with
another (older) version of Archive::Tar. It could be one I patched,
myself, though. ;-)
Check out if this creates a valid archive for you.
use Archive::Tar;
my @files = glob 'test.*';
# or any other file pattern which matches at least a few files
{
my $tarfilename = "testfiles.tar";
my $tar = Archive::Tar->new() or
die "Unable to create tar archive: $!\n";
foreach my $file(@files){
$tar->add_files($file);
}
mkdir 'Archive', 0777;
$tar->write("Archive/$tarfilename")
or die "Couldn't write to tarfile: $!\n";
}
print "All's well, using Archive::Tar $Archive::Tar::VERSION\n";
p.s. If you want to run this by cron, remember to use fully qualified
file paths, or at least, chdir to the proper directory at the start of
the script.
--
Bart.
------------------------------
Date: Tue, 26 Jun 2001 01:09:20 +0000 (UTC)
From: see-sig@from.invalid (David Efflandt)
Subject: Re: problems with reading a file from a directory
Message-Id: <slrn9jfo60.h2e.see-sig@typhoon.xnet.com>
On 25 Jun 2001 17:02:49 -0700, Nina <nina_samimi@yahoo.com.au> wrote:
> Hi,
> I am trying to open a directory and read a file which is compressed(.Z).
> I am getting an error "Use of uninitialized value at qf_system_blast.pl line 179."
> what am I doing wrong?
> can I read a compressed file? or should it be uncompressed first?
> Here is the code I am using, please advise.
>
>
> my @tempdir;
> opendir(DIR, $mns_dir) || die("Cannot open directory");
> print "$DIR is my directory!!!!!!!!";
> while (my $tempfiles = readdir DIR) {
> print $tempfiles if $tempfiles =~ /RPTPRINT.MNS206AR.24Jun01_13.37.48.Z/;}
> closedir DIR;
$DIR is not defined here, is it defined elsewhere? Is that line 179?
--
David Efflandt (Reply-To is valid) http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: 26 Jun 2001 08:34:15 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: puzzled over fork() doing something different to book example
Message-Id: <slrn9jgi87.23h.vek@pharmnl.ohout.pharmapartners.nl>
On Mon, 25 Jun 2001 18:28:24 +0100,
Mark Grimshaw <m.grimshaw@salford.ac.uk> wrote:
>As you say, 'this is not an easy topic' and a combination of books, man,
>perldoc, my own experimentation and, as a final resort, answers from
>here usually leads me to the solution by collating some understanding
>from each. What throws me off my stride is when the example from a book
>does not do exactly what that book says it will do (I'll grant that the
>-l switch was a leftover from previous scripts that I didn't take out -
>the order of execution was still different without it), nor does the
>book state that the order of execution of processes may not be exactly
>that given. Perhaps I'm _too_ trusting of the documentation ;)
Probably. Sometimes the author of books simplifies things, and by
doing that they leave out some issues. Occasionally you'll find direct
mis-information, or just obsolete information that is no longer valid.
The authors of the books are after all just humans and do make mistakes
once in a while. With many years of experience and reading several
sources of information you will pick up the ability to tell the wheat
from the chaff.
Villy
------------------------------
Date: Tue, 26 Jun 2001 10:58:37 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: range operator in scalar context - how to make it true?
Message-Id: <9h8tl3$45e@netnews.hinet.net>
Dear all,
Recently I encountered a problem:
sub foo { /A/../Z/ }
$_ = 'A';
print "true" if foo; # Yes, I got "true", thanks.
But
sub foo { 10..20 }
$_ = 10;
print "true" if foo; # Sorry, the answer is "false"
According to the "perlop" document, I should compare against $.
sub foo { 10..20 }
$. = 10;
print "true" if foo; # Sorry, the answer is still "false"
What's wrong? I must have a misunderstanding here.
(or perl has a bug?) Could you help me?
Thank you.
John Lin
--
P.S. The sub works well in a loop.
sub foo { 10..20 }
$| = 1; while(<>) { print "true " if foo } # got 11 true's, good.
------------------------------
Date: 25 Jun 2001 23:40:51 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: range operator in scalar context - how to make it true?
Message-Id: <m37kxzsybg.fsf@mumonkan.sunstarsys.com>
"John Lin" <johnlin@chttl.com.tw> writes:
> Dear all,
>
> Recently I encountered a problem:
>
> sub foo { /A/../Z/ }
> $_ = 'A';
> print "true" if foo; # Yes, I got "true", thanks.
>
> But
>
> sub foo { 10..20 }
> $_ = 10;
> print "true" if foo; # Sorry, the answer is "false"
>
> According to the "perlop" document, I should compare against $.
>
> sub foo { 10..20 }
> $. = 10;
> print "true" if foo; # Sorry, the answer is still "false"
>
> What's wrong? I must have a misunderstanding here.
> (or perl has a bug?) Could you help me?
The association of $. with the
"last file handle from which you just read()" [sic]
is nebulous unless you've called _readline_ somewhere earlier in your
code. Note that perlvar is completely wrong about the association
of $. and read(). They are totally unrelated:
% perl -wle 'open $a=> shift; open $b=>shift; <$a>; read $b, $_, 1024;
print $.; print tr/\n//; print tell $b; print $.' /tmp/try.c /tmp/try.pl
1
35
1024
0
For it to work in conjunction with scalar "..", you need to fix $.'s
association with a filehandle. <>, readline(), tell(), and seek() will
do this:
% perl -wle 'tell *STDIN; $.=10; print "OK" if 10..20 '
Useless use of tell in void context at -e line 1.
OK
IMO $. should be clearly marked as deprecated. But you knew that already :-)
--
Joe Schaefer "Everything that can be invented has been invented."
-- Charles H. Duell
------------------------------
Date: Tue, 26 Jun 2001 16:53:28 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Re: range operator in scalar context - how to make it true?
Message-Id: <9h9ide$f31@netnews.hinet.net>
"Joe Schaefer" wrote
> "John Lin" writes:
> > sub foo { 10..20 }
> > $. = 10;
> > print "true" if foo; # Sorry, the answer is still "false"
> For it to work in conjunction with scalar "..", you need to fix $.'s
> association with a filehandle. <>, readline(), tell(), and seek() will
> do this:
>
> % perl -wle 'tell *STDIN; $.=10; print "OK" if 10..20 '
> Useless use of tell in void context at -e line 1.
> OK
>
> IMO $. should be clearly marked as deprecated. But you knew that already :-)
Thanks. To summarize:
perl -le "$.=10; print 'OK' if 10..20"
perl -le "tell STDIN; $.=10; print 'OK' if 10..20"
OK
perl -le "tell F; $.=10; print 'OK' if 10..20"
OK # any filehandle would do
It looks like the problem is not $. because its value is well-defined
and visible to the range-operator all through the process.
perl -le "$.=10; print 'OK' if 10..20; print $."
10
The problem is the range-operator doesn't look at the value at all,
unless the runtime is in a special status (reading file) which we
triggered by tell (or <>, seek ... etc).
I am surprised that this is a 'runtime' behavior which we can't
detect it at compile time.
Thank you very much.
John Lin
------------------------------
Date: Tue, 26 Jun 2001 11:56:55 +1000
From: "Troy Boy" <troyr@vicnet.net.au>
Subject: reg expr
Message-Id: <v%RZ6.11749$qJ4.478160@ozemail.com.au>
Hi there,
I have the following variable
$tmp="http://www.vicnet.net.au/~troyr/myfiles/index.html";
And what i want to do is only keep whats after the tilda sign...so only have
'troyr/myfiles/index.html'
this line does the reverse of what i want
print "test",($tmp=~/(.*)~/),"\n";
and this does it..but with too many lines of code
$index=index($tmp,"~");
$index++;
$subby=substr($tmp,$index);
print "$index\n$subby\n";
Does anyone know of a one liner solution?
Thanks in Advance
--
----------------------------------------------------------------
Troy Rasiah
Melbourne, Aus
------------------------------
Date: Tue, 26 Jun 2001 11:53:09 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: reg expr
Message-Id: <ThSZ6.35$eo1.1830@vic.nntp.telstra.net>
"Troy Boy" <troyr@vicnet.net.au> wrote in message
news:v%RZ6.11749$qJ4.478160@ozemail.com.au...
> Hi there,
> I have the following variable
>
> $tmp="http://www.vicnet.net.au/~troyr/myfiles/index.html";
>
> And what i want to do is only keep whats after the tilda sign...so only
have
> 'troyr/myfiles/index.html'
>
> this line does the reverse of what i want
> print "test",($tmp=~/(.*)~/),"\n";
So put the capture after the tilde...
print "test",($tmp=~/~(.*)/),"\n";
Read up on regular expressions. Chack perlre.
Wyzelli
--
push@x,$_ for(a..z);push@x,' ';
@z='092018192600131419070417261504171126070002100417'=~/(..)/g;
foreach $y(@z){$_.=$x[$y]}y/jp/JP/;print;
------------------------------
Date: Tue, 26 Jun 2001 10:24:27 +0200
From: Laeti <laeti@cotranet.com>
Subject: Solaris + Perl : function "system"
Message-Id: <3B3846BB.64CAAF8D@cotranet.com>
Hello,
I use Perl 5.6 with Solaris 2.8 (and Apache 1.3.19)
I have an issue with STDOUT/STDERR and the function "system".
When I execute my perl script with a browser :
- if data are writen in a file : I have a system error.
$error_system = system "ls -la >titi";
#$error_system -> 139 (128 + 11)
The swap or the memory are not full and the user has the good
rights.
- if data are writen in STDOUT -> "Internal Server Error"
$error_system = system "echo test";
- if nothing is writen in STDOUT : it is ok !
$error_system = system "touch test";
#$error_system -> 0
STDOUT is not ok :
print ( -t STDOUT ) ? "tty\n" : "no tty\n";
-> nothing...
print !(-t STDOUT) ? "pas tty\n" : "tty\n";
-> "no tty"
I tried to open STDOUT et STDERR but there is no improvement.
The files /tmp/out and /tmp/err are empty.
close STDOUT;
open (STDOUT, ">/tmp/out");
open (STDERR, ">/tmp/err");
When I execute my perl script with unix terminal : it is ok
(with the same user)
Any help would be most appreciated.
cheers,
Laetitia
------------------------------
Date: Tue, 26 Jun 2001 07:08:50 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: Re: splice/Join and split!!
Message-Id: <3b3834b6.2841415@news.grnet.gr>
On Fri, 22 Jun 2001 08:39:47 GMT, "John W. Krahn" <krahnj@acm.org>
wrote:
>Philip Lees wrote:
>>
>> On Thu, 21 Jun 2001 22:59:29 GMT, "John W. Krahn" <krahnj@acm.org>
>> wrote:
>>
>> >Michael Carman wrote:
>> >> if ($. == 6 .. $. == 9) {
>> > ^^^^^ ^^^^^^
>> >The "$. ==" part is superfluous.
>> >
>> > if ( 6 .. 9 ) {
>> >
>> Surely not - it should be checking $. not $_
>>
>> ... or am I missing something?
>
>From perlop:
>
> If either operand of scalar ".." is a
> constant expression, that operand is implicitly compared
> to the $. variable, the current line number. Examples:
>
> As a scalar operator:
>
> if (101 .. 200) { print; } # print 2nd hundred lines
Well thank you - I've learned something very useful.
Phil
--
Philip Lees
ICS-FORTH, Heraklion, Crete, Greece
Ignore coming events if you wish to send me e-mail
'The aim of high technology should be to simplify, not complicate' - Hans Christian von Baeyer
------------------------------
Date: 25 Jun 2001 21:03:52 -0700
From: brockh@ozemail.com.au (Entropy)
Subject: weird hash behaviour.
Message-Id: <6699d75d.0106252003.7208c1dd@posting.google.com>
OK,
now I actually think it is behaving properly, and I'm a moron... but I
just cant see what I'm going wrong.. Here is whats killing me, output
from debug:
DB<19> x $rldr
0 HASH(0x202738bc)
'BLvl' => 'm'
'Ctrl' => ' '
'Desc' => 'a'
'ELvl' => ' '
'RecStat' => 'c'
'Type' => 'a'
'Undef2ldr' => 0
'Undefldr' => ' 22'
'base_addr' => 00289
'len_impl' => ' '
'len_len_field' => 4
'len_start_char' => 5
'ln_rec' => ' '
'rec_len' => 00942
DB<20> x $rldr{'Desc'}
0 undef
DB<21> x $rldr{Desc}
0 undef
DB<22>
It says that rldr is a hash, good!
it has a key 'Desc', which has "a" in it.
but x $rldr{'Desc'} shows undef! So do all the other keys.
Am I moron? Is my perl broken? It's on a AIX box, and the hash is
generated off in a magical perl module... MARC.pm
Any ideas?
Brock Henry
PS: please reply as email brockh@ozemail.com as well if possible, I'm
anxious to fix this beasty.
------------------------------
Date: Tue, 26 Jun 2001 04:54:30 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: weird hash behaviour.
Message-Id: <x7g0cnaliw.fsf@home.sysarch.com>
>>>>> "E" == Entropy <brockh@ozemail.com.au> writes:
E> DB<19> x $rldr
E> 0 HASH(0x202738bc)
E> 'BLvl' => 'm'
E> 'Ctrl' => ' '
E> 'Desc' => 'a'
E> It says that rldr is a hash, good!
^
reference
E> but x $rldr{'Desc'} shows undef! So do all the other keys.
you are missing the -> to dereference $rldr. what you did above was a
lookup in the %rldr hash.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info: http://www.sysarch.com/perl/OOP_class.html
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 1194
***************************************