[26704] in Perl-Users-Digest
Perl-Users Digest, Issue: 8804 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 28 11:05:28 2005
Date: Wed, 28 Dec 2005 08:05:05 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 28 Dec 2005 Volume: 10 Number: 8804
Today's topics:
"local @_ = @_;" for "pass-by-value"? <issakov@t-online.de>
'file changed'-event <news2132@8439.e4ward.com>
grep: \" and " both Give Errors <wh2leung@student.cs.uwaterloo.ca>
Re: How to print (2 & (1 * (2**32)))? <rvtol+news@isolution.nl>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 28 Dec 2005 14:10:51 +0100
From: Mihail <issakov@t-online.de>
Subject: "local @_ = @_;" for "pass-by-value"?
Message-Id: <dou2ss$497$01$1@news.t-online.com>
Hello,
again about sub{} behavior and "pass-by-call"/"pass-by-value".
Is it clean and recommended to use local @_ ?
sub {
local @_ = @_;
...
}
I do not like the way of fantasy arrays:
sub {
my @pass_by_value_workaround = @_;
...
}
It is ugly. But i still don't see clear advice how to do
"call-by-value"? And "local" things seems to change from
version to version.
Thank you.
Mihail
------------------------------
Date: Wed, 28 Dec 2005 16:57:43 +0100
From: Michael Goerz <news2132@8439.e4ward.com>
Subject: 'file changed'-event
Message-Id: <41fqvnF1c3e1gU1@uni-berlin.de>
Hi,
I'm trying to execute a sub whenever a certain file on the disk changes.
Currently, I'm doing this with an infinite loop that checks the modify
time (stat("$file"))[9]. While this works in principle, the infinite
loop drives the CPU crazy and speeds up the fan (very annoying).
Can I implement this with an event-based approach that doesn't drive up
my CPU? How?
Thanks,
Michael Goerz
------------------------------
Date: Wed, 28 Dec 2005 09:52:37 -0500
From: William <wh2leung@student.cs.uwaterloo.ca>
Subject: grep: \" and " both Give Errors
Message-Id: <Pine.GSO.4.64.0512280930540.29304@cpu02.student.cs.uwaterloo.ca>
In my perl script, I currently have:
#!/usr/bin/perl -w
use strict;
my $InputFileDir = "/mkapp/webapps/mxrt-cgi/upload_vol/upload_files/";
my $savedfilename = "trs_vol.txt.49.22.224.163.VERGAJ2.20050215.10.21.21";
my $filename = "trs_vol.txt";
my $originalList = $InputFileDir . $savedfilename;
my $originalListBack = $InputFileDir . $filename;
system "sed -e 's/^M//' $originalList | grep \"USD FNM\" > $originalListBack";
where $originalList is a file that contains:
|USD CHL|USD NYSE|Securities|1d|0|ATM|16.3194164633751|16.3194164633751|
|USD CHL|USD NYSE|Securities|3d|0|ATM|16.3215860724449|16.3215860724449|
|USD CHL|USD NYSE|Securities|1w|0|ATM|16.3243487477303|16.3243487477303|
|USD CHL|USD NYSE|Securities|2w|0|ATM|16.3260638713837|16.3260638713837|
|USD CHL|USD NYSE|Securities|3w|0|ATM|16.3272082805634|16.3272082805634|
|USD CHL|USD NYSE|Securities|1m|0|ATM|16.3357391953468|16.3357391953468|
|USD CHL|USD NYSE|Securities|3m|0|ATM|17.0192211866379|17.0192211866379|
|USD CHL|USD NYSE|Securities|4m|0|ATM|17.4577638506889|17.4577638506889|
|USD CHL|USD NYSE|Securities|6m|0|ATM|17.9224327206612|17.9224327206612|
|USD CHL|USD NYSE|Securities|9m|0|ATM|18.4148281812668|18.4148281812668|
$originalListBack is an (uncreated) file named trs_vol.txt
My problem: $originalListBack is not being created by this line:
system "sed -e 's/^M//' $originalList | grep \"USD FNM\" > $originalListBack";
I tried the following on the command line:
sed -e 's/^M//' trs_vol.txt.49.22.224.132.LEUNGW5.20051227.16.36.13 | grep
\"USD FNM\" > trs_vol.txt
but I got the following error message:
grep: can't open FNM"
Broken Pipe
However, if I try the following line on the command line, I got a 0 KB
trs_vol.txt file, which is what I desire.
sed -e 's/^M//' trs_vol.txt.49.22.224.132.LEUNGW5.20051227.16.36.13 | grep
"USD FNM" > trs_vol.txt
But if I remove the \ from the system "sed ..." line, then my Perl script
does not compile.
My question: what is the correct way to obtain a 0 KB trs_vol.txt file
using Perl (not command line)?
------------------------------
Date: Wed, 28 Dec 2005 14:32:57 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: How to print (2 & (1 * (2**32)))?
Message-Id: <dou7mu.1es.1@news.isolution.nl>
sonet schreef:
> print (2 & (1 * (2**32)));
>
> The result is 2 ??
perl -le 'print("2 & 2**", $_, ":\t", 2&2**$_)
for map(2**$_, 0..10)'
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 8804
***************************************