[29947] in Perl-Users-Digest
Perl-Users Digest, Issue: 1190 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jan 13 00:09:39 2008
Date: Sat, 12 Jan 2008 21:09: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 Sat, 12 Jan 2008 Volume: 11 Number: 1190
Today's topics:
Re: Active State perl for windows not working. <wheeledBobNOSPAM@yahoo.com>
Re: Active State perl for windows not working. <john@castleamber.com>
Re: Active State perl for windows not working. <veatchla@yahoo.com>
Re: Converting milliseconds to seconds <nospam-abuse@ilyaz.org>
Re: Converting milliseconds to seconds <someone@example.com>
Re: Converting milliseconds to seconds <jurgenex@hotmail.com>
Re: csv data file, but with a twist <someone@example.com>
Re: csv data file, but with a twist <rvtol+news@isolution.nl>
How to make COPY of Worksheet(1) to some other Workshee <katja@makniovotht.hr>
Ip-In-IP Encapsulation simone.romano82@gmail.com
looking for efficient way to parse a file <emartin24@gmail.com>
Re: looking for efficient way to parse a file <noreply@gunnar.cc>
Re: looking for efficient way to parse a file xhoster@gmail.com
Re: looking for efficient way to parse a file <jurgenex@hotmail.com>
Re: Simple "rm -rf"? <cwilbur@chromatico.net>
Re: Simple "rm -rf"? xhoster@gmail.com
Re: Simple "rm -rf"? <john@castleamber.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 12 Jan 2008 23:33:46 GMT
From: still just me <wheeledBobNOSPAM@yahoo.com>
Subject: Re: Active State perl for windows not working.
Message-Id: <ohjio39jhd7gtc2ub6iubu2dgjjqjntas4@4ax.com>
On 11 Jan 2008 14:20:08 GMT, John Bokma <john@castleamber.com> wrote:
>
>> I use perl as a hobby and don't face issues that
>> say, a sysadmin might.
>
>Your computer is connected to the Internet, right? In that case you might
>not care about the issues, but others connected to the Internet /do/. Most
>spam and other garbage nowadays comes from computers that got infected
>because their owner was (and still is) careless.
>
>>> Also, it *should* work from any location, has been doing so for me
>>> for years.
>> Apparently it works for me too.
>
>That's good to hear. Anyway, I strongly recommend to create another
>account for day-to-day use on your computer and make sure you make it have
>"limited rights", unless I was mistaken.
Unfortunately, unless you are a sysadmin, you likely have to run
windows as an administrator just to survive. Sort of a catch-22.
------------------------------
Date: 12 Jan 2008 23:49:49 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Active State perl for windows not working.
Message-Id: <Xns9A23B56168481castleamber@130.133.1.4>
still just me <wheeledBobNOSPAM@yahoo.com> wrote:
> On 11 Jan 2008 14:20:08 GMT, John Bokma <john@castleamber.com> wrote:
[..]
>>That's good to hear. Anyway, I strongly recommend to create another
>>account for day-to-day use on your computer and make sure you make it
>>have "limited rights", unless I was mistaken.
>
> Unfortunately, unless you are a sysadmin, you likely have to run
> windows as an administrator just to survive. Sort of a catch-22.
That once in a while an action requires Admin rights doesn't mean one has
to work the whole day with such rights.
--
John
http://johnbokma.com/mexit/
------------------------------
Date: Sat, 12 Jan 2008 19:32:35 -0600
From: l v <veatchla@yahoo.com>
Subject: Re: Active State perl for windows not working.
Message-Id: <13oiqhk1pfuodf5@news.supernews.com>
still just me wrote:
> On 11 Jan 2008 14:20:08 GMT, John Bokma <john@castleamber.com> wrote:
>
>>> I use perl as a hobby and don't face issues that
>>> say, a sysadmin might.
>> Your computer is connected to the Internet, right? In that case you might
>> not care about the issues, but others connected to the Internet /do/. Most
>> spam and other garbage nowadays comes from computers that got infected
>> because their owner was (and still is) careless.
>>
>>>> Also, it *should* work from any location, has been doing so for me
>>>> for years.
>>> Apparently it works for me too.
>> That's good to hear. Anyway, I strongly recommend to create another
>> account for day-to-day use on your computer and make sure you make it have
>> "limited rights", unless I was mistaken.
>
> Unfortunately, unless you are a sysadmin, you likely have to run
> windows as an administrator just to survive. Sort of a catch-22.
>
>
My children do not have accounts with admin rights and I only need to
get involved when they new to install something, not very often.
Additionally many corporations do not give admin rights to their
employee owned assets and they survive quite well.
--
Len
------------------------------
Date: Sat, 12 Jan 2008 23:15:07 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Converting milliseconds to seconds
Message-Id: <fmbhlr$2jtm$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Jürgen Exner
<jurgenex@hotmail.com>], who wrote in article <ik3go3pgkcrol2diigag1hl2prkke0ktt7@4ax.com>:
> >This is just a reflection of a sorry state of Perl documentation.
> >There is NO OTHER WAY to round-to-0 but to use int().
>
> Your statement is non sequitur. int() does not an never was supposed to
> round a number. If you expect int() to round a number then you are mistaken
> about the semantic of this function.
I assure you that int() does nothing else but rounding-to-0.
Hope this helps,
Ilya
------------------------------
Date: Sun, 13 Jan 2008 01:13:24 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Converting milliseconds to seconds
Message-Id: <UAdij.28019$fj2.15938@edtnps82>
Ilya Zakharevich wrote:
> [A complimentary Cc of this posting was sent to
> J=FCrgen Exner=20
> <jurgenex@hotmail.com>], who wrote in article <ik3go3pgkcrol2diigag1hl2=
prkke0ktt7@4ax.com>:
>>> This is just a reflection of a sorry state of Perl documentation.
>>> There is NO OTHER WAY to round-to-0 but to use int(). =20
>> Your statement is non sequitur. int() does not an never was supposed t=
o
>> round a number. If you expect int() to round a number then you are mis=
taken
>> about the semantic of this function.
>=20
> I assure you that int() does nothing else but rounding-to-0.
Then why does the documentation say:
perldoc -f int
int EXPR
int Returns the integer portion of EXPR. If EXPR is omitted,
uses $_. You should not use this function for rounding: one=
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
because it truncates towards 0, and two because machine
^^^^^^^^^
representations of floating point numbers can sometimes
produce counterintuitive results. For example,
"int(-6.725/0.025)" produces -268 rather than the correct
-269; that=92s because it=92s really more like
-268.99999999999994315658 instead. Usually, the "sprintf",
"printf", or the "POSIX::floor" and "POSIX::ceil" functions
will serve you better than will int().
John
--=20
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
------------------------------
Date: Sun, 13 Jan 2008 02:32:32 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Converting milliseconds to seconds
Message-Id: <hrtio3d2mf132qo44iatbi88nhthe2gnfm@4ax.com>
Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote:
>[A complimentary Cc of this posting was sent to
>Jürgen Exner
Please don't do that. I happen to read the NGs in which I am posting.
><jurgenex@hotmail.com>], who wrote in article <ik3go3pgkcrol2diigag1hl2prkke0ktt7@4ax.com>:
>> >This is just a reflection of a sorry state of Perl documentation.
>> >There is NO OTHER WAY to round-to-0 but to use int().
>>
>> Your statement is non sequitur. int() does not an never was supposed to
>> round a number. If you expect int() to round a number then you are mistaken
>> about the semantic of this function.
>
>I assure you that int() does nothing else but rounding-to-0.
As I said: you are greatly mistaken about the intended semantic of int().
You may want to read the documentation for clarification.
jue
------------------------------
Date: Sat, 12 Jan 2008 21:46:22 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: csv data file, but with a twist
Message-Id: <Oyaij.4463$yQ1.251@edtnps89>
Dr.Ruud wrote:
> nun schreef:
>
>> Actual sample data:
>> 0120 ,HOOK, TAPERED ,0004.57,0002.74,N,O, ,254-72 ,001
>>
>> What I'd like to and up with:
>> 0120 ,HOOK - TAPERED ,0004.57,0002.74,N,O, ,254-72 ,001
>>
>> There *may* be lines which have more than one comma in the DESCR
>> field. but luckily the 3rd field always has the format XXXX.XX (four
>> digits, decimal, 2 digits)
>
>
> To start you off:
>
> #!/usr/bin/perl
> use strict;
> use warnings;
> use Data::Dumper;
>
> my @data = split /((?<=,)[0-9]{4}[.][0-9]{2},)/, <DATA>, 2;
> print Dumper \@data;
>
> $data[0] = \@{[ split /\s*,/, $data[0], 2 ]};
> $data[2] = \@{[ split /\s*,/, $data[2] ]};
Why create an anonymous array reference, and then dereference it, and
then reference that dereference?
> print Dumper \@data;
>
> __DATA__
> 0120 ,HOOK, TAPERED ,0004.57,0002.74,N,O, ,254-72 ,001
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
------------------------------
Date: Sun, 13 Jan 2008 01:17:36 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: csv data file, but with a twist
Message-Id: <fmbp6t.1jo.1@news.isolution.nl>
John W. Krahn schreef:
> Dr.Ruud:
>> $data[0] = \@{[ split /\s*,/, $data[0], 2 ]};
>
> Why create an anonymous array reference, and then dereference it, and
> then reference that dereference?
Oops, was playing away with the code and just never went back.
$data[0] = [ split /\s*,/, $data[0], 2 ];
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: Sat, 12 Jan 2008 22:09:27 +0100
From: "Katja" <katja@makniovotht.hr>
Subject: How to make COPY of Worksheet(1) to some other Worksheet ???
Message-Id: <fmbaa8$p77$1@localhost.localdomain>
How to make COPY of Worksheet(1)to some other Worksheet ???
Please Help!
------------------
use strict;
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Excel';
$Win32::OLE::Warn = 3; # die on errors...
# get already active Excel application or open new
my $Excel = Win32::OLE->GetActiveObject('Excel.Application')
|| Win32::OLE->new('Excel.Application', 'Quit');
my $Book = $Excel->Workbooks->Open('d:\cgi\work.xls');
my $Sheet = $Book->Worksheets(1);
# How to make COPY of Worksheet(1) to some other Worksheet ???
#
$Book->Save;
------------------
------------------------------
Date: Sat, 12 Jan 2008 13:27:37 -0800 (PST)
From: simone.romano82@gmail.com
Subject: Ip-In-IP Encapsulation
Message-Id: <163b792f-67b5-4397-908d-6e2b887c1122@t1g2000pra.googlegroups.com>
Hi,
I'm writing a script PERL for ip-in-ip encapsulation.
I could give multicast packet over udp connection encapusalate it and
send it to peer destination.
I'll use the NetPacket::UDP module.
Think you that it is a good idea? Help and idea for the problem are
welcome....
Thanks in advance...
Simo
------------------------------
Date: Sat, 12 Jan 2008 13:40:10 -0800 (PST)
From: Eric Martin <emartin24@gmail.com>
Subject: looking for efficient way to parse a file
Message-Id: <f2d4fb07-6e8f-4ab8-af1c-5e9f4920766c@q39g2000hsf.googlegroups.com>
Hello,
I have a file with the following data structure:
#category
item name
data1
data2
item name
data1
data2
#category
item name
data1
data2
... etc.
Any line that starts with #, indicates a new category. Between
categories, there can be any number of items, with associated data.
Each item has exactly two data properties.
My plan was to just get an array that contained the index of each of
the categories and then parse each item from there, since they are in
a set format...but I was wondering if there were any suggestions for a
more efficient way...
------------------------------
Date: Sat, 12 Jan 2008 23:59:13 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: looking for efficient way to parse a file
Message-Id: <5usv28F1iv78kU1@mid.individual.net>
Eric Martin wrote:
> I have a file with the following data structure:
> #category
> item name
> data1
> data2
> item name
> data1
> data2
> #category
> item name
> data1
> data2
> ... etc.
>
> Any line that starts with #, indicates a new category. Between
> categories, there can be any number of items, with associated data.
> Each item has exactly two data properties.
>
> My plan was to just get an array that contained the index of each of
> the categories and then parse each item from there, since they are in
> a set format...
Not sure what you mean by that. Could you please expand?
> but I was wondering if there were any suggestions for a
> more efficient way...
Efficient - in what sense?
To me, the described data structure would suggest a HoHoA (hash of
hashes of arrays):
use Data::Dumper;
my (%HoHoA, $cat);
while ( <DATA> ) {
chomp;
if ( substr($_, 0, 1) eq '#' ) {
$cat = substr $_, 1;
next;
}
for my $item ( 0, 1 ) {
chomp( $HoHoA{$cat}{$_}[$item] = <DATA> );
}
}
print Dumper \%HoHoA;
__DATA__
#category1
item1
data1
data2
item2
data1
data2
#category2
item1
data1
data2
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 12 Jan 2008 23:09:20 GMT
From: xhoster@gmail.com
Subject: Re: looking for efficient way to parse a file
Message-Id: <20080112180923.412$Bv@newsreader.com>
Eric Martin <emartin24@gmail.com> wrote:
> Hello,
>
> I have a file with the following data structure:
> #category
> item name
> data1
> data2
> item name
> data1
> data2
> #category
> item name
> data1
> data2
> ... etc.
>
> Any line that starts with #, indicates a new category. Between
> categories, there can be any number of items, with associated data.
> Each item has exactly two data properties.
>
> My plan was to just get an array that contained the index of each of
> the categories
That suggests the categories are already in an array, or else what is the
index the index to? I'd probably not bother to load them into an array
in the first place, just parse it on the fly. Maybe not, depending on
where it was coming from and how big I expected it to plausibly get.
> and then parse each item from there, since they are in
> a set format...but I was wondering if there were any suggestions for a
> more efficient way...
Efficient in what sense? Memory? CPU time? Programmer maintenance time?
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
------------------------------
Date: Sun, 13 Jan 2008 02:38:14 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: looking for efficient way to parse a file
Message-Id: <e4uio351m3e0s1gf2cvee0irliacb98k3b@4ax.com>
Eric Martin <emartin24@gmail.com> wrote:
>I have a file with the following data structure:
>#category
>item name
>data1
>data2
>item name
>data1
>data2
>#category
>item name
>data1
>data2
>... etc.
>
>Any line that starts with #, indicates a new category. Between
>categories, there can be any number of items, with associated data.
>Each item has exactly two data properties.
That suggests to me a Hash(category) of Hash(item name) of Array (two data
elements)
>My plan was to just get an array that contained the index of each of
>the categories and then parse each item from there, since they are in
What's an index of a category?
>a set format...but I was wondering if there were any suggestions for a
>more efficient way...
Reading the file line by line in a linear manner is about as efficient as
you can possibly get because you need to read each item at least once and
you don't read it more than once, either. The suggested data structure would
support a linear reading, too.
jue
------------------------------
Date: 12 Jan 2008 14:05:43 -0500
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: Simple "rm -rf"?
Message-Id: <877iie27aw.fsf@mithril.chromatico.net>
>>>>> "JP" == Joachim Pense <snob@pense-mainz.eu> writes:
JP> Am 12 Jan 2008 17:43:59 GMT schrieb Abigail:
>> Considering that Perl is a glue language, calling a tool to do
>> the job is a VERY Perlish way to accomplish your goals.
>>
>> system rm => "-rf", TEMPDIR
>>
>> takes just one line.
JP> And what if you need to port your code to Windows?
If you *do* need to port your code to Windows, you fix it then.
That's what "porting" means.
If you never need to port your code to Windows, the simpler solution
saves you programmer time. If you think you *may* need to port your
code to Windows *someday*, you put in a comment that says
# TODO: this won't work on Windows
and get on with your life.
Charlton
--
Charlton Wilbur
cwilbur@chromatico.net
------------------------------
Date: 12 Jan 2008 23:14:03 GMT
From: xhoster@gmail.com
Subject: Re: Simple "rm -rf"?
Message-Id: <20080112181406.385$Sd@newsreader.com>
Joachim Pense <snob@pense-mainz.eu> wrote:
> Am 12 Jan 2008 17:43:59 GMT schrieb Abigail:
>
> > _
> > Bernie Cosell (bernie@fantasyfarm.com) wrote on VCCXLVII September
> > MCMXCIII in
> > <URL:news:r3iho3psrttro1d7vpdoup8ct9nrfoij4f@library.airnews.net>: ??
> > I want to nuke a temp directory. The very simplest way to do it is ??
> > system("rm", "-rf", TEMPDIR), but I'm wondering if there's a perlish
> > way to ?? do it that'd be about as easy.
> ....
> > Considering that Perl is a glue language, calling a tool to do the job
> > is a VERY Perlish way to accomplish your goals.
> >
> > system rm => "-rf", TEMPDIR
> >
> > takes just one line.
> >
>
> And what if you need to port your code to Windows?
Then do it.
What if you want to port your code to Java? What if I want hamburger
for lunch?
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
------------------------------
Date: 12 Jan 2008 23:51:34 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Simple "rm -rf"?
Message-Id: <Xns9A23B5AD03307castleamber@130.133.1.4>
xhoster@gmail.com wrote:
> What if you want to port your code to Java? What if I want hamburger
> for lunch?
And what if you don't? Questions, questions. And those don't get your
tempdir cleaned :-)
--
John
http://johnbokma.com/
------------------------------
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 V11 Issue 1190
***************************************