[19440] in Perl-Users-Digest
Perl-Users Digest, Issue: 1635 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 28 06:10:27 2001
Date: Tue, 28 Aug 2001 03:10:13 -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: <998993412-v10-i1635@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 28 Aug 2001 Volume: 10 Number: 1635
Today's topics:
Re: Newbie. Searching a text file and replacing text. <Rainer.Klier@erl.sbs.de>
Re: Perl number conversion Utilities <jonni@ifm.liu.nospam.se>
Re: Perl number conversion Utilities <bart.lateur@skynet.be>
Profiling <mh2@isis.co.za>
REGEX <fredrik.andersson@esavionics.se>
Re: REGEX <mbudash@sonic.net>
Re: REGEX <Rainer.Klier@erl.sbs.de>
Re: REGEX (Philip Lees)
Re: REGEX <goldbb2@earthlink.net>
ucd snmp ? <petek.external@infineon.com>
Re: warnings with cgi will crash Win32 perl core <godzilla@stomp.stomp.tokyo>
Re: warnings with cgi will crash Win32 perl core <noone@nospam.com>
Re: warnings with cgi will crash Win32 perl core (Yves Orton)
Re: warnings with cgi will crash Win32 perl core <Thomas@Baetzler.de>
Re: Will Perl report on variables no longer used?? <godzilla@stomp.stomp.tokyo>
Re: Will Perl report on variables no longer used?? (Abigail)
Re: zipping in perl <no@mail.addr>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 28 Aug 2001 10:44:12 -0100
From: Rainer Klier <Rainer.Klier@erl.sbs.de>
Subject: Re: Newbie. Searching a text file and replacing text.
Message-Id: <3B8B840C.1E859BB8@erl.sbs.de>
Hardy Merrill wrote:
>
> Rainer Klier <Rainer.Klier@erl.sbs.de> wrote in message news:<3B8A1887.F8A79B8C@erl.sbs.de>...
>
> > What I wonder is, wether this is a common way to
> > update textfiles. Is there another possibility?
> > I do not like the idea so much to load the whole
> > file into memory.
>
> You could open a filehandle to the file and read it line
> by line - use a regex on each line to find the line you're
> looking for, and write the lines you want to a temporary file.
> When your done reading and writing, then do a "move"(from
> File::Copy) from the temporary file to the real input file you
> started with:
>
> use File::Copy; ### for "move"
Hmm .. this for sure works fine, but I guess,
I could run into problems, when I exclusively
need to update the file, because the lock
is on the orignal file and I cannot move the
new file in an atomic command on the old file.
Maybe I should have mentioned the exclusive
lock in my first posting.
Thanx anyways.
Rainer
------------------------------
Date: Tue, 28 Aug 2001 08:46:34 +0200
From: "Jonas Nilsson" <jonni@ifm.liu.nospam.se>
Subject: Re: Perl number conversion Utilities
Message-Id: <9mfee9$kfc$1@newsy.ifm.liu.se>
One could use.
sub float2bin {0+(dec2bin(int $_[0]).".".sprintf "%011i",dec2bin int
2**11*($_[0]-int $_[0] ));}
sub bin2float {bin2dec((split /\./,$_[0])[0])+bin2dec(((split
/\./,$_[0])[1]."0"x11)=~/(\d{11})/)/2**11;}
--
/jN
"Aziz Shallwani" <ashallwani@tsp.ece.mcgill.ca> wrote in message
news:aABi7.23460$KE4.3093698@carnaval.risq.qc.ca...
| Would anybody have a float2bin and bin2float subroutines similar to the
| dec2bin and bin2dec subroutines?
|
| thanks
| Aziz
|
| "Tina Mueller" <tinamue@zedat.fu-berlin.de> wrote in message
| news:9mei3g$1r6f5$4@fu-berlin.de...
| > Joseph Hasting <hasting@agere.com> wrote:
| > > Hi, I spent some time putting these number conversion subroutines
| > > together. It was very difficult to find the non-printf ways to
convert
| > > number formats, so I thought I would share them:
| >
| > > sub dec2bin {my $str = unpack("B32", pack("N", shift)); $str =~
| > > s/^0+(?=\d)//; return $str;}
| >
| > at least that one can be:
| > sub dec2bin {sprintf "%b", shift} # for perl 5.6 or higher
| >
| > regards,
| > tina
| > --
| > http://www.tinita.de \ enter__| |__the___ _ _ ___
| > tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
| > search & add comments \ \ _,_\ __/\ __/_| /__/ perception
| > --- Warning: content of homepage hopelessly out-dated ---
|
|
------------------------------
Date: Tue, 28 Aug 2001 09:00:18 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Perl number conversion Utilities
Message-Id: <r7nmotski2jfrjh5n7ao7f4ai9fme058f4@4ax.com>
Tina Mueller wrote:
>> sub dec2bin {my $str = unpack("B32", pack("N", shift)); $str =~
>> s/^0+(?=\d)//; return $str;}
>
>at least that one can be:
>sub dec2bin {sprintf "%b", shift} # for perl 5.6 or higher
And bin2dec can be achieved using oct(). The argument must contain only
"0" and "1" characters.
sub bin2dec { oct("b".shift) };
--
Bart.
------------------------------
Date: Tue, 28 Aug 2001 10:37:25 +0200
From: "NoNameBrand" <mh2@isis.co.za>
Subject: Profiling
Message-Id: <9mfl6g$ido$1@ctb-nnrp2.saix.net>
Hi,
I posted this to alt.perl as well, but wondered this group wouldn't be more
appropriate...
I have been wokring to rewrite some scripts, to reduce compile and excution
time.
Does anybody have any suggestions as to how I could go about timing these
operations, in particular the load/compile time of a cgi, as well as the
execution of the script? I would like to be able to compare the original to
my changed versions, to get some stats about what improvements have been
gained.
I am running the latest Apache with ActiveState PERL on a Windows 98
machine.
Many thankx in advance...
------------------------------
Date: Tue, 28 Aug 2001 09:11:58 +0200
From: Fredrik Andersson <fredrik.andersson@esavionics.se>
Subject: REGEX
Message-Id: <3B8B443E.63C57FED@esavionics.se>
Hi, I'm trying to use a REGEX for adding integers.
I have a file with ascii text and are seaching for lines
with the text POS_Z (se below)
BUTTON_01 = SYMBOL /POS_Z = -770 /POS_Z = -950 /DATA=#1
BUTTON_45 = SYMBOL /POS_Z = 570 /POS_Z = 320 /DATA=#1
I want to add an integer to the number after the POS_Z =
Say 20 =>
BUTTON_01 = SYMBOL /POS_Z = -750 /POS_Z = -950 /DATA=#1
BUTTON_45 = SYMBOL /POS_Z = 590 /POS_Z = 320 /DATA=#1
Best regards Fredrik Andersson
------------------------------
Date: Tue, 28 Aug 2001 07:32:48 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: REGEX
Message-Id: <mbudash-974093.00324928082001@news.sonic.net>
In article <3B8B443E.63C57FED@esavionics.se>, Fredrik Andersson
<fredrik.andersson@esavionics.se> wrote:
> Hi, I'm trying to use a REGEX for adding integers.
> I have a file with ascii text and are seaching for lines
> with the text POS_Z (se below)
>
> BUTTON_01 = SYMBOL /POS_Z = -770 /POS_Z = -950 /DATA=#1
> BUTTON_45 = SYMBOL /POS_Z = 570 /POS_Z = 320 /DATA=#1
>
> I want to add an integer to the number after the POS_Z =
> Say 20 =>
> BUTTON_01 = SYMBOL /POS_Z = -750 /POS_Z = -950 /DATA=#1
> BUTTON_45 = SYMBOL /POS_Z = 590 /POS_Z = 320 /DATA=#1
>
> Best regards Fredrik Andersson
one way:
$line =~ s/(POS_Z\s+=\s+)(\S+)/$1 . ($2 + 20)/e;
hth-
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: Tue, 28 Aug 2001 08:57:04 -0100
From: Rainer Klier <Rainer.Klier@erl.sbs.de>
Subject: Re: REGEX
Message-Id: <3B8B6AF0.9E949D63@erl.sbs.de>
Fredrik Andersson wrote:
>
> Hi, I'm trying to use a REGEX for adding integers.
> I have a file with ascii text and are seaching for lines
> with the text POS_Z (se below)
>
> BUTTON_01 = SYMBOL /POS_Z = -770 /POS_Z = -950 /DATA=#1
> BUTTON_45 = SYMBOL /POS_Z = 570 /POS_Z = 320 /DATA=#1
>
> I want to add an integer to the number after the POS_Z =
> Say 20 =>
> BUTTON_01 = SYMBOL /POS_Z = -750 /POS_Z = -950 /DATA=#1
> BUTTON_45 = SYMBOL /POS_Z = 590 /POS_Z = 320 /DATA=#1
>
> Best regards Fredrik Andersson
while(<DATA>) {
s/(.*?\/.*?=\s+)([-+]?\d+)(.*)/$1.($2+20).$3/e;
print;
}
__DATA__
BUTTON_01 = SYMBOL /POS_Z = -770 /POS_Z = -950 /DATA=#1
BUTTON_45 = SYMBOL /POS_Z = 570 /POS_Z = 320 /DATA=#1
This only changes the second column of data.
Regards, Rainer
------------------------------
Date: Tue, 28 Aug 2001 09:34:32 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: Re: REGEX
Message-Id: <3b8b652f.75772715@news.grnet.gr>
On Tue, 28 Aug 2001 09:11:58 +0200, Fredrik Andersson
<fredrik.andersson@esavionics.se> wrote:
>Hi, I'm trying to use a REGEX for adding integers.
>I have a file with ascii text and are seaching for lines
>with the text POS_Z (se below)
>
>BUTTON_01 = SYMBOL /POS_Z = -770 /POS_Z = -950 /DATA=#1
>BUTTON_45 = SYMBOL /POS_Z = 570 /POS_Z = 320 /DATA=#1
>
>I want to add an integer to the number after the POS_Z =
>Say 20 =>
>BUTTON_01 = SYMBOL /POS_Z = -750 /POS_Z = -950 /DATA=#1
>BUTTON_45 = SYMBOL /POS_Z = 590 /POS_Z = 320 /DATA=#1
Try this:
my $num = 20;
while( <DATA> ){
s/(POS_Z\s*=\s*)(-?\d+)/$1.($2+$num)/eo;
print;
}
__DATA__
BUTTON_01 = SYMBOL /POS_Z = -770 /POS_Z = -950 /DATA=#1
BUTTON_45 = SYMBOL /POS_Z = 570 /POS_Z = 320 /DATA=#1
If you want the regex to affect all the POS_Z numbers in a line and
not just the first one, add g after the eo.
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: Tue, 28 Aug 2001 05:44:25 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: REGEX
Message-Id: <3B8B67F9.236B046@earthlink.net>
Fredrik Andersson wrote:
>
> Hi, I'm trying to use a REGEX for adding integers.
> I have a file with ascii text and are seaching for lines
> with the text POS_Z (se below)
>
> BUTTON_01 = SYMBOL /POS_Z = -770 /POS_Z = -950 /DATA=#1
> BUTTON_45 = SYMBOL /POS_Z = 570 /POS_Z = 320 /DATA=#1
>
> I want to add an integer to the number after the POS_Z =
> Say 20 =>
> BUTTON_01 = SYMBOL /POS_Z = -750 /POS_Z = -950 /DATA=#1
> BUTTON_45 = SYMBOL /POS_Z = 590 /POS_Z = 320 /DATA=#1
while(<DATA>) {
s[(?<=POS_Z\s=\s+)([-+]?\d+)][ $1 + 20 ]e;
print;
}
__DATA__
BUTTON_01 = SYMBOL /POS_Z = -770 /POS_Z = -950 /DATA=#1
BUTTON_45 = SYMBOL /POS_Z = 570 /POS_Z = 320 /DATA=#1
This changes only the first POS_Z value in each line, but can be made to
change all of the POS_Z values simply by changing the /e flag to /eg
--
I'm not a programmer but I play one on TV...
------------------------------
Date: Tue, 28 Aug 2001 07:58:30 +0200
From: "Suko Paul" <petek.external@infineon.com>
Subject: ucd snmp ?
Message-Id: <9mfbu7$jua$1@mosquito.HL.Siemens.DE>
hope, i´m not off topic ... but a question about snmp:
I´ve installed the net-snmp package ( www.net-snmp.org ). I added a mib
Printer-MIB ). Every time i send some requests, get the warning: unlinked
OID in Printer-MIB ( 43 ). Does anyone know how to fix this ( i think its a
configuration task ).
second question: does anyone knows how to determine the trays of a printer
count )? Theres no OID, isn´t it? ( a clean way )
thanks
HP
------------------------------
Date: Mon, 27 Aug 2001 21:44:23 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: warnings with cgi will crash Win32 perl core
Message-Id: <3B8B21A7.B3E4258B@stomp.stomp.tokyo>
Matt Garrish wrote:
> Godzilla! wrote:
> > You should research your shovels better before piling
> > mule manure within this group. This child's plastic
> > play toy shovel you use, is most inefficient.
(snipped stereotypical idiotic blatherings)
Well gosh, aren't you an excitable boy.
Nice play toy shovel you have.
Is your stupefying stupidity motivated by something I said
to you over in the defunct perl group?
My presumption is, based on your skittish response, is you
really don't want to be reminded of this attempted and quite
lame Denial Of Service attack upon my site, perpetrated by
you, the Alaskan Electrician and a few other of your friends
beginning at,
00:07:42 5/20/2000
and ending at,
00:30:56 5/20/2000
Pretty darn lame technique you boys tried. Sure didn't get
you anywhere but nearly in deep shit trouble. Say, do you
know Mike Messick, the security specialist for Alaska.net?
* thinks I should have had my androids crash their systems *
I am enjoying reading so many regulars over in the defunct
perl groups telling you to get the F-word out! You are not
a very popular person nor a popular troll, yes?
Thanks for the laughs.
Godzilla!
--
21:16:26 08/27/2001 - RESTRICTED FILE REDIRECT:
- DNS: bc.dnsdhcp.provo.novell.com - IPA: 137.65.145.252
- System:
- Redirect URL: /default.ida
------------------------------
Date: Tue, 28 Aug 2001 03:02:48 -0600
From: "Michael Love" <noone@nospam.com>
Subject: Re: warnings with cgi will crash Win32 perl core
Message-Id: <3b8b5f8d.0@oracle.zianet.com>
It's pretty obvious that Godzilla doesn't really want any help and that
their goal is to just amuse themselves by engaging in a one-sided flame war.
Can't we all just killfile this person and stop responding to their ravings?
I'm doing that right now so I won't have to see any of this poster's rubbish
anymore.
Please, don't feed the trolls! :)
------------------------------------
Michael Love,
Southwest Direct Connect, Technical Support
------------------------------
Date: 28 Aug 2001 02:36:16 -0700
From: demerphq@hotmail.com (Yves Orton)
Subject: Re: warnings with cgi will crash Win32 perl core
Message-Id: <74f348f7.0108280136.23712fc7@posting.google.com>
"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message news:<3B8A65FF.792C1D28@stomp.stomp.tokyo>...
> Yves Orton wrote:
>
> > "Godzilla! wrote:
> > > Yves Orton wrote:
> > > > Godzilla! wrote
> > > > > Yves Orton wrote:
> > > > > > Godzilla! wrote:
>
>
> (snipped classic CLPM Troll blatherings)
>
>
> You and Goldberg collaborate on this Mule Manure project?
Lizard darling, all of us on CLPM who read the docs are collaborating
against you. Secretly we are bypassing your firewall and patching
your version of perl so that if you use any of the 'standard'
features, like nested subroutines, weird things happen. In fact our
latest attack we rendered all function unusable except for substr and
index. We figured you wouldnt notice anyway....
Get Real Kira.
The only reason everyone that replies says the same thing: Its 'cause
we can all see the same f*cking error that you are blabbing on about.
Despite the fact that we are all saying the same thing, for some
reason you think we are conspiring against you. It doesnt occur to
you that possibly that your code IS actually buggy. (You wouldnt have
gone far in CS, 'How dare the compiler fail to build my code! The
compiler must be broken!') And you still havent posted ANY of the
code that people have asked for. You havent sent us a copy of your
env you have demonstrated any code that other people can run to
independently verify to claims...
So ultimately you are wasting your time and ours.
Yves
------------------------------
Date: Tue, 28 Aug 2001 12:01:26 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: warnings with cgi will crash Win32 perl core
Message-Id: <0cqmotka3in9jfbefapv460pb03g8g3cch@4ax.com>
On Mon, 27 Aug 2001, "Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:
>My test script below my signature will draw pictures so those
>of you with less than acceptable reading comprehension skills
>will be afforded a better chance at just that, comprehension.
Hm. The only warning I get is
Variable "$nest_1" will not stay shared at kira.pl line 22.
> sub Nest_2
> {
> my ($nest_2) = "nest two";
> print "Nest 2: $nest_1\n";
If you change your code to give that variable a non-static value, i.e.
> sub Nest_1
> {
> my ($nest_1) = time(); #"nest one";
and then run that sub Nest_1 twice in your code, i.e.
> &Nest_1;
> sleep 2;
> &Nest_1;
you should be able to visualize what Perl's trying to tell you.
On the other hand, I don't understand why you think that Perl should
issue warnings for the other variables.
HTH,
--
Thomas Baetzler - http://baetzler.de/ - Clan LoL - http://lavabackflips.de/
I am the "ILOVEGNU" signature virus. Just copy me to your signature.
This post was infected under the terms of the GNU General Public License.
------------------------------
Date: Mon, 27 Aug 2001 21:17:35 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Will Perl report on variables no longer used??
Message-Id: <3B8B1B5F.459EEB39@stomp.stomp.tokyo>
Mark Jason Dominus wrote:
> Abigail wrote:
> >I'd be interested if you can find an algorithm that Perl should use
> >to figure out any "unused variables" that doesn't lead to false
> >positives and doesn't solve the halting problem either.
> I don't think you could, because:
> my $bar;
> if (foo()) {
> $bar = 1;
> } else {
> #
> }
> exit;
> You can't know whether foo() will return true unless you run it.
Illogical. If $bar is never used again subsequent to your
subroutine call, it is an unused variable, regardless
if $bar is undefined or defined.
Godzilla!
--
19:19:29 08/27/2001 - RESTRICTED FILE REDIRECT:
- DNS: wcc5-106.wccnet.org - IPA: 207.75.136.106
- System:
- Redirect URL: /default.ida
------------------------------
Date: 28 Aug 2001 06:28:07 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Will Perl report on variables no longer used??
Message-Id: <slrn9omefs.r1r.abigail@alexandra.xs4all.nl>
Ilmari Karonen (iltzu@sci.invalid) wrote on MMCMXIX September MCMXCIII in
<URL:news:998960983.10957@itz.pp.sci.fi>:
## In article <slrn9ol1lv.plv.abigail@alexandra.xs4all.nl>, Abigail wrote:
## >Benjamin Goldberg (goldbb2@earthlink.net) wrote on MMCMXVIII September
## >MCMXCIII in <URL:news:3B8A1425.4D5CC9D1@earthlink.net>:
## >~~
## >~~ sub foo {
## >~~ my $bar;
## >~~ 1;
## >~~ }
## >~~
## >~~ Neither $bar nor a reference to it is ever used -- yet perl gives no
## >~~ warning about it.
## >
## >So what? Unlike package variables, it's hard to come up with examples
## >where such unused variables can lead to a problem.
## >
## >I'd be interested if you can find an algorithm that Perl should use
## >to figure out any "unused variables" that doesn't lead to false
## >positives and doesn't solve the halting problem either.
##
## Well, the compiler certainly could be made to check for only-once-used
## lexicals just as it currently checks for only-once-used globals. That
## approach, of course, does produce both false positives and negatives.
## It does not, to my knowledge, solve the halting problem.
The "just as" isn't clear at all. The names of package variables live on,
while they don't for lexicals.
Abigail
--
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'
------------------------------
Date: Tue, 28 Aug 2001 15:00:19 +0800
From: MMX166+2.1G HD <no@mail.addr>
Subject: Re: zipping in perl
Message-Id: <0jdmot02mp45hvnm3vgo96c5bu58q3n1cs@4ax.com>
On Thu, 23 Aug 2001 20:06:57 -0000, in comp.lang.perl.misc "Brendon
Caligari" <bcaligari@fireforged.com> wrote:
>"mk" <mkarasick@diggstown.com> wrote in message
>news:41c8ef03.0108231140.7cb5d72b@posting.google.com...
>> Anybody know a package out there that lets me zip files for NT? Thanks.
what's the zip files for NT? are they *.zip? or *.gz, *.tar.gz? or
even *.cab, *.zz_?
I know the active-perl has tar and gz modules by default, but I think
they are good enough to use. I've found the *.tar.gz is the best
method of all.
------------------------------
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 1635
***************************************