[28615] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 9979 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 18 11:05:55 2006

Date: Sat, 18 Nov 2006 08:05:06 -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, 18 Nov 2006     Volume: 10 Number: 9979

Today's topics:
        At a loss how to sort this file <cdalten@gmail.com>
    Re: At a loss how to sort this file <jurgenex@hotmail.com>
    Re: At a loss how to sort this file <cdalten@gmail.com>
    Re: At a loss how to sort this file (reading news)
    Re: best practice to avoiding excessive memory usage?? <hjp-usenet2@hjp.at>
    Re: Do I *have* to use 'OOP' to use modules? <abigail@abigail.be>
    Re: Do I *have* to use 'OOP' to use modules? <asandstrom@accesswave.ca>
    Re: Do I *have* to use 'OOP' to use modules? <bart.lateur@pandora.be>
    Re: Do I *have* to use 'OOP' to use modules? <spamtrap@dot-app.org>
    Re: FAQ 6.6 How can I make "\w" match national characte <rvtol+news@isolution.nl>
    Re: HoA bug? Size limit? <tadmc@augustmail.com>
    Re: HoA bug? Size limit? <wahab@chemie.uni-halle.de>
    Re: HoA bug? Size limit? <wahab@chemie.uni-halle.de>
    Re: is there a bash script to perl converter? <tadmc@augustmail.com>
    Re: Module help! <struggle@mail.nankai.edu.cn>
    Re: Module help! <spamtrap@dot-app.org>
    Re: OT: O'Reilly 'Perl CD Bookshelf' - gone for good? <sigzero@gmail.com>
    Re: OT: O'Reilly 'Perl CD Bookshelf' - gone for good? <spamtrap@dot-app.org>
    Re: p-value calculation <tadmc@augustmail.com>
    Re: threads crash on XP (in Tk script) <zentara@highstream.net>
        Warning Re: is there a bash script to perl converter? <fake@fake.com>
    Re: Warning Re: is there a bash script to perl converte <tadmc@augustmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 18 Nov 2006 03:03:27 -0800
From: "grocery_stocker" <cdalten@gmail.com>
Subject: At a loss how to sort this file
Message-Id: <1163847807.732818.256840@e3g2000cwe.googlegroups.com>

If I have a file in the following format:

lar              ttyp2    216.106.179.129  Fri Nov 17 17:12 - 17:14
(00:01)
lar              ttypa    216.106.179.129  Fri Nov 17 15:53 - 15:55
(00:01)
lar              ttypp    216.106.179.129  Thu Nov 16 17:11 - 17:21
(00:09)
lar              ttypk    216.106.179.129  Thu Nov 16 14:20 - 14:21
(00:01)
lar              ttypn    216.106.179.129  Thu Nov 16 13:23 - 13:37
(00:13)
irongeek         ttypi    216.106.179.129  Wed Nov 15 17:27 - 17:32
(00:04)
sabre            ttyp5    216.106.179.129  Wed Nov 15 13:59 - 14:03
(00:04)
lar              ttyp5    216.106.179.129  Wed Nov 15 13:57 - 13:59
(00:01)
sabre            ttyp5    216.106.179.129  Wed Nov 15 13:28 - 13:57
(00:28)
sabre            ttypc    216.106.179.129  Wed Nov 15 12:10 - 12:10
(00:00)

lar              ttypd    71.57.146.22     Fri Nov 17 07:27 - 07:43
(00:16)
irongeek         ttyp2    71.57.146.22     Thu Nov 16 07:49 - 07:56
(00:07)
sabre            ttypg    71.57.146.22     Sat Nov 11 15:56 - 16:09
(00:12)

The stuff before the space is already sorted. After the space break,
the data is sorted again. I want
all the data in this file to be sorted in descending order. I tried
looking at bash sort, but I couldn't
find anything.

I thought maybe I could also do this:
-read in each line
-have the date as the first value, and the reference to the list(?) as
the second value.
-Make the first value the hash key and the reference to the list the
value of the hash key
-sort the hash keys and write back

However, for some reason, this seems a bit overcomplicated. 

Ideas?



------------------------------

Date: Sat, 18 Nov 2006 12:19:44 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: At a loss how to sort this file
Message-Id: <ATC7h.1284$7a2.1058@trndny06>

grocery_stocker wrote:

Dear Grocery

> If I have a file in the following format:
>
> lar              ttyp2    216.106.179.129  Fri Nov 17 17:12 - 17:14
> (00:01)

I presume this (00::01) actually belongs at the end of the preceeding line 
and it's just you newsreader that wrapped that line?

> lar              ttypa    216.106.179.129  Fri Nov 17 15:53 - 15:55
> (00:01)
> lar              ttypp    216.106.179.129  Thu Nov 16 17:11 - 17:21
> (00:09)
> lar              ttypk    216.106.179.129  Thu Nov 16 14:20 - 14:21
> (00:01)
> lar              ttypn    216.106.179.129  Thu Nov 16 13:23 - 13:37
> (00:13)
> irongeek         ttypi    216.106.179.129  Wed Nov 15 17:27 - 17:32
> (00:04)
> sabre            ttyp5    216.106.179.129  Wed Nov 15 13:59 - 14:03
> (00:04)
> lar              ttyp5    216.106.179.129  Wed Nov 15 13:57 - 13:59
> (00:01)
> sabre            ttyp5    216.106.179.129  Wed Nov 15 13:28 - 13:57
> (00:28)
> sabre            ttypc    216.106.179.129  Wed Nov 15 12:10 - 12:10
> (00:00)
>
> lar              ttypd    71.57.146.22     Fri Nov 17 07:27 - 07:43
> (00:16)
> irongeek         ttyp2    71.57.146.22     Thu Nov 16 07:49 - 07:56
> (00:07)
> sabre            ttypg    71.57.146.22     Sat Nov 11 15:56 - 16:09
> (00:12)
>
> The stuff before the space is already sorted.

You got me confused. Do you mean the list is already sorted by 'lar', 
'sabre', and 'irongeek'?
Where? I mean, I can clearly see that each of those values appears several 
times and totally intermixed with the others. To me that is not sorted at 
all.
If you mean something else by "before the space is already sorted", then 
please explain.

> After the space break,
> the data is sorted again.

Are you talking about the substrings that start with 'ttyp', either with or 
without the rest of each line. Again, I do not recognize any sorting order 
in those values, neither overall nor within each group of values for 'lar', 
'sabre', and 'irongeek' in case you were talking about primary and secondary 
sort keys.

> I want
> all the data in this file to be sorted in descending order.

Do you mean all the data (like in each column individually; I cannot think 
of an application where this would make sense) or all the lines?

> I tried
> looking at bash sort, but I couldn't
> find anything.

Well, I may not be up to speed but last I've never heard of any algorithm 
called bash sort, either.
What's wrong with just using the buildin Perl sort()?
All you have to do is to define your custom comparison function and then you 
can sort by whatever you like. There is even an FAQ "How do I sort an array 
by (anything)?". I'd like to help, but from your description and data sample 
it is impossible to figure out what your desired end result should look 
like.
BTW: some people will probably suggest a Schwartzian Transformation. That is 
an interesting optimization technique if and when the data set becomes large 
and performance and issue. For a first simple solution "Make it work" there 
is no need for it.

jue




------------------------------

Date: 18 Nov 2006 07:05:38 -0800
From: "grocery_stocker" <cdalten@gmail.com>
Subject: Re: At a loss how to sort this file
Message-Id: <1163862338.795256.69390@f16g2000cwb.googlegroups.com>


J=FCrgen Exner wrote:
> grocery_stocker wrote:
>
> Dear Grocery
>
> > If I have a file in the following format:
> >
> > lar              ttyp2    216.106.179.129  Fri Nov 17 17:12 - 17:14
> > (00:01)
>
> I presume this (00::01) actually belongs at the end of the preceeding line
> and it's just you newsreader that wrapped that line?

Yes the (00:01) belongs at the end of the line. My newsreader like to
wrap things at the most inane times.

> > lar              ttypa    216.106.179.129  Fri Nov 17 15:53 - 15:55
> > (00:01)
> > lar              ttypp    216.106.179.129  Thu Nov 16 17:11 - 17:21
> > (00:09)
> > lar              ttypk    216.106.179.129  Thu Nov 16 14:20 - 14:21
> > (00:01)
> > lar              ttypn    216.106.179.129  Thu Nov 16 13:23 - 13:37
> > (00:13)
> > irongeek         ttypi    216.106.179.129  Wed Nov 15 17:27 - 17:32
> > (00:04)
> > sabre            ttyp5    216.106.179.129  Wed Nov 15 13:59 - 14:03
> > (00:04)
> > lar              ttyp5    216.106.179.129  Wed Nov 15 13:57 - 13:59
> > (00:01)
> > sabre            ttyp5    216.106.179.129  Wed Nov 15 13:28 - 13:57
> > (00:28)
> > sabre            ttypc    216.106.179.129  Wed Nov 15 12:10 - 12:10
> > (00:00)
> >
> > lar              ttypd    71.57.146.22     Fri Nov 17 07:27 - 07:43
> > (00:16)
> > irongeek         ttyp2    71.57.146.22     Thu Nov 16 07:49 - 07:56
> > (00:07)
> > sabre            ttypg    71.57.146.22     Sat Nov 11 15:56 - 16:09
> > (00:12)
> >
> > The stuff before the space is already sorted.
>
> You got me confused. Do you mean the list is already sorted by 'lar',
> 'sabre', and 'irongeek'?
> Where? I mean, I can clearly see that each of those values appears several
> times and totally intermixed with the others. To me that is not sorted at
> all.
> If you mean something else by "before the space is already sorted", then
> please explain.

If you look at the 4th column (which has dates line Fri Nov 17), the
dates start to go backwards. That is how the list is ordered. If there
are multiple entries for the same date (like Thu Nov 16), the data is
then ordered by time (in the 5th column).

> > After the space break,
> > the data is sorted again.
>
> Are you talking about the substrings that start with 'ttyp', either with =
or
> without the rest of each line. Again, I do not recognize any sorting order
> in those values, neither overall nor within each group of values for 'lar=
',
> 'sabre', and 'irongeek' in case you were talking about primary and second=
ary
> sort keys.
>
> > I want
> > all the data in this file to be sorted in descending order.
>
> Do you mean all the data (like in each column individually; I cannot think
> of an application where this would make sense) or all the lines?
>
> > I tried
> > looking at bash sort, but I couldn't
> > find anything.
>
> Well, I may not be up to speed but last I've never heard of any algorithm
> called bash sort, either.

My wording was sloppy on that line.

> What's wrong with just using the buildin Perl sort()?
> All you have to do is to define your custom comparison function and then =
you
> can sort by whatever you like. There is even an FAQ "How do I sort an arr=
ay
> by (anything)?". I'd like to help, but from your description and data sam=
ple
> it is impossible to figure out what your desired end result should look
> like.

I forgot what else. I need to go to the store and get some alcohol.
However, I refuse to get nylons for my girlfiend.

> BTW: some people will probably suggest a Schwartzian Transformation. That=
 is
> an interesting optimization technique if and when the data set becomes la=
rge
> and performance and issue. For a first simple solution "Make it work" the=
re
> is no need for it.

I was thinking if I had a really large honkin data set, I would use
something like a k-way sort.



------------------------------

Date: Sat, 18 Nov 2006 15:16:25 GMT
From: "Mumia W. (reading news)" <paduille.4060.mumia.w@earthlink.net>
Subject: Re: At a loss how to sort this file
Message-Id: <dtF7h.418$ql2.122@newsread3.news.pas.earthlink.net>

On 11/18/2006 05:03 AM, grocery_stocker wrote:
> If I have a file in the following format:
> 
> lar              ttyp2    216.106.179.129  Fri Nov 17 17:12 - 17:14
> (00:01)
> lar              ttypa    216.106.179.129  Fri Nov 17 15:53 - 15:55
> (00:01)
> lar              ttypp    216.106.179.129  Thu Nov 16 17:11 - 17:21
> (00:09)
> lar              ttypk    216.106.179.129  Thu Nov 16 14:20 - 14:21
> (00:01)
> lar              ttypn    216.106.179.129  Thu Nov 16 13:23 - 13:37
> (00:13)
> irongeek         ttypi    216.106.179.129  Wed Nov 15 17:27 - 17:32
> (00:04)
> sabre            ttyp5    216.106.179.129  Wed Nov 15 13:59 - 14:03
> (00:04)
> lar              ttyp5    216.106.179.129  Wed Nov 15 13:57 - 13:59
> (00:01)
> sabre            ttyp5    216.106.179.129  Wed Nov 15 13:28 - 13:57
> (00:28)
> sabre            ttypc    216.106.179.129  Wed Nov 15 12:10 - 12:10
> (00:00)
> 
> lar              ttypd    71.57.146.22     Fri Nov 17 07:27 - 07:43
> (00:16)
> irongeek         ttyp2    71.57.146.22     Thu Nov 16 07:49 - 07:56
> (00:07)
> sabre            ttypg    71.57.146.22     Sat Nov 11 15:56 - 16:09
> (00:12)
> 
> The stuff before the space is already sorted. After the space break,
> the data is sorted again. I want
> all the data in this file to be sorted in descending order. I tried
> looking at bash sort, but I couldn't
> find anything.
> 
> I thought maybe I could also do this:
> -read in each line
> -have the date as the first value, and the reference to the list(?) as
> the second value.
> -Make the first value the hash key and the reference to the list the
> value of the hash key
> -sort the hash keys and write back
> 
> However, for some reason, this seems a bit overcomplicated. 
> 
> Ideas?
> 

That would be overly complicated. Just create a sorting (comparison) 
function that extracts the dates from each string, converts them and 
compares them.

Get the Date::Parse module from CPAN (or ActiveState or Debian) and use 
that to easily convert those date strings to time values.

Show some code, and we can help you better.


-- 
paduille.4060.mumia.w@earthlink.net



------------------------------

Date: Sat, 18 Nov 2006 14:37:59 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: best practice to avoiding excessive memory usage??
Message-Id: <slrnelu35n.u4p.hjp-usenet2@yoyo.hjp.at>

On 2006-11-17 14:38, Chris <ithinkiam@gmail.com> wrote:
> I've come across the perl issue of inefficient use of memory when
> dealing with large datasets.

You aren't the first one. There are modules for dealing with large
numeric arrays for a reason.

> What are people's opinions on the best way
> to work around this problem.

So far I haven't needed them but searching CPAN for appropriate modules
would certainly be among the first things I'd try. I have also
bookmarked something called "PDL - The Perl Data Language" just in case
I'll ever need it.

> My input file has this layout:
> # Input 1_8:
> 0.28496 0.10340 0.33403 0.86176 0.06723 0.15316 0.46009 0.09535 ...
> # Output 1_8:
> 0 0 1
> # Input 1_9:
> 0.38225 0.98944 0.03805 0.04031 0.05417 0.19623 0.07656 0.07944 ...
> # Output 1_9:
> 0 0 1
> # Input 1_10:
> 0.11106 0.02792 0.69635 0.37519 0.01326 0.95435 0.15976 0.01406 ...
> # Output 1_10:
> 0 0 1
>
> With ~73000 pairs of input and outputs. The file is ~260Mb is size.
> However when reading the file into an array with the following code
> snippet results in 1.2Gb of memory usage:

This is not surprising. Perl scalars take quite a bit of space. Assuming
no overhead from memory management (which is hardly realistic), a floating
point number takes 20 bytes, and a string takes 25 + n bytes (where n is
the length of the string).

>       $array[$i] = [ split ];

You are storing your values as strings here. Since all your values seem
to be 7 characters long you could reduce the size of each element from
32 to 20 bytes, saving almost 40 %, by converting each value into a
number:

        $array[$i] = [ map { $_ + 0 } split ];

In reality, the space saving may be less or more, depending on the
memory management of your perl implementation, the exact shape of your
data and other conditions.

Note that this solution is brittle: If you access the elements of your
arrays in a string context, perl may convert them back into strings, and
you will need even more space than you needed in the first place.

	hp


-- 
   _  | Peter J. Holzer    | > Wieso sollte man etwas erfinden was nicht
|_|_) | Sysadmin WSR       | > ist?
| |   | hjp@hjp.at         | Was sonst wäre der Sinn des Erfindens?
__/   | http://www.hjp.at/ |	-- P. Einstein u. V. Gringmuth in desd


------------------------------

Date: 18 Nov 2006 11:16:01 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: Do I *have* to use 'OOP' to use modules?
Message-Id: <slrneltqqd.bt.abigail@alexandra.abigail.be>

Merrilee Larson (merrile@telus.net) wrote on MMMMDCCCXXVI September
MCMXCIII in <URL:news:KHl7h.6944$_Z2.6942@edtnps89>:
{}  Hi...
{}  
{}  I'm not sure why, but I can't stand OOP. That's it!
{}  
{}  Sooo....is it possible to be fully productive using Perl5 in a non-OOP
{}  fashion? Can I still use modules, etc? Or would I be severely restricting
{}  myself?

That depends on how much you want to avoid OO. If all you want to avoid
writing OO, you can be fully productive in Perl5. In fact, the native
OO support you get from Perl is so limited, one wonder why people even
bother writing OO Perl. However, if you want to avoid modules that have
an OO API, then you are limiting yourself. The set of modules available
from CPAN to pick from will be smaller than if you don't set up this
limitation for yourself.

{}  I'm *not* a student or professional programmer wannabe -- just an avid
{}  middle-aged geek looking to write/speak some programming language well. My
{}  goal is to fool around developing websites.
{}  
{}  To date I'm not a bad hand with bash/ksh; html/css/js. I've tried PHP -- too
{}  verbose for me. C -- too terse. C++/java -- no thanks. I'm also looking at
{}  Lisp/Scheme et al. TIA...


If you find C too terse, why even bother with Perl? Perl is a *lot* terser
than C. 




Abigail
-- 
perl -wle'print"Êõóô áîïôèåò Ðåòì Èáãëåò"^"\x80"x24'


------------------------------

Date: Sat, 18 Nov 2006 12:35:40 GMT
From: "Arved Sandstrom" <asandstrom@accesswave.ca>
Subject: Re: Do I *have* to use 'OOP' to use modules?
Message-Id: <w6D7h.11870$gy2.6058@edtnps90>

"Abigail" <abigail@abigail.be> wrote in message 
news:slrneltqqd.bt.abigail@alexandra.abigail.be...
> Merrilee Larson (merrile@telus.net) wrote on MMMMDCCCXXVI September
> MCMXCIII in <URL:news:KHl7h.6944$_Z2.6942@edtnps89>:
> {}  Hi...
> {}
> {}  I'm not sure why, but I can't stand OOP. That's it!
> {}
> {}  Sooo....is it possible to be fully productive using Perl5 in a non-OOP
> {}  fashion? Can I still use modules, etc? Or would I be severely 
> restricting
> {}  myself?
>
> That depends on how much you want to avoid OO. If all you want to avoid
> writing OO, you can be fully productive in Perl5. In fact, the native
> OO support you get from Perl is so limited, one wonder why people even
> bother writing OO Perl.
[ SNIP ]

I haven't observed the average programmer using Java, say, doing anything 
more challenging with OOP than you can do in Perl. I'd guess that 90% of 
programmers do with their object-oriented language of choice pretty much 
what they'd do in Perl5:

Object object = new Object(stuff)
object->method(stuff) OR object.method(stuff)
object1 == object2
Object.classMethod(other_stuff)

That kind of thing. Seeing as how what Perl5 does OOP-wise accurately 
describes almost everything that eight or nine programmers out of ten do 
with OOP in whatever language they like, I'd be interested to hear why you 
think OO Perl is not worth bothering with.

AHS 




------------------------------

Date: Sat, 18 Nov 2006 14:14:16 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Do I *have* to use 'OOP' to use modules?
Message-Id: <k45ul21etus5qaklngc8fa3tng149aq4qh@4ax.com>

Merrilee Larson wrote:

>Sooo....is it possible to be fully productive using Perl5 in a non-OOP
>fashion?

Yes.

>Can I still use modules, etc?

Yes. modules can contain any kind of Perl source code.

So of the modules you find on CPAN are written with OO in mind, and if
there are no alternatives, those will be the ones to use. But you can
still safely mix OO with procedural code.

>Or would I be severely restricting
>myself?

Some people think OO is handy for easier managing large projects. If you
don't feel that way, then you don't have to use it.

-- 
	Bart.


------------------------------

Date: Sat, 18 Nov 2006 10:47:25 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Do I *have* to use 'OOP' to use modules?
Message-Id: <m24pswwycy.fsf@Sherm-Pendleys-Computer.local>

Abigail <abigail@abigail.be> writes:

> Merrilee Larson (merrile@telus.net) wrote on MMMMDCCCXXVI September
> MCMXCIII in <URL:news:KHl7h.6944$_Z2.6942@edtnps89>:
> {}  Hi...
> {}  
> {}  I'm not sure why, but I can't stand OOP. That's it!
> {}  
> {}  Sooo....is it possible to be fully productive using Perl5 in a non-OOP
> {}  fashion? Can I still use modules, etc? Or would I be severely restricting
> {}  myself?
>
> That depends on how much you want to avoid OO. If all you want to avoid
> writing OO, you can be fully productive in Perl5. In fact, the native
> OO support you get from Perl is so limited, one wonder why people even
> bother writing OO Perl.

Speaking strictly for myself, it's because the "limitations" I hear about are
primarily a lack of formal OOP strictures. Perl will let you access package
(aka class) variables from any class, there's no private object variables or
methods, you're not required to use accessors, $self is passed explicitly,
and so forth.

I'm talking about the core language here, btw - I'm well aware that there
are CPAN modules that attempt to address these so-called "limitations", with
varying degrees of success.

In short, OOP "purists" - the ones I've heard, that is - tend to bemoan the
fact that Perl doesn't *force* best OOP practice, but merely allows it. But
force is not the Perl Way - as it's often been said, you should stay out of
my living room because you weren't invited, not because I'm holding a gun.

sherm--

-- 
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net


------------------------------

Date: Sat, 18 Nov 2006 16:17:33 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: FAQ 6.6 How can I make "\w" match national character sets?
Message-Id: <ejnboi.1hk.1@news.isolution.nl>

PerlFAQ Server schreef:

> 6.6: How can I make "\w" match national character sets?
> 
> 
>     Put "use locale;" in your script. The \w character class is taken
>     from the current locale.
> 
>     See perllocale for details.

See also:

  http://www.xs4all.nl/~rvtol/perl/unicount.pl 

which matches 91801 codepoints with \w. 
(without "use locale;")

-- 
Affijn, Ruud

"Gewoon is een tijger."


------------------------------

Date: Sat, 18 Nov 2006 04:11:03 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: HoA bug? Size limit?
Message-Id: <slrneltn1n.ssg.tadmc@tadmc30.august.net>

Uri Guttman <uri@stemsystems.com> wrote:
>>>>>> "JWK" == John W Krahn <someone@example.com> writes:
>
>  JWK> Uri Guttman wrote:
>  >>>>>>> "P" == PB0711  <hpbenton@scripps.edu> writes:
>  >> 
>  >> gack! i hate seeing useless and bug prone c style for loops.
>  >> 
>  >> foreach my $i ( 0 .. $#AoA ){
>  >> foreach my $j ( 0 .. $#AoA ){
>  >> foreach my $k ( 0 .. $#AoA ){
>  >> 
>  >> and k usually follows n. 
>
>  JWK> I though that k usually follows j?
>
> not in MY alphabet!
         ^^
         ^^

_your_ alphabet contains upper case? Horrors!


>  P> my $h=($AoA[$i][6]+$AoA[$j][6])+$AoA[$n][6];
>  JWK>               ^           ^            ^
>
> why are you pointing out the integers there?


Because ...


>  JWK> The correct order should be:
>
>  JWK>  			my( $c, $o, $n, $h, $s ) = map {


 ... you had them in the wrong order.



-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Sat, 18 Nov 2006 14:04:33 +0100
From: Mirco Wahab <wahab@chemie.uni-halle.de>
Subject: Re: HoA bug? Size limit?
Message-Id: <ejn0m1$nb2$1@mlucom4.urz.uni-halle.de>

Thus spoke PB0711 (on 2006-11-18 02:20):

> I have just finished a script with 3 for loops, at the end of which it
> generates an HoA. I've printed out that it goes throught all expected
> 8000 loops but there are only a unique 1599 keys. However, if I print
> the keys out before I put them into the HoA I can see that it does all
> combinations that I expect. Is this a bug or a size limit on the number
> of keys for an HoA??

I see you are into Protein stuff, this is nice, Hey, I did
these things in the past (when I didn't know Perl).

> #making dipeptides - a nasty way V2 will do a sub
> for (my $i=0; $i < $#AoA+1; $i++){
> 	for (my $j=0; $j < $#AoA+1; $j++){
> 		for (my $n=0; $n < $#AoA+1; $n++) {

Others have pointed out several problems already.

Because I guess you are new into Perl and new into
Protein/amino acids stuff, I'd like to make a recommendation
regarding general program structure and amino acid handling
here.

Basically, I straightened up your code a bit and tried
to make it readable and extensible (what I think what it
would be then ;-).

Part one - Data:

--- 8< ---

use strict;
use warnings;

use constant TLC   => 1;  # use some readable indices
use constant MASS  => 3;  # into the data array below
use constant C_IDX => 4;  # TLC -> 'three letter code'
use constant O_IDX => 5;
use constant N_IDX => 6;
use constant H_IDX => 7;
use constant S_IDX => 8;
                          # define some element related data
my @elems;
   $elems[C_IDX] = 'C', $elems[O_IDX] = 'O', $elems[N_IDX] = 'N',
   $elems[H_IDX] = 'H', $elems[S_IDX] = 'S';

# this is the whole story (always use single character codes!):
my @acids = qw'A C D E F G H I K L M N P Q R S T V W Y';

# now compile your data into the appropriate form,
# use a hash to organize the amino acid data records ...
my %table = (
	A => [qw'A Ala Alanine        71.08  3  2  1  7  0'],
	C => [qw'C Cys Cysteine      103.14  3  2  1  7  1'],
	D => [qw'D Asp Aspartate     115.09  4  4  1  7  0'],
	E => [qw'E Glu Glutamate     129.11  5  4  1  9  0'],
	F => [qw'F Phe Phenylalanine 147.18  9  2  1 11  0'],
	G => [qw'G Gly Glycine        57.05  2  2  1  5  0'],
	H => [qw'H His Histidine     137.14  6  2  3  9  0'],
	I => [qw'I Ile Isoleucine    113.16  6  2  1 13  0'],
	K => [qw'K Lys Lysine        128.17  6  2  2 14  0'],
	L => [qw'L Leu Leucine       113.16  6  2  1 13  0'],
	M => [qw'L Met Methionine    131.20  5  2  1 11  1'],
	N => [qw'N Asn Asparagine    114.10  4  3  2  8  0'],
	P => [qw'P Pro Proline        97.12  5  2  1  9  0'],
	Q => [qw'Q Gln Glutamine     128.13  5  3  2 10  0'],
	R => [qw'R Arg Arginine      156.19  6  2  4 14  0'],
	S => [qw'S Ser Serine         87.08  3  3  1  7  0'],
	T => [qw'T Thr Threonine     101.10  4  3  1  9  0'],
	V => [qw'V Val Valine         99.13  5  2  1 11  0'],
	W => [qw'W Trp Trytophan     186.21 11  2  2 12  0'],
	Y => [qw'Y Tyr Tryosine      163.17  9  3  1 11  0']  );

--- 8< ---

From the definitions and declarations above,
data handling gets relatively easy now:

Part two - workflow:

--- 8< ---

my @triplets;              # generate all possible amino acid triplets
for my $i (0..@acids-1) {
   for my $j (0..@acids-1) {
      for my $k (0..@acids-1) {
         push @triplets, [ $acids[$i], $acids[$j], $acids[$k] ];
      }
   }
}

--- 8< ---

After you generated the triplets, you can
do some operations on them:

--- 8< ---

for my $triplet (@triplets) {   # handle tripeptides in any way you want
  # 1) calculate masses
  my $mass = 0;
  $mass += $table{$_}->[MASS] for @$triplet;

  # 2) generate elementary composition
  my %compos;
  for my $acid (@$triplet) {
     $compos{$_} += $table{$acid}->[$_] for C_IDX..S_IDX;
  }

  # 3) make some kind of a 'formula' of the composition
  my $frm = join'', map "$elems[$_]$compos{$_}", grep $compos{$_}, C_IDX..S_IDX;

  # 4) print the results for each triplet
  print +(map "$_", @$triplet), "\t",             # print one letter codes
        +(map "$table{$_}->[TLC] ", @$triplet),   # print three letter codes
        "\t$frm\tM=$mass\n";
}

__END__

--- 8< ---

This is how I'd have tried to play with
amino acid sequences in the olden times,
maybe it's somehow instructive - if not,
whatever ... ;-)

Iteration over data contained in the records (C_IDX..S_IDX)
implies that this specific order is reitained, otherwise
you have to explicitly state the indices in question.


Regards

Mirco


------------------------------

Date: Sat, 18 Nov 2006 14:03:15 +0100
From: Mirco Wahab <wahab@chemie.uni-halle.de>
Subject: Re: HoA bug? Size limit?
Message-Id: <ejn998$pli$1@mlucom4.urz.uni-halle.de>

Thus spoke PB0711 (on 2006-11-18 02:20):

> I have just finished a script with 3 for loops, at the end of which it
> generates an HoA. I've printed out that it goes throught all expected
> 8000 loops but there are only a unique 1599 keys. However, if I print
> the keys out before I put them into the HoA I can see that it does all
> combinations that I expect. Is this a bug or a size limit on the number
> of keys for an HoA??

I see you are into Protein stuff, this is nice, Hey, I did
these things in the past (when I didn't know Perl).

> #making dipeptides - a nasty way V2 will do a sub
> for (my $i=0; $i < $#AoA+1; $i++){
> 	for (my $j=0; $j < $#AoA+1; $j++){
> 		for (my $n=0; $n < $#AoA+1; $n++) {

Others have pointed out several problems already.

Because I guess you are new into Perl and new into
Protein/amino acids stuff, I'd like to make a recommendation
regarding general program structure and amino acid handling
here.

Basically, I straightened up your code a bit and tried
to make it readable and extensible (what I think what it
would be then ;-).

Part one - Data:
--- 8< ---

use strict;
use warnings;

use constant TLC  => 1;  # use some readable indices
use constant MASS => 3;  # into the data array below
use constant C_ID => 4;  # TLC -> 'three letter code'
use constant O_ID => 5;
use constant N_ID => 6;
use constant H_ID => 7;
use constant S_ID => 8;
                         # define some element related data
my @elems;
   $elems[C_ID] = 'C', $elems[O_ID] = 'O', $elems[N_ID] = 'N',
   $elems[H_ID] = 'H', $elems[S_ID] = 'S';

# this is the whole story (always use single character codes!):
my @acids = qw'A C D E F G H I K L M N P Q R S T V W Y';

# now compile your data into the appropriate form,
# use a hash to organize the amino acid data records ...
my %table = (
	A => [qw'A Ala Alanine        71.08  3  2  1  7  0'],
	C => [qw'C Cys Cysteine      103.14  3  2  1  7  1'],
	D => [qw'D Asp Aspartate     115.09  4  4  1  7  0'],
	E => [qw'E Glu Glutamate     129.11  5  4  1  9  0'],
	F => [qw'F Phe Phenylalanine 147.18  9  2  1 11  0'],
	G => [qw'G Gly Glycine        57.05  2  2  1  5  0'],
	H => [qw'H His Histidine     137.14  6  2  3  9  0'],
	I => [qw'I Ile Isoleucine    113.16  6  2  1 13  0'],
	K => [qw'K Lys Lysine        128.17  6  2  2 14  0'],
	L => [qw'L Leu Leucine       113.16  6  2  1 13  0'],
	M => [qw'L Met Methionine    131.20  5  2  1 11  1'],
	N => [qw'N Asn Asparagine    114.10  4  3  2  8  0'],
	P => [qw'P Pro Proline        97.12  5  2  1  9  0'],
	Q => [qw'Q Gln Glutamine     128.13  5  3  2 10  0'],
	R => [qw'R Arg Arginine      156.19  6  2  4 14  0'],
	S => [qw'S Ser Serine         87.08  3  3  1  7  0'],
	T => [qw'T Thr Threonine     101.10  4  3  1  9  0'],
	V => [qw'V Val Valine         99.13  5  2  1 11  0'],
	W => [qw'W Trp Trytophan     186.21 11  2  2 12  0'],
	Y => [qw'Y Tyr Tryosine      163.17  9  3  1 11  0']  );

--- 8< ---

From the definitions and declarations above,
data handling gets relatively easy now:

Part two - workflow:

--- 8< ---

my @triplets;
for my $i (@acids) {
   for my $j (@acids) {
      for my $k (@acids) {
         push @triplets, [ $i, $j, $k ];
      }
   }
}

--- 8< ---

After you generated the triplets, you can
do some operations on them:

--- 8< ---

for my $triplet (@triplets) {			# handle tripeptides in any way you want
  # 1) calculate masses
  my $mass = 0;
  $mass += $table{$_}[MASS] for @$triplet;

  # 2) generate elementary composition
  my %compos;
  for my $acid (@$triplet) {
     $compos{$_} += $table{$acid}[$_] for C_ID .. S_ID;
  }

  # 3) make some kind of a 'formula'
  my $formula = join '',
         map $elems[$_] . $compos{$_} x ($compos{$_} > 1),
            grep $compos{$_}, C_ID .. S_ID;

  # 4) print the results
  print +(map "$_", @$triplet), "\t",           # print one letter codes
         (map "$table{$_}[TLC] ", @$triplet),   # print three letter codes
         "\t$formula\tM=$mass\n";
}
__END__

--- 8< ---

This is how I'd have tried to play with
amino acid sequences in the olden times,
maybe it's somehow instructive - if not,
whatever ... ;-)

Iteration over data contained in the records (C_ID .. S_ID)
implies that this specific order is reitained, otherwise
you have to explicitly state the indices in question.


Regards

Mirco


------------------------------

Date: Sat, 18 Nov 2006 04:15:42 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: is there a bash script to perl converter?
Message-Id: <slrneltnae.ssg.tadmc@tadmc30.august.net>

Tintin <tintin@invalid.invalid> wrote:
>
><ToddAndMargo@gbis.com> wrote in message 
> news:1163825339.671311.207020@m73g2000cwd.googlegroups.com...
>> Hi All,
>>
>>   Is there a such thing as a bash script to perl converter?
>
> Yes.  It's called a programmer. 


 ...because shell scripts don't really do much themselves, most of their
"heavy lifting" is done by calling other programs.

So to make a shell script converter, you would need all of those
other programs in Perl as well.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Sat, 18 Nov 2006 23:11:16 +0800
From: Bo Yang <struggle@mail.nankai.edu.cn>
Subject: Re: Module help!
Message-Id: <ejn9tg$u18$1@news.cn99.com>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

Bo Yang :
> I have search in cpan and google, but failed.
> I want to use PKI in perl, is there any module
> for this function?
> 
> Thanks in advance!


No body reply to my post, help please!
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFXyKU7tZp58UCwyMRApFPAJ4uuEh1+ZJ7Dh7pNnELjmm03MwxHwCeKFcY
2oV1RFP82bYPszQ4r2dnJuM=
=I5ta
-----END PGP SIGNATURE-----


------------------------------

Date: Sat, 18 Nov 2006 11:00:58 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Module help!
Message-Id: <m2velcvj5x.fsf@Sherm-Pendleys-Computer.local>

Bo Yang <struggle@mail.nankai.edu.cn> writes:

> Bo Yang :
>> I have search in cpan and google, but failed.
>> I want to use PKI in perl, is there any module
>> for this function?
>> 
>> Thanks in advance!
>
>
> No body reply to my post, help please!

It's too vague to give a very useful answer.

In general, go to <http://search.cpan.org> and search for the specific
encryption tech you're using - GPG, PGP, SSL, etc.

sherm--

-- 
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net


------------------------------

Date: 18 Nov 2006 06:35:11 -0800
From: "Robert Hicks" <sigzero@gmail.com>
Subject: Re: OT: O'Reilly 'Perl CD Bookshelf' - gone for good?
Message-Id: <1163860511.625440.76560@h48g2000cwc.googlegroups.com>


Randal L. Schwartz wrote:
> >>>>> "Robert" == Robert Hicks <sigzero@gmail.com> writes:
>
> Robert> Yes...but we were hoping for "future" editions.
>
> yeah, and thanks to pirates, you won't be getting them.
>

Possibly true but probably not quantifiably true (without producing
numbers to support your position). I lean more towards they want Safari
to replace the bookshelfs.

Robert



------------------------------

Date: Sat, 18 Nov 2006 10:52:43 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: OT: O'Reilly 'Perl CD Bookshelf' - gone for good?
Message-Id: <m2zmaovjjo.fsf@Sherm-Pendleys-Computer.local>

"Robert Hicks" <sigzero@gmail.com> writes:

> Randal L. Schwartz wrote:
>> >>>>> "Robert" == Robert Hicks <sigzero@gmail.com> writes:
>>
>> Robert> Yes...but we were hoping for "future" editions.
>>
>> yeah, and thanks to pirates, you won't be getting them.
>>
>
> Possibly true but probably not quantifiably true (without producing
> numbers to support your position). I lean more towards they want Safari
> to replace the bookshelfs.

Agreed. Why would I buy a set of CDs that have searchable copies of a half-
dozen O'Reilly books and are updated once every 12-18 months, when I could
instead buy access to the whole catalog and constant updates?

I'm not saying that piracy wasn't a factor, Randal, just that I doubt it was
the *only* reason for the decision.

sherm--

-- 
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net


------------------------------

Date: Sat, 18 Nov 2006 04:18:39 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: p-value calculation
Message-Id: <slrneltnfv.ssg.tadmc@tadmc30.august.net>

rahulthathoo <rahul.thathoo@gmail.com> wrote:

> I did this in perl.


You did that in Perl.


> How
> do i do that in PERL. 


How do you do that in Perl.



Case matters.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Sat, 18 Nov 2006 12:35:39 GMT
From: zentara <zentara@highstream.net>
Subject: Re: threads crash on XP (in Tk script)
Message-Id: <o7vtl21i55uklaidbf4teso50udelkkira@4ax.com>

On Fri, 17 Nov 2006 22:48:26 +0000, Brian Raven
<brian.raven@osbsl.co.uk> wrote:

>zentara <zentara@highstream.net> writes:
>
>> But you are probably right, that one of the use statements is causing
>> it. I would try removing them all, and adding them back, 1 by 1, until
>> you find which one causes it.


>Which suggests that Tk is not the only thread unsafe module being
>loaded. In which case, a single threaded approach may be less
>problematic.
>
>HTH

Yeah, Tk is often blasted as not being thread safe, but many other
modules are in the same boat. 


-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html


------------------------------

Date: Sat, 18 Nov 2006 11:58:02 +0100
From: Richard <fake@fake.com>
Subject: Warning Re: is there a bash script to perl converter?
Message-Id: <ejmp49$5fv$1@online.de>

Tad McClellan schrieb:
> Tintin <tintin@invalid.invalid> wrote:
>> <ToddAndMargo@gbis.com> wrote in message 
>> news:1163825339.671311.207020@m73g2000cwd.googlegroups.com...
>>> Hi All,
>>>
>>>   Is there a such thing as a bash script to perl converter?
>> Yes.  It's called a programmer. 
> 
> 
> ...because shell scripts don't really do much themselves, most of their
> "heavy lifting" is done by calling other programs.
> 
> So to make a shell script converter, you would need all of those
> other programs in Perl as well.
> 
> 
Tad, he just grabbed your email to spam you, didn't you notice, that
this question was autogenerated, just like one before with the
decompiler question.

This is very edffective technique, you send general question to dozens
of mailingslists and you get lots of replies and bingo lots of valid
emailadresses.


------------------------------

Date: Sat, 18 Nov 2006 07:46:19 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Warning Re: is there a bash script to perl converter?
Message-Id: <slrnelu3lb.vh.tadmc@tadmc30.august.net>

Richard <fake@fake.com> wrote:
> Tad McClellan schrieb:
>> Tintin <tintin@invalid.invalid> wrote:
>>> <ToddAndMargo@gbis.com> wrote in message 
>>> news:1163825339.671311.207020@m73g2000cwd.googlegroups.com...
>>>> Hi All,
>>>>
>>>>   Is there a such thing as a bash script to perl converter?
>>> Yes.  It's called a programmer. 
>> 
>> 
>> ...because shell scripts don't really do much themselves, most of their
>> "heavy lifting" is done by calling other programs.
>> 
>> So to make a shell script converter, you would need all of those
>> other programs in Perl as well.
>> 
>> 
> Tad, he just grabbed your email to spam you, didn't you notice, that
> this question was autogenerated, 


What did you observe that led you to conclude that it was autogenerated?


> just like one before with the
> decompiler question.


Message-ID please, else I dunno what you're referring to.


> This is very edffective technique, you send general question to dozens
> of mailingslists and you get lots of replies and bingo lots of valid
> emailadresses.


Spammers don't generally follow the threads that they start. This
poster has replied to many threads here in the past.

I think you have a mistaken identity thing going here...



[ In fact, _you_ look more like a spammer than the OP does, by
  virtue of masquerading as someone else's domain.
  (unless you really do have something to do with fake plants)
  It is an abuse to use a domain that you don't have rights to,
  please don't abuse folks like that.
]

-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

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 9979
***************************************


home help back first fref pref prev next nref lref last post