[19409] in Perl-Users-Digest
Perl-Users Digest, Issue: 1604 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 24 14:05:34 2001
Date: Fri, 24 Aug 2001 11: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: <998676310-v10-i1604@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 24 Aug 2001 Volume: 10 Number: 1604
Today's topics:
Re: - HELP! Accidentally saved Perl script with WORDPAD (E.Chang)
Re: - HELP! Accidentally saved Perl script with WORDPAD <vemba72@youknowwhattodo.hotmail.com>
Re: - HELP! Accidentally saved Perl script with WORDPAD <vemba72@youknowwhattodo.hotmail.com>
Re: avoid date like 31st of february <bart.lateur@skynet.be>
Re: Can't get correct IP (Malcolm Ray)
Check subroutine data from other process <cave@pertus.com.pl>
D'oh! It does what I said, not what I want <lmoran@wtsg.com>
Re: D'oh! It does what I said, not what I want <cb@onsitetech.com>
Re: Date module <sb@mcasia.imperia.net>
Editor Question <mark.riehl@agilecommunications.com>
Hashref to coderef? <djberge@uswest.com>
Re: Hashref to coderef? (Rafael Garcia-Suarez)
Re: Hashref to coderef? (Mark Jason Dominus)
Re: Hashref to coderef? (Anno Siegel)
Re: help with searching for occurances of...... <lmoran@wtsg.com>
Re: join (IG)
Re: Microsoft Perl <wsegrave@mindspring.com>
Re: Newbie. Searching a text file and replacing text. <Rainer.Klier@erl.sbs.de>
Re: Performance : Shell X Perl <florian@haftmann-online.de>
Re: Performance : Shell X Perl <bcc@eswssol001.elsegundoca.ncr.com>
Re: pl or not pl, that is the question <florian@haftmann-online.de>
Re: pl or not pl, that is the question <jurgenex@hotmail.com>
qw// documentation revision (was Re: Openning a file) <ren@tivoli.com>
read next line into $_ <_nospam_m9652@abc.se>
Re: read next line into $_ (Anno Siegel)
restarting named...takes a longtime...??? <f.benady@french-connexion.fr>
Re: restarting named...takes a longtime...??? (Anno Siegel)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 24 Aug 2001 13:45:49 GMT
From: echang@netstorm.net (E.Chang)
Subject: Re: - HELP! Accidentally saved Perl script with WORDPAD...
Message-Id: <Xns9107641146F37echangnetstormnet@207.106.92.86>
[posted and mailed]
"Jon 'The Mensch'" <vemba72@youknowwhattodo.hotmail.com> wrote in
<Mmmh7.7149$Oj3.463631@wagner.videotron.net>:
>I tried that actually when I was troubleshooting... but it didn't
>help. :(
>
>Jon
Hmm. Maybe try copying and pasting the text into Notepad then.
Incidentally, if you're working on program code, get at least a text
editor that has line numbers. For example EditPad Lite at
http://www.jgsoft.com/ is a giant step up over Notepad and there are a
lot of others around. Search the archives of this list for discussions
about full-scale program editors.
--
EBC
------------------------------
Date: Fri, 24 Aug 2001 11:13:14 -0400
From: "Jon 'The Mensch'" <vemba72@youknowwhattodo.hotmail.com>
Subject: Re: - HELP! Accidentally saved Perl script with WORDPAD...
Message-Id: <gauh7.6214$ok3.532563@weber.videotron.net>
Kira,
You haven't been laid in a while, have you?
Jon
"Kira" <callgirl@la.znet.com> wrote in message
news:3B85F26A.C4C0BD62@la.znet.com...
> Jon 'The Mensch' wrote:
>
> > I just accidentally modified a .CGI perl script with WORDPAD instead of
my
> > usual NOTEPAD. Naturally, the file no longer works, probably because of
the
> > added carriage returns WP adds (I guess).
>
> Yeah, real difficult to notice this difference between wordpad
> and notepad, real difficult.
>
> * rolls her eyes *
>
>
> > My question is... short of going over every line in NOTEPAD manually
(forget
> > it, there are zillions of lines) what are my options to get out of this
> > predicament?
>
>
> Predicament, you misspelled pickle, which I understand most
> trolls love to suck.
>
> You expect me, at least me, to believe you are editing a program
> with zillions of lines using notepad? Sure!
>
> Tonight, I spent my quiet time working on my chatline script.
> It is three-thousand-four-hundred-forty-five lines at a bit
> over one-hundred-thirty kilobytes.
>
> * wonders if she would have better luck using notepad *
>
> I use a full blown program editor to write and work with my
> programs. What is your excuse for not using a program editor?
>
> * as if *
>
> My chat script is, without exaggeration, the absolute best
> and the absolute most entertaining chat program found anywhere,
> and, stroking my ego, quite often a target for theft, although
> none have succeeded nor will. I have two very remarkable androids
> taking care of my various sites.
>
> Wanna meet them? Most sissified geeks scream and leave upon
> first encounter with my Roberta The Remarkable Robot.
>
> Professionals use the right tools and, use professional tools.
>
> Notepad, well, this is a good indicator of your professionalism.
>
>
> NOTEPAD!!
>
> * flat palm smacks her forehead *
>
> jeeeeshhh...
>
>
> Godzilla! Queen Of Artificial Intelligence.
> --
> http://la.znet.com/~callgirl/webchat/chahta.cgi
> http://la.znet.com/~callgirl/android.html
------------------------------
Date: Fri, 24 Aug 2001 11:18:15 -0400
From: "Jon 'The Mensch'" <vemba72@youknowwhattodo.hotmail.com>
Subject: Re: - HELP! Accidentally saved Perl script with WORDPAD...
Message-Id: <Yeuh7.6267$ok3.534457@weber.videotron.net>
Thanks, E.
I replaced Notepad with EditPad, and tried saving the file "for UNIX".
Thought it might remove unwanted elements from the code (like the <cr>s) but
it didn't really help.
Someone suggested I use WORD, which has codes to identify <cr>s and hence
makes it easier to remove them... but the problem is that WORD tries to do
way too much. When it sees anything that resembles HTML coding, it actually
tries to translate the code into a webpage, despite the CGI extension, and
tries to interpret the page rather than show it as-is.
Needless to say, I am NOT a programmer. I'm just trying to apply a public
CGI script to one of my websites after modifying a long list of customizable
variables... and saved it with Wordpad by accident.
Jon
"E.Chang" <echang@netstorm.net> wrote in message
news:Xns9107641146F37echangnetstormnet@207.106.92.86...
> [posted and mailed]
>
> "Jon 'The Mensch'" <vemba72@youknowwhattodo.hotmail.com> wrote in
> <Mmmh7.7149$Oj3.463631@wagner.videotron.net>:
>
> >I tried that actually when I was troubleshooting... but it didn't
> >help. :(
> >
> >Jon
>
> Hmm. Maybe try copying and pasting the text into Notepad then.
> Incidentally, if you're working on program code, get at least a text
> editor that has line numbers. For example EditPad Lite at
> http://www.jgsoft.com/ is a giant step up over Notepad and there are a
> lot of others around. Search the archives of this list for discussions
> about full-scale program editors.
>
> --
> EBC
------------------------------
Date: Fri, 24 Aug 2001 14:16:38 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: avoid date like 31st of february
Message-Id: <0focot074ipv1ih1lo73qg7nsc4cpad2hn@4ax.com>
cecile wrote:
>People can choose the
>date and hour they like (for exemple for a delivery date) but of
>course they shouldn't choose any date like 31st february.
Use the module Time::Local (part of the basic distribution) to convert a
date consisting of parts, into unix time (= seconds since the epoch, the
beginning of 1970). Do the same with the first of the next month. See if
indeed you get a smaller number for the "earlier" date.
--
Bart.
------------------------------
Date: 24 Aug 2001 15:09:13 GMT
From: M.Ray@ulcc.ac.uk (Malcolm Ray)
Subject: Re: Can't get correct IP
Message-Id: <slrn9ocrgp.r1u.M.Ray@carlova.ulcc.ac.uk>
On Thu, 23 Aug 2001 22:37:55 +0200, Alan J. Flavell
<flavell@mail.cern.ch> wrote:
>It's possible to configure Apache to resolve IP addresses to DNS names
>only when URLs seem to be CGI calls. For example the ones I manage
>have a bracket that's effective whenever the URLpath contains "cgi".
YMMV: the value of this of course depends on who your users are, but
with in-addr.arpa records sadly out of vogue these days, it's debatable
whether this is worth the cost in general, since you're likely to find
that > 30% of those lookups fail. But now we're OT.
>> I'd be very surprised to find a webserver which supplied '127.0.0.1'
>> in $ENV{REMOTE_ADDR} and the client's hostname in $ENV{REMOTE_HOST}
>> (unless the client *is* localhost, of course).
>
>Indeed. remote_addr and remote_host always relate to the same
>Internet host, but it often will not be the address/name of the actual
>client.
...which may not even have an IP address, of course, or may have one which
has no meaning outside of the client's network.
--
Malcolm Ray University of London Computer Centre
------------------------------
Date: Fri, 24 Aug 2001 19:39:54 +0200
From: Mirek Rewak <cave@pertus.com.pl>
Subject: Check subroutine data from other process
Message-Id: <3m3dotctuahd6fjafh19duhk88rns5frb8@4ax.com>
Hi,
At first: sorry for that stupid subject...
How to solve this problem: I've got a subrountine which loops a long
time (exactly Mail::Bulkmail::bulkmail) and I want check from other
process status of this operation (counter, to check how many posts
have been sent so far) while it is executing.
Pozdrowienia
Mirek Rewak
cave@pertus.com.pl
------------------------------
Date: Fri, 24 Aug 2001 12:28:00 -0400
From: Lou Moran <lmoran@wtsg.com>
Subject: D'oh! It does what I said, not what I want
Message-Id: <otvcotk3drk2db4hfugc81aqfoc6t7bhg0@4ax.com>
I have writtent the script below and I think my problem with it is the
"until" b/c what is happening is that my (hmm that's funnny) variables
are getting their information once. But I want them to get the
information over and over again. What would work better?
code:
#!/usr/bin/perl -w
use strict ;
use diagnostics ;
use LWP::Simple ;
#this will run a ping to our firewall
#to yahoo.com
#to 132.163.4.101 an NIST Time Server
#and with get the time (UTC)
#run this script piped to text from the prompt
my $ping1 = (`ping XXX.XXX.XXX.XXX -n 1`) ;
my $ping2 = (`ping yahoo.com -n 25`) ;
my $ping3 = (`ping 132.163.4.101 -n 25`) ;
my $time = (localtime) ;
my $numb = 18501 ;
until ($numb == 1) {
chomp $numb ;
$numb -- ;
print "----------------------------\n" ;
print $ping1 ;
print "----------------------------\n" ;
print $ping2 ;
print "----------------------------\n" ;
print $ping3 ;
print "----------------------------\n" ;
print $time ;
print "\n" ;
print "----------------------------\n" ;
}
------------------------------
Date: 24 Aug 2001 17:07:10 GMT
From: "Christian Brink" <cb@onsitetech.com>
Subject: Re: D'oh! It does what I said, not what I want
Message-Id: <9m61ju$m9v@dispatch.concentric.net>
> #!/usr/bin/perl -w
>
> use strict ;
> use diagnostics ;
> use LWP::Simple ;
>
> #this will run a ping to our firewall
> #to yahoo.com
> #to 132.163.4.101 an NIST Time Server
> #and with get the time (UTC)
> #run this script piped to text from the prompt
#
# my $ping1 = (`ping XXX.XXX.XXX.XXX -n 1`) ;
# my $ping2 = (`ping yahoo.com -n 25`) ;
# my $ping3 = (`ping 132.163.4.101 -n 25`) ;
# my $time = (localtime) ;
# my $numb = 18501 ;
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# You want this section of code inside the loop.
> until ($numb == 1) {
# like this
my $ping1 = `ping XXX.XXX.XXX.XXX -n 1` ;
my $ping2 = `ping yahoo.com -n 25`;
my $ping3 = `ping 132.163.4.101 -n 25` ;
my $time = localtime() ;
my $numb = 18501 ;
#Also you do not need to interpret those backticks in a list format so
get rid of the parens.
> chomp $numb ;
> $numb -- ;
>
> print "----------------------------\n" ;
> print $ping1 ;
> print "----------------------------\n" ;
> print $ping2 ;
> print "----------------------------\n" ;
> print $ping3 ;
> print "----------------------------\n" ;
> print $time ;
> print "\n" ;
> print "----------------------------\n" ;
> }
------------------------------
Date: Fri, 24 Aug 2001 16:34:29 +0200
From: Steffen Beyer <sb@mcasia.imperia.net>
Subject: Re: Date module
Message-Id: <llo5m9.mf4.ln@imperia.net>
Jonas Nilsson <jonni@ifm.liu.nospam.se> wrote:
> I want to write a simple function like this.
>
> print &AddDaysToDate('2001-05-24',5);
> Will get you:
> 2001-05-29
>
> print &AddDaysToDate('2001-05-24',-25);
> Will get you:
> 2001-04-29
>
> And so on. I could write it myself, but I don't want to reinvent the wheel.
> So what module would you suggest. It should handle leap year, but it doen't
> need to recognize any fancy dateformat.
See Date::Calc on CPAN, for example, or download it from
http://www.engelschall.com/u/sb/download/pkg/Date-Calc-5.0.tar.gz
> What is the leap year convention anyway?
> Are the leapyears:
> year=(n*4 but not m*100);
> and
> year=(o*400);
> for any integers n,m,o
((($year % 4 == 0) && !($year % 100 == 0)) || ($year % 400 == 0))
Hope this helps.
--
Steffen Beyer <sb@engelschall.com>
(This message may not be replyable. Use address on line above instead!)
http://www.engelschall.com/u/sb/whoami/ (Who am I)
http://www.engelschall.com/u/sb/gallery/ (Fotos Brasil, USA, ...)
http://www.engelschall.com/u/sb/download/ (Free Perl and C Software)
------------------------------
Date: Fri, 24 Aug 2001 15:49:14 GMT
From: "Mark Riehl" <mark.riehl@agilecommunications.com>
Subject: Editor Question
Message-Id: <_Huh7.797$qq2.382426@typhoon1.gnilink.net>
All - Anyone using XEmacs? I'm running 21.4p3 on Win2k, and it is having
fits with the indents on the following code. I can't seem to get it right,
can't find a matching brace, etc.
for $key (keys %RxTxData) {
print RESULTS "Table key = $key\n";
print RESULTS "My current info:\n";
print RESULTS "Last SA: $RxTxData{$key}{last_sa_time}\t";
print RESULTS "Last SA: $RxTxData{$key}{last_latitude}\t";
print RESULTS "Last SA: $RxTxData{$key}{last_longitude}\n";
print RESULTS "\nCurrent transmitters\n";
foreach $key2 ( sort keys %{$RxTxData{$key}{my_display} } ) {
if (${$RxTxData{$key}{my_display}{$key2}}[0] != 0) {
print RESULTS "Urn: $key2\t";
print RESULTS "Time: ${$RxTxData{$key}{my_display}{$key2}}[0]\t";
print RESULTS "Lat: ${$RxTxData{$key}{my_display}{$key2}}[1]\t";
print RESULTS "Long: ${$RxTxData{$key}{my_display}{$key2}}[2]\n";
}
}
print RESULTS "\n";
print RESULTS "Statistics\n";
print RESULTS "Time\tVisibility\tActual\tExpected\n";
foreach $key2 ( sort keys %{$RxTxData{$key}{statistics} } )
{
print RESULTS "$key2\t";
print RESULTS "${$RxTxData{$key}{statistics}{$key2}}[0]\t";
print RESULTS "${$RxTxData{$key}{statistics}{$key2}}[1]\t";
print RESULTS "${$RxTxData{$key}{statistics}{$key2}}[2]\n";
# print RESULTS "Accuracy:
${$RxTxData{$key}{statistics}{$key2}}[1]\n";
}
print RESULTS "\n";
}
Any suggestions? I've tried the XEmacs FAQ, and perl-mode on XEmacs.
Thanks,
Mark
------------------------------
Date: Fri, 24 Aug 2001 10:06:19 -0500
From: Mr Sunblade <djberge@uswest.com>
Subject: Hashref to coderef?
Message-Id: <3B866D6B.FCBE5E5@uswest.com>
Hi all,
How can I convert a hashref to a code ref on the fly? Is this possible?
Consider:
#!/usr/local/bin/perl -w
my @array = qw(1 2 10 3 4 5);
sortArray(sub {$b <=> $a});
sub sortArray{
my $ref = shift;
print "Ref is: ", ref($ref), "\n";
my @sorted = eval{ sort $ref @array };
print "Sorted: ", join(',',@sorted),"\n";
}
This works, but let's say I want to be able to omit the "sub" within the
call and place it in the 'sortArray()' function (just, uh, for kicks and
looks).
sortArray({$b <=> $a}); # Pass a hash ref
my @sorted = eval{ sort sub $ref @array }; # convert to code ref on the
fly - Fails!
I've tried a few permutations of eval / quoting / bracketing but no
luck.
Is this possible? How do functions like 'map' and 'sort' magically turn
what look like hash-ref's into code ref's?
Thanks in advance.
Mr. Sunblade
--
"Evil will always triumph because Good is *dumb*."
-- Dark Helmet, 'Spaceballs: The Movie'
------------------------------
Date: 24 Aug 2001 15:33:51 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Hashref to coderef?
Message-Id: <slrn9oct9g.mi4.rgarciasuarez@rafael.kazibao.net>
Mr Sunblade wrote in comp.lang.perl.misc:
[...]
} This works, but let's say I want to be able to omit the "sub" within the
} call and place it in the 'sortArray()' function (just, uh, for kicks and
} looks).
}
} sortArray({$b <=> $a}); # Pass a hash ref
This is NOT an hash ref.
You should look at the 'prototypes' section of the perlsub manpage;
pay special attention to the (&) prototype.
--
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
Date: Fri, 24 Aug 2001 15:50:40 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Hashref to coderef?
Message-Id: <3b8677cf.1010$eb@news.op.net>
In article <3B866D6B.FCBE5E5@uswest.com>,
Mr Sunblade <djberge@uswest.com> wrote:
>How can I convert a hashref to a code ref on the fly? Is this possible?
No. The question does not even make sense.
>sortArray(sub {$b <=> $a});
>
>This works, but let's say I want to be able to omit the "sub" within the
>call and place it in the 'sortArray()' function (just, uh, for kicks and
>looks).
>
>sortArray({$b <=> $a}); # Pass a hash ref
I don't know what you think a hash ref is, but it won't do what you
want, because the ($b <=> $a) expression is evaluated *before* the
sortArray function is called. The resulting value is used to
construct a new hash, and the reference to the hash is passed to
sortArray. With a code reference, the code is *not* executed.
Instead, it is packaged up into a new subroutine, and the reference to
the subroutine is passed to the function.
What you really seem to want to do is to change the *syntax* of the
code ref, so that it is still a code ref even if you omit the word
'sub'. To do that, use:
sub sortArray (&);
sortArray {$b <=> $a}; # Pass a CODE ref
sub sortArray (&) {
... as before
}
Here we are not using a hash ref. We are using a code ref as before.
The "(&)" in the declaration warns Perl that we will leave out the
word 'sub'.
>Is this possible? How do functions like 'map' and 'sort' magically turn
>what look like hash-ref's into code ref's?
They don't. There is no way to turn a hash ref into a code ref. It
is like saying "Well, I have a race car, but it has stripes, and I
don't like stripes. So how can I turn this eggplant into a race car?"
Hope this helps.
--
@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
------------------------------
Date: 24 Aug 2001 16:51:51 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Hashref to coderef?
Message-Id: <9m60n7$qch$1@mamenchi.zrz.TU-Berlin.DE>
According to Mr Sunblade <djberge@uswest.com>:
[snip]
> sub sortArray{
> my $ref = shift;
> print "Ref is: ", ref($ref), "\n";
> my @sorted = eval{ sort $ref @array };
You don't need eval here.
my @sorted = sort $ref @array;
does the same thing.
> print "Sorted: ", join(',',@sorted),"\n";
> }
Your original question has been excellently answered.
Anno
------------------------------
Date: Fri, 24 Aug 2001 09:35:59 -0400
From: Lou Moran <lmoran@wtsg.com>
Subject: Re: help with searching for occurances of......
Message-Id: <n0mcot8rnntfhgrl8oadrar671d4rv3k62@4ax.com>
On 23 Aug 2001 18:38:17 GMT, trammell@haqq.hypersloth.invalid (John J.
Trammell) wrote wonderful things about sparkplugs:
>LINUX was released on August 25th, 1991
>and is therefore a virgo.
Just like me.... August 24th, 1967!
(Well wishing is currently being accepted!)
------------------------------
Date: 24 Aug 2001 10:26:06 -0700
From: irinag@ims.com (IG)
Subject: Re: join
Message-Id: <9ef37b56.0108240926.2ba3d7ca@posting.google.com>
Just in,
"Just in" <justin.devanandan.allegakoen@intel.com> wrote in message news:<9m3982$7ub@news.or.intel.com>...
...skip
> s/\n// if((length($Line) < 60) && !(Line =~ /;$/));
>
You can try to read lines with $/ set to ";\n". Something like
my @array = do { local $/ = ";\n"; <DATA>; };
__END__
;-)
------------------------------
Date: Fri, 24 Aug 2001 09:12:00 -0500
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: Microsoft Perl
Message-Id: <9m5o3j$vmk$1@nntp9.atl.mindspring.net>
"Bart Lateur" <bart.lateur@skynet.be> wrote in message
news:o57cot0o4p8193upsre9iu8jrqn10tlguj@4ax.com...
> William Alexander Segraves wrote:
>
> >BTW, IndigoStar claims in their release history to have upgraded to v
> >5.0005. When I downloaded MicroWeb, v 5.001 was still in the
distribution.
> >They have not responded to questions.
>
> Perhaps as included with Microweb.
>
> But the most recent IndigoPerl is 5.6.1. Get that. It's free.
>
> --
Thanks, Bart. perhaps the OP will notice and take heed.
I have no need for it.
Bill Segraves
Auburn, AL
> Bart.
------------------------------
Date: Fri, 24 Aug 2001 14:17:27 -0100
From: Rainer Klier <Rainer.Klier@erl.sbs.de>
Subject: Re: Newbie. Searching a text file and replacing text.
Message-Id: <3B867007.DAC3E21B@erl.sbs.de>
Andrew Paul Gorton wrote:
>
> Hi all,
>
> I need to search a text file similar to this:
>
> ChkDisk: ERROR /dev/hda5 90% full
> ChkCPU: ERROR load average:1.00, 0.01, 2.00
> ...
>
> I need to find say the ChkDisk and replace this line with the updated
> line from another program.
> How is this done.
>
> Cheers for the help
------------------- untested ---------------------
#!/usr/bin/perl -w
use Fcntl qw/:DEFAULT :flock :seek/;
my $file = "/path/to/file";
sysopen(FH,$file,O_RDWR) or die("Cannot open file $file for writing.
$!.");
flock(FH,LOCK_EX) or die("Cannot get exclusive lock for $file. $!.");
my @lines = <FH>;
seek(FH,0,SEEK_SET);
truncate(FH,0);
foreach (@lines) {
$_ = "ChkDisk:\t$newvalue\n" if(/^ChkDisk:/);
print FH;
}
close(FH);
------------------- untested ---------------------
Provides Filelocking, in case you have
more progs accessing the file concurrently.
If not, skip the flock line.
Hope it help,
Rainer
------------------------------
Date: Fri, 24 Aug 2001 17:05:39 +0100
From: Florian Haftmann <florian@haftmann-online.de>
Subject: Re: Performance : Shell X Perl
Message-Id: <3B867B53.193AE7D7@haftmann-online.de>
Sandra Regina schrieb:
>
> HI,
>
> Is there anybody that could tell me what is better a shell or a perl
> program to do a specific
> task?
be pragmatic:
a) If you are both experienced in shell and perl programming, use this
experience to get the answer.
b) If both are new for you, try perl - generally it can do the same
tasks as any shell without more code lines.
In my view shells have their advantages in interactive mode today -
shell programming is obsolete for new tasks except really simply ones
(e.g. calling a few programmes in sequence) Of course if you have to
manage existing shell scripts, you should get fimiliar with the
shell, too-
-f.h.
------------------------------
Date: 24 Aug 2001 09:57:12 -0700
From: Brian Cantin <bcc@eswssol001.elsegundoca.ncr.com>
Subject: Re: Performance : Shell X Perl
Message-Id: <7nlmk9tmzb.fsf@eswssol001.elsegundoca.ncr.com>
mjd@plover.com (Mark Jason Dominus) writes:
> In my experience it's a lot easier to write a portable Perl program
> than a portable shell script. In 1995 you might have had to worry
> that the target system didn't have Perl, but these days Perl is almost
> everywhere.
True, Perl is available nearly everywhere, but it may not be the same
version. I run into problems all the time with machines running 5.001
on scripts that were coded and tested against later versions. The
Bourne shell and the UNIX toolkit definition is pretty much static, so
it is easier to test on a bunch of different platforms and assure
things will run.
So, pick your poison: the ever changing virtual machine that Perl
provides versus the relatively static but platform dependent UNIX
toolkit. However, if you have to support something as impoverished as
NT, you are definitely better off with Perl.
------------------------------
Date: Fri, 24 Aug 2001 17:09:29 +0100
From: Florian Haftmann <florian@haftmann-online.de>
Subject: Re: pl or not pl, that is the question
Message-Id: <3B867C39.36E0574B@haftmann-online.de>
> nothing or .pl is common in a *nix environment.
for perl scripts designed for running under Win32 or multiple platforms,
.pl should be prefered due to the meachanism Win32 executes scripts.
-f.h
------------------------------
Date: Fri, 24 Aug 2001 08:09:21 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: pl or not pl, that is the question
Message-Id: <3b866e22$1@news.microsoft.com>
"Joachim Ziegler" <ziegler@algorilla.de> wrote in message
news:93aad7d0.0108240201.240f78b2@posting.google.com...
> is it ok to call an ordinary perl-script 'helloworld.pl',
> or should it rather be call just 'helloworld'?
"A rose by any other name would have smelled as sweet"
It doesn't matter, a name is a name is a name.
The name is
- for your comfort. Use ".pl" if it pleases/helps you to find your perl
scripts. Don't use it if if annoys you to type it every time.
- needed by some programs sometimes: if your webserver insists on ".cgi",
then name it ".cgi"; if your OS won't execute a Perl script unless it has a
".pl" extension then name it ".pl"
jue
------------------------------
Date: 24 Aug 2001 11:20:06 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: qw// documentation revision (was Re: Openning a file)
Message-Id: <m3itfd5t1l.fsf_-_@dhcp9-161.support.tivoli.com>
On 23 Aug 2001, ansok@alumni.caltech.edu wrote:
> In article <slrn9oaolc.6m2.abigail@alexandra.xs4all.nl>,
> Abigail <abigail@foad.org> wrote:
>>Please write down 500 times (in blood):
>>
>> THERE ARE NO LISTS IN SCALAR CONTEXT.
>
> How would you describe this?
>
> my $x = qw/a b c/;
>
> According to perlop, qw// generates "a real list".
>
> I know, you'll probably tell me it's an implied comma-operator.
> But that's not how the documentation describes it. ;-)
Yes, and IMO, the documentation is in error. A simple test:
$ perl -le 'print $x = qw/a b c/'
c
Shows that the behavior is the same as the comma operator. The
current (5.6.1) documentation:
qw/STRING/
Evaluates to a list of the words extracted out of
STRING, using embedded whitespace as the word
delimiters. It can be understood as being roughly
equivalent to:
split(' ', q/STRING/);
the difference being that it generates a real list
at compile time. So this expression:
qw(foo bar baz)
is semantically equivalent to the list:
'foo', 'bar', 'baz'
Some frequently seen examples:
use POSIX qw( setlocale localeconv )
@EXPORT = qw( foo bar baz );
A common mistake is to try to separate the words
with comma or to put comments into a multi-line
"qw"-string. For this reason, the "use warnings"
pragma and the -w switch (that is, the "$^W" vari
able) produces warnings if the STRING contains the
"," or the "#" character.
should be changed to something like:
qw/STRING/
Evaluates to a sequence of comma-separated,
single-quoted sub-strings extracted out of STRING,
using embedded whitespace as the delimiters.
In list context, it can be understood as being roughly
equivalent to:
split(' ', q/STRING/, -1);
the difference being that it happens at compile time.
In scalar context, it evaluates to the final sub-string
of the sequence.
So this expression:
qw(foo bar baz)
is semantically equivalent to this one:
('foo', 'bar', 'baz')
in both list and scalar contexts (evaluating to a list
of the three elements in list context and 'baz' in
scalar context).
Some frequently seen examples:
use POSIX qw( setlocale localeconv )
@EXPORT = qw( foo bar baz );
A common mistake is to try to separate the words
with comma or to put comments into a multi-line
"qw"-string. For this reason, the "use warnings"
pragma and the -w switch (that is, the "$^W" vari
able) produces warnings if the STRING contains the
"," or the "#" character.
Comments?
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Fri, 24 Aug 2001 15:43:06 +0200
From: kb <_nospam_m9652@abc.se>
Subject: read next line into $_
Message-Id: <3B8659EA.513BA69A@abc.se>
hi
how can i manually (not using a loop) read the next line from a text
file into $_?
/konrad
------------------------------
Date: 24 Aug 2001 13:44:32 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: read next line into $_
Message-Id: <9m5lo0$euk$2@mamenchi.zrz.TU-Berlin.DE>
According to kb <_nospam_m9652@abc.se>:
> hi
>
> how can i manually (not using a loop) read the next line from a text
> file into $_?
$_ = <$fh> unless eof $fh;
Anno
------------------------------
Date: Fri, 24 Aug 2001 19:04:53 +0200
From: "Frank Benady" <f.benady@french-connexion.fr>
Subject: restarting named...takes a longtime...???
Message-Id: <9m61sm$c7m$1@wanadoo.fr>
Hi all
I run Bind 8.2.3-REL on Linux Red Hat 6.0
named serves about 4000 zones on the server.
The pb : it takes 20 up to 30 minutes to restart named with the following
command
/usr/sbin/named -c /etc/named/named.conf
Is it normal ? Is it because of the 4000 db.files it has to read ?
Moreover, when named restarts the syslogd start eating up all the ressources
on the server.
Do I have to stop syslod before restarting named ?
If I do a simple kill -HUP, are the new zones loaded ? It seems it isn't....
Or what about the ndc reload command ?
Thanks for your kind help
Frank
------------------------------
Date: 24 Aug 2001 17:37:00 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: restarting named...takes a longtime...???
Message-Id: <9m63bs$1fq$3@mamenchi.zrz.TU-Berlin.DE>
According to Frank Benady <f.benady@french-connexion.fr>:
> Hi all
>
>
> I run Bind 8.2.3-REL on Linux Red Hat 6.0
>
>
> named serves about 4000 zones on the server.
>
> The pb : it takes 20 up to 30 minutes to restart named with the following
> command
>
> /usr/sbin/named -c /etc/named/named.conf
>
> Is it normal ? Is it because of the 4000 db.files it has to read ?
>
> Moreover, when named restarts the syslogd start eating up all the ressources
> on the server.
> Do I have to stop syslod before restarting named ?
>
> If I do a simple kill -HUP, are the new zones loaded ? It seems it isn't....
> Or what about the ndc reload command ?
Wrong door. linux.redhat.misc is over there.
Anno
------------------------------
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 1604
***************************************