[24959] in Perl-Users-Digest
Perl-Users Digest, Issue: 7209 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 5 03:06:51 2004
Date: Tue, 5 Oct 2004 00:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 5 Oct 2004 Volume: 10 Number: 7209
Today's topics:
Building a Perl based online survey and data gathering, (George_V)
Re: Getopt::Long install problems <tadmc@augustmail.com>
Re: Getopt::Long install problems <kkeller-usenet@wombat.san-francisco.ca.us>
Re: Getopt::Long install problems (Harry)
Re: Getopt::Long install problems <tadmc@augustmail.com>
Re: How to flush a stinkin' socket? (your name here)
Re: initialize a list <notvalid@email.com>
Re: initialize a list <uri@stemsystems.com>
Perl books on tape (wana)
Re: Perl books on tape <tadmc@augustmail.com>
Re: Perl books on tape <abigail@abigail.nl>
Perl6 (Polu Kiran)
Re: regex error <see@sig.invalid>
Re: regex error <abigail@abigail.nl>
Regular Expression help please (Shane)
Re: Regular Expression help please <usa1@llenroc.ude.invalid>
Re: Regular Expression help please <tadmc@augustmail.com>
Re: Regular Expression help please <abigail@abigail.nl>
Re: use sed in perl <simon@unisolve.com.au>
Re: Which Counter is Perfect? <nntp@rogers.com>
Re: Which Counter is Perfect? <sholden@flexal.cs.usyd.edu.au>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 4 Oct 2004 23:53:05 -0700
From: George.Vidalis@its.monash.edu.au (George_V)
Subject: Building a Perl based online survey and data gathering, reporting and analysis tool
Message-Id: <cd616041.0410042253.54a74c1a@posting.google.com>
Hi all. First up - I'm not a programmer. I'm researching for an online
survey and data analysis tool for Monash University, Australia.
Our developers are keen on a Perl solution. I've found some Perl form
generators and basic survey tools, but we need something that has
powerful gathering, reporting and analysis capability.
I have included a wish list of our requirements, hopefully they'll
make enough sense to give you an idea of what we're after. If anyone
knows of a single Perl based package or any useful modules that could
be added onto a front end to build a complete package I would be most
grateful for your info.
Wishlist:
*Questions* based on a standardised 5-point scale (strongly agree ->
strongly disagree) + don't know/unable to judge and doesn't
apply/inappropriate.
*Flexibility*: We would like to create survey form templates that can
be easily adapted by untrained academic staff, to satisfy differing
evaluation requirements across various units. This may involve adding
or subtracting questions from the survey.
*Distribute and Gathering*:
* Generate Scantron/Word document (could be PDF and published online)
* Configure: optional reminders; notifications; closing dates, etc.
* Define respondent grouping based on student or unit attributes
* Notify respondents: email, messaging
* Reports on responses and response rates inc. timestamp (into
database…?)
* Ticketing facility for identifying non-respondents
* Capacity for distinguishing between cohorts based on LDAP
attributes/ Sending them different questionnaires / Interactive
questionnaires with branching
* Support both qualitative and quantitative questions / Process for
removing identifying information
* Massage data from scan sheets into the database
* Generate scan sheets from electronic surveys
* Audit trails (date completed, etc.)
**Reporting and analysis:**
* Access control: initially only at Faculty level (further access
control offline)
* User enquiries (standard database for arbitrary reports)
* Access to past reports / saved queries
* Queries students or by question
* Simple reports should happen within a minute, complex reports can
happen within 24 hours
* Time-series analyses require ad hoc access for last five years
* Compare against previous time taught
* Compare against same teaching period previous year
* Analysis of both qualitative and quantitative questions
* Qualitative looks for frequently repeated words/sentences to
identify themes of feedback
* Audit trails (reports run, by whom, etc.)
* Unique identification of reports (timestamp)
* Extract data in an Excel-friendly format (.csv/.xls)
>>>
Many thanks for taking the time to look this over. Cheers. GeorgeV.
------------------------------
Date: Mon, 4 Oct 2004 20:45:57 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Getopt::Long install problems
Message-Id: <slrncm3v6l.286.tadmc@magna.augustmail.com>
A. Sinan Unur <usa1@llenroc.ude.invalid> wrote:
> Mark J Fenbers <Mark.Fenbers@noaa.gov> wrote in
> news:4161E0C7.55C3F5B0@noaa.gov:
>
> Mark:
>
> I am going to suggest that you read the posting guidelines for this group
> before proceeding any further.
I asked him to do that a year ago.
It was not well received.
Message-ID: <3F6996FA.275A4C5A@noaa.gov>
(wherein _I_ am entreated to follow netiquette!)
(and I got an email with similar foolishness.)
> Avoid top-posting.
I asked for that too.
>> Attachment decoded: untitled-2.txt
>
> Avoid attachments.
And I asked for that as well.
> And the main reason I am even bothering to write this, do not post multiple
> copies of the same message. Given the fact that you posted the exact same
> message at 6:49, 6:55, 6:58, 7:00, 7:03, 7:08, and 7:11 EST I am inclined
> not to think it was by accident.
Mark does not give a rat's ass about other people's time.
Quit the shouting and just answer the damn question. Now!
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 04 Oct 2004 21:04:17 -0700
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: Getopt::Long install problems
Message-Id: <13j932xcdl.ln2@goaway.wombat.san-francisco.ca.us>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
On 2004-10-05, Tad McClellan <tadmc@augustmail.com> wrote:
> A. Sinan Unur <usa1@llenroc.ude.invalid> wrote:
>> Mark J Fenbers <Mark.Fenbers@noaa.gov> wrote in
>> news:4161E0C7.55C3F5B0@noaa.gov:
>>> Attachment decoded: untitled-2.txt
>>
>> Avoid attachments.
>
> And I asked for that as well.
I like killfiling on
Content-type: multipart/mixed
>> And the main reason I am even bothering to write this, do not post multiple
>> copies of the same message. Given the fact that you posted the exact same
>> message at 6:49, 6:55, 6:58, 7:00, 7:03, 7:08, and 7:11 EST I am inclined
>> not to think it was by accident.
To be fair, I'd have guessed that it was by accident, had my
newsreader not scored down his multipart posts.
- --keith
- --
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFBYh05hVcNCxZ5ID8RAnFEAJ9NOyHIuO1i7+7vVl8iVXaaaAcr8QCglEfu
wnUVbfreBuL1sPL2HazKgds=
=ju/0
-----END PGP SIGNATURE-----
------------------------------
Date: Tue, 05 Oct 2004 04:21:58 GMT
From: harryooopotter@hotmail.co_ (Harry)
Subject: Re: Getopt::Long install problems
Message-Id: <Gjp8d.11298$MV5.3019@clgrps13>
Mark J Fenbers wrote...
>Well, I downloaded it using the FTP protocol, too. But the 'make' command
>still gave me the same results. I does appear that the problem is in fact
>with the gzipped tar file. But I would LOVE to be proven otherwise, as I
>really need to get this done tonight...
Below is what happen on my cygwin environment.
You can do it by hand, to simulate "make all" and "make install".
That is, run the copy manually.
$ perl Makefile.PL
Checking if your kit is complete...
Looks good
Writing Makefile for Getopt::Long
$ make all
cp lib/Getopt/Long.pm blib/lib/Getopt/Long.pm
cp lib/newgetopt.pl blib/lib/newgetopt.pl
Manifying blib/man3/Getopt.Long.3
$ make install
Installing /usr/local/lib/perl5/5.8.0/newgetopt.pl
Installing /usr/local/lib/perl5/5.8.0/Getopt/Long.pm
Installing /usr/local/man/man3/Getopt.Long.3
Writing /usr/local/lib/perl5/5.8.0/cygwin/auto/Getopt/Long/.packlist
Appending installation info to /usr/local/lib/perl5/5.8.0/cygwin/perllocal.pod
------------------------------
Date: Tue, 5 Oct 2004 00:08:07 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Getopt::Long install problems
Message-Id: <slrncm4b1n.2kd.tadmc@magna.augustmail.com>
Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us> wrote:
> On 2004-10-05, Tad McClellan <tadmc@augustmail.com> wrote:
>> A. Sinan Unur <usa1@llenroc.ude.invalid> wrote:
>>> Mark J Fenbers <Mark.Fenbers@noaa.gov> wrote in
>>> news:4161E0C7.55C3F5B0@noaa.gov:
>
>>>> Attachment decoded: untitled-2.txt
>>>
>>> Avoid attachments.
>>
>> And I asked for that as well.
>
> I like killfiling on
>
> Content-type: multipart/mixed
Me too, which is why I suggested he not do it.
(I don't think he knows what a killfile is though...)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 4 Oct 2004 19:43:48 -0700
From: hik2sanity@hotmail.com (your name here)
Subject: Re: How to flush a stinkin' socket?
Message-Id: <a794b8d.0410041843.48e241a7@posting.google.com>
Brian McCauley <nobull@mail.com> wrote in message news:<cjs2rh$8nm$1@sun3.bham.ac.uk>...
> your name here wrote:
>
> > You may be familar with the following code snippet as it was taken
> > from some posts in this group. However, whatever I do, I cannot get
> > this message through the socket immediately which causes the other
> > side to determine I am in trouble because it hasn't received a health
> > check. The message finally shows up after I issue the shutdown
> > command, which is unacceptable. Any ideas? Windows peculiarity?
>
> How are you sure that it is not being sent? Is it possible that
> there's unwanted buffering at the reading end? Perhaps the reading
> application is waiting for some kind of end-of-message seqence that does
> not appear in you message.
The message on the receiving end appears when the shutdown command is
issued. I am not particularly familiar with the receiving end's
application (a Delphi program) but I have the source and can step
through. The receive event is triggered when that shutdown command
occurs.
------------------------------
Date: Tue, 05 Oct 2004 04:23:53 GMT
From: Ala Qumsieh <notvalid@email.com>
Subject: Re: initialize a list
Message-Id: <tlp8d.24199$QJ3.1069@newssvr21.news.prodigy.com>
Jay Tilton wrote:
> My personal preference in the extraordinarily rare circumstance that
> initialization is necessary:
>
> $_ = 0 for
> my ($a, $b, $c, $d, $e);
Hmmm .. I would have expected the variables to be defined only within
the "body" of the for loop. Why does this work?
--Ala
------------------------------
Date: Tue, 05 Oct 2004 04:43:32 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: initialize a list
Message-Id: <x7zn31rd1y.fsf@mail.sysarch.com>
>>>>> "AQ" == Ala Qumsieh <notvalid@email.com> writes:
AQ> Jay Tilton wrote:
>> My personal preference in the extraordinarily rare circumstance that
>> initialization is necessary:
>> $_ = 0 for
>> my ($a, $b, $c, $d, $e);
AQ> Hmmm .. I would have expected the variables to be defined only within
AQ> the "body" of the for loop. Why does this work?
that expression (not really a loop body) isn't a block so there is no
scope. the my is scoped to the enclosing block. this isn't any different
than saying open( my $fh, 'foo' ).
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 4 Oct 2004 18:38:44 -0700
From: ioneabu@yahoo.com (wana)
Subject: Perl books on tape
Message-Id: <bf0b47ca.0410041738.4a09b76e@posting.google.com>
The following link is to an answer by Mr. O'Reilly to a question that
I have had in my head for a while now. It appears to be 5 years old,
but I doubt that the answer has changed.
I have a long drive to and from work every day and I would like
nothing better than to immerse myself in learning about Perl and, if
necessary, other topics in software.
At least maybe there is a way to get the recordings that he does
mention were made and discontinued. Please let me know if there is
such a thing as lectures or books on tape about Perl.
Does O'Reilly sort of own Perl, the way Sun owns Java? No offense,
but it does seem that way to some degree. I have found lots of
interesting audio lectures in the past online from various
universities, but I was wondering if any such topic regarding Perl
would be subject to the permission of Larry Wall or O'Reilly. If not,
it is an opportunity open to the many experts out there.
How much could it cost to produce really? Sit at your computer and
record yourself spewing out Perl pearls for an hour at a time, package
into an mp3 and put up on your website for sale. If you're good,
people will buy.
If not, I may have to start taking the bus.
wana
http://www.oreilly.com/pub/a/oreilly/ask_tim/2000/audio_0100.html
------------------------------
Date: Tue, 5 Oct 2004 00:10:14 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Perl books on tape
Message-Id: <slrncm4b5m.2kd.tadmc@magna.augustmail.com>
wana <ioneabu@yahoo.com> wrote:
> Does O'Reilly sort of own Perl, the way Sun owns Java?
No.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 05 Oct 2004 07:01:12 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Perl books on tape
Message-Id: <slrncm4hlo.qgs.abigail@alexandra.abigail.nl>
wana (ioneabu@yahoo.com) wrote on MMMMLIII September MCMXCIII in
<URL:news:bf0b47ca.0410041738.4a09b76e@posting.google.com>:
//
// Does O'Reilly sort of own Perl, the way Sun owns Java?
Nope. Java people don't worship Sun the way Perl people worship O'Reilly.
Abigail
--
package Z;use overload'""'=>sub{$b++?Hacker:Another};
sub TIESCALAR{bless\my$y=>Z}sub FETCH{$a++?Perl:Just}
$,=$";my$x=tie+my$y=>Z;print$y,$x,$y,$x,"\n";#Abigail
------------------------------
Date: 4 Oct 2004 23:39:57 -0700
From: polu.kiran@gmail.com (Polu Kiran)
Subject: Perl6
Message-Id: <dde30c8c.0410042239.7c7630bf@posting.google.com>
Hi,
Does anybody knows the difference between perl5 and perl6?
advance thanx.
------------------------------
Date: Mon, 04 Oct 2004 21:25:08 -0400
From: Bob Walton <see@sig.invalid>
Subject: Re: regex error
Message-Id: <4161f601$1_5@127.0.0.1>
Brendon Caligari wrote:
> Abigail wrote:
>
>> Brendon Caligari (bcaligari@nospam.fireforged.com) wrote on MMMMLII
>> September MCMXCIII in
>> <URL:news:4161d09b$0$94914$bed64819@news.gradwell.net>:
...
>> Abigail
...
> <cut filename = 'x.pl'>
> #!/usr/bin/perl
> use warnings;
> use strict;
>
> my $str = '';
> my $num = 0;
> open(MF, "<x");
Always *always* check to see if open failed. Like:
open MF,"<x" or die "Oops, couldn't open x for read, $!";
> {
> local $/ = '';
> $str = <MF>;
> }
> close(MF);
> $str =~ m/^length: (\d+?)$/ms;
Always *always* before using a "number variable", check to see if the
match succeeded. Maybe like:
if($str=~m/^length: (\d+?)$/ms){
$num=$1;
}
else{
die "Bad length: line";
}
> $num = $1;
> $str =~ m/^data: '(.{$num})'$/ms;
Again, before using $1 from this statement, check to see if the match
was successful. Another way:
(my $data)=$str=~m/^data: '(.{$num})'$/ms;
die "bad data: line" unless defined $data;
print $data;
> </cut>
>
>
> <cut filename = 'x'>
> length: 5
> data: '01234'
> </cut>
>
...
> I tried the same thing on a WinXP machine with a recentish version of
> ActivePerl port and it worked well.
I verify -- works fine on Windoze XP, AS Perl 5.8.4 build 810.
> Brendon
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: 05 Oct 2004 06:54:19 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: regex error
Message-Id: <slrncm4h8q.qgs.abigail@alexandra.abigail.nl>
Brendon Caligari (bcaligari@nospam.fireforged.com) wrote on MMMMLIII
September MCMXCIII in <URL:news:4161ecbb$0$94923$bed64819@news.gradwell.net>:
:} Abigail wrote:
:}
:} > Brendon Caligari (bcaligari@nospam.fireforged.com) wrote on MMMMLII
:} > September MCMXCIII in <URL:news:4161d09b$0$94914$bed64819@news.gradwell.net>:
:} > ;; I cannot understand what i'm doing wrong but my script fails to compile
:} > ;; ("panic: end_shift");
:} >
:} > Probably a syntax error that is triggering a bug in Perl. You should
:} > never get the "panic" message - if you get it, it's a bug in Perl.
:} >
:} > Probably the most common source of such 'panic' errors happen when
:} > Perl tries to compile a regexp containing some kind of syntax error.
:} >
:} > ;; $SMContents =~ m/^User data: '(.{$SMMessageLength})'$/ms
:} >
:} > Since we don't know what's in $SMMessageLength, it's hard to say
:} > what is going wrong.
:} >
:} >
:} >
:} > Abigail
:}
:} Thanks Abigail...
:}
:}
:} <cut filename = 'x.pl'>
:} #!/usr/bin/perl
:} use warnings;
:} use strict;
:}
:} my $str = '';
:} my $num = 0;
:} open(MF, "<x");
What if the open fails?
:} {
:} local $/ = '';
:} $str = <MF>;
:} }
:} close(MF);
:} $str =~ m/^length: (\d+?)$/ms;
There's no need for the ? (it only slows things down), as you are
anchoring the expression anyway, and there are no futher quantifiers.
:} $num = $1;
What if the regexp fails?
:} $str =~ m/^data: '(.{$num})'$/ms;
Did you print out the value of $num?
:} </cut>
:}
:}
:} <cut filename = 'x'>
:} length: 5
:} data: '01234'
:} </cut>
:}
:}
:} $ uname -r
:} 2.4.21-20.EL
:}
:}
:} $ rpm -q perl
:} perl-5.8.0-88.7
:}
:}
:}
:} I tried the same thing on a WinXP machine with a recentish version of
:} ActivePerl port and it worked well.
It might be a bug in Perl. Could you make a self-contained program that
exhibits this bug?
Abigail
--
map{${+chr}=chr}map{$_=>$_^ord$"}$=+$]..3*$=/2;
print "$J$u$s$t $a$n$o$t$h$e$r $P$e$r$l $H$a$c$k$e$r\n";
------------------------------
Date: 4 Oct 2004 20:56:27 -0700
From: deja_NOSPAM_@zaft.com (Shane)
Subject: Regular Expression help please
Message-Id: <d0cc80fa.0410041956.3913e74d@posting.google.com>
Hi,
I'm sure this message doesn't belong here exactly, but I know all the
Perl gurus know regular expressions really well and I can't find a
group just for regular expressions.
Anyway, I am trying to use regular expressions to find patterns and
add to them - not replace.
Specifically, I want to find something like:
foo?4567"
and replace it with something like:
foo?4567.txt"
I really don't want to write a perl script to do it - I thought I
could do it in textpad or vi, but I'm having trouble with the syntax.
In Perl I would just find foo?.*\" and use $1 as the variable to
replace the number to the original number. For some reason, I can't
get textpad to do what I want and I'm sure I'm just missing something
simple.
Thanks in advance for the help, and not flaming me. Although if this
really needs to be about Perl, I'll take corrections on my assumptions
about how to do it in Perl and just write a script to do it. It just
seems overkill.
shane
------------------------------
Date: 5 Oct 2004 04:00:10 GMT
From: "A. Sinan Unur" <usa1@llenroc.ude.invalid>
Subject: Re: Regular Expression help please
Message-Id: <Xns9579447E3EDasu1cornelledu@132.236.56.8>
deja_NOSPAM_@zaft.com (Shane) wrote in
news:d0cc80fa.0410041956.3913e74d@posting.google.com:
> Hi,
>
> I'm sure this message doesn't belong here exactly,
You might want to head on over to comp.editors for help with text editors.
Sinan.
------------------------------
Date: Tue, 5 Oct 2004 00:05:19 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Regular Expression help please
Message-Id: <slrncm4asf.2kd.tadmc@magna.augustmail.com>
Shane <deja_NOSPAM_@zaft.com> wrote:
> Anyway, I am trying to use regular expressions to find patterns and
> add to them - not replace.
>
> Specifically, I want to find something like:
>
> foo?4567"
>
> and replace it with something like:
>
> foo?4567.txt"
> about how to do it in Perl and just write a script to do it.
perl -p -i~ -e 's/(foo\?[^"]+)"/$1.txt"/g' file
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 05 Oct 2004 07:03:49 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Regular Expression help please
Message-Id: <slrncm4hql.qgs.abigail@alexandra.abigail.nl>
Shane (deja_NOSPAM_@zaft.com) wrote on MMMMLIII September MCMXCIII in
<URL:news:d0cc80fa.0410041956.3913e74d@posting.google.com>:
!! Hi,
!!
!! I'm sure this message doesn't belong here exactly, but I know all the
!! Perl gurus know regular expressions really well and I can't find a
!! group just for regular expressions.
!!
!! Anyway, I am trying to use regular expressions to find patterns and
!! add to them - not replace.
!!
!! Specifically, I want to find something like:
!!
!! foo?4567"
!!
!! and replace it with something like:
!!
!! foo?4567.txt"
!!
!! I really don't want to write a perl script to do it - I thought I
!! could do it in textpad or vi, but I'm having trouble with the syntax.
!! In Perl I would just find foo?.*\" and use $1 as the variable to
!! replace the number to the original number. For some reason, I can't
!! get textpad to do what I want and I'm sure I'm just missing something
!! simple.
!!
!! Thanks in advance for the help, and not flaming me. Although if this
!! really needs to be about Perl, I'll take corrections on my assumptions
!! about how to do it in Perl and just write a script to do it. It just
!! seems overkill.
Considering that you seem to know how to do it in Perl, but you have to
ask on Usenet to do it in another way, I don't agree with your statement
that doing it in Perl seems overkill.
Asking on Usenet, and bothering hundreds of other people just to avoid
writing a one-liner in Perl, now *that* is overkill.
Abigail
--
# Perl 5.6.0 broke this.
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi
------------------------------
Date: Tue, 05 Oct 2004 14:25:56 +1000
From: Simon Taylor <simon@unisolve.com.au>
Subject: Re: use sed in perl
Message-Id: <cjt837$2d28$1@otis.netspace.net.au>
Hello,
> I used some legacy perl code to change a configuration file, it is
> working and it replaces the line starts with XT_SCREEN_COUNT=1 with
> the a new SCREEN_COUNT variable. But I don't quite understand what's
> the meaning of the ' . in front of $numscreens and after $numscreens.
> Could anyone give me a hint?
>
> Thanks in advance!
>
> $rc = system('sed -e
> "s/^XT_SCREEN_COUNT=1/XT_SCREEN_COUNT='.$numscreens. '/g" '.
> $resultdir.'tetexec.cfg>' . $resultdir. 'tetexec.cfg.tmp');
The code is concatenating single-quoted strings together and
interpolating variables to form an argument to the perl system() function.
You can read it as:
'some text in single quotes' . $somevariable . 'more text'
where the binary '.' operator is doing the string concatenation that the
'+' operator does in some other languages.
If the values of the perl variables $numscreens and $resultdir
were, say, 2 and '/tmp/', respectively, then the system function
would receive an argument that looked like:
'sed -e "s/^XT_SCREEN_COUNT=1/XT_SCREEN_COUNT=2/g" /tmp/tetexec.cfg>
/tmp/tetexec.cfg.tmp'
Needless to say, the original author of this code would find
that the same functionality is more easily done directly in Perl.
There's no need to use sed via a system call for this.
I hope this helps,
Simon Taylor
------------------------------
Date: Tue, 5 Oct 2004 02:04:41 -0400
From: "nntp" <nntp@rogers.com>
Subject: Re: Which Counter is Perfect?
Message-Id: <D4udnWXfyowKpP_cRVn-vg@rogers.com>
> The second one is simply madness. Why use a seperate lock file when
> the counter file will do? Why open a file in read-write mode when you
> are only writing to it?
>
> It also fails to protect the count if the flock fails and hence
> can't be called "perfect".
>
> The second one has far more flaws than the first.
>
> Please post code in a readable format and not the gunk that is quoted
above.
>
> --
> Sam Holden
You need to read http://www.perlguy.com/articles/locking.html
to understand why the second one is perfect, as far as it stated. I am not
an expert, but his statement makes sense.
------------------------------
Date: 5 Oct 2004 06:23:50 GMT
From: Sam Holden <sholden@flexal.cs.usyd.edu.au>
Subject: Re: Which Counter is Perfect?
Message-Id: <slrncm4ffm.ccu.sholden@flexal.cs.usyd.edu.au>
On Tue, 5 Oct 2004 02:04:41 -0400, nntp <nntp@rogers.com> wrote:
>> The second one is simply madness. Why use a seperate lock file when
>> the counter file will do? Why open a file in read-write mode when you
>> are only writing to it?
>>
>> It also fails to protect the count if the flock fails and hence
>> can't be called "perfect".
>>
>> The second one has far more flaws than the first.
>>
>> Please post code in a readable format and not the gunk that is quoted
> above.
>>
>> --
>> Sam Holden
>
> You need to read http://www.perlguy.com/articles/locking.html
> to understand why the second one is perfect, as far as it stated. I am not
> an expert, but his statement makes sense.
The only reason a seperate lock file is used in those examples is
because the count file is opened once for reading and then once for
writing. Sane people open it once for read-write and hence don't need
a second file for locking as the lock isn't lost during the
read->write reopen.
And it isn't "perfect", I already gave the case in which data corruption
results.
If you are not expert how do you know his statement makes sense?
--
Sam Holden
------------------------------
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 7209
***************************************