[18432] in Perl-Users-Digest
Perl-Users Digest, Issue: 600 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 2 18:06:23 2001
Date: Mon, 2 Apr 2001 15:05:18 -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: <986249117-v10-i600@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 2 Apr 2001 Volume: 10 Number: 600
Today's topics:
Re: - Looking for this type of TALKBACK user feedback s <elsid@nospam.com>
Re: add lines from logfile <bmb@ginger.libs.uga.edu>
Re: ANNOUNCEMENT: SuperPython-0.91 released <webmaster@webdragon.unmunge.net>
Re: Disguising Perl scripts <uri@sysarch.com>
Re: Disguising Perl scripts <elijah@workspot.net>
Re: Disguising Perl scripts <andrew@mvt.ie>
Re: fetch back STDERR outputs <rick.delaney@home.com>
Re: Formatting HTML using Perl <moiraine@qwest.net>
Getting Character Codes peter.reid2000@ntlworld.com
hashes keys case insensitive <fabascal@MailAndNews.com>
HTML conversion <Tim.Lauterborn@gmx.de>
Re: HTML conversion <juex@deja.com>
Re: HTML conversion <Tim.Lauterborn@gmx.de>
Re: list all subdirectories..... (Tad McClellan)
Re: Newbies welcome <darrenls21@yahoo.com>
Re: Perl newbie <webmaster@webdragon.unmunge.net>
Re: Perl public key encryption (those who know me have no need of my name)
Re: Please Flame my Benchmark: open vs. cat <uri@sysarch.com>
Re: QUE: Serial port interrupt handling from perl <mtsouk@freemail.gr>
Re: Read and write a hash of arrays ? <goldbb2@earthlink.net>
Re: rounding up or down with Perl (Gwyn Judd)
Script or Application <tom@hotversion.com>
Re: Script or Application <uri@sysarch.com>
Re: SMTP Connections nobull@mail.com
Re: sort array contents from file question <whynot117@hotmail.com>
Re: Sorts on first six columns only (John Joseph Trammell)
ssi #exec problem <anim8grl@onebox.com>
Re: Use Asp over Perl or Php? <moiraine@qwest.net>
Re: what are the new languages? (Tom Briles)
Re: what are the new languages? (Tad McClellan)
Re: what are the new languages? (Tad McClellan)
Why do "Programming Perl" Books Do This? a rgexp questi <Francis.Derive@wanadoo.fr>
Re: Why do "Programming Perl" Books Do This? a rgexp qu <Francis.Derive@wanadoo.fr>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 01 Apr 2001 11:35:22 +0200
From: Sid Ismail <elsid@nospam.com>
Subject: Re: - Looking for this type of TALKBACK user feedback script... --
Message-Id: <fhtdct4u8qe1g0ftmb687bd05ehakic8on@4ax.com>
On Sun, 1 Apr 2001 03:47:37 -0400, "Jon" <vemba72@hotmail.com> wrote:
: Are you guys done being condescending cumstains now, or is there more to
: this routine I haven't yet seen?
:
: For what it's worth, emailing the site owners is something I did way before
: I posted the question the FIRST time.
Why didn't you tell us that?!
: Not that it matters, of course.
Of course it matters - what did they say?
===================
Sid Ismail Computers are not intelligent.
http://fly.to/elsid They only think they are.
===================
------------------------------
Date: Sun, 1 Apr 2001 11:39:45 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: add lines from logfile
Message-Id: <Pine.A41.4.21.0104011107050.14738-100000@ginger.libs.uga.edu>
On 30 Mar 2001, Joe Schaefer wrote:
> Brad Baxter <bmb@ginger.libs.uga.edu> writes:
> > I guess I win a Guinness:
> >
> > perl -ane '$_{"@F[0,1]"}+=$F[2]}$"=$/;print"@{[%_]}";{' logfile
> >
> > My, that was tasty. :-)
> >
>
> % perl -pale '$_{"@F[0,1]"}+=$F[2]}for(%_){' logfile
I'm humbled. As many times as I've seen the '}{' chicanery, I failed to
realize that while "perl -pe '' logfile" prints each line of logfile,
"perl -pe '}{' logfile" does not.
Cheers,
Brad
------------------------------
Date: 2 Apr 2001 12:25:13 GMT
From: "Scott R. Godin" <webmaster@webdragon.unmunge.net>
Subject: Re: ANNOUNCEMENT: SuperPython-0.91 released
Message-Id: <9a9r39$mjv$0@216.155.32.18>
In article <20010401224025.12978.qmail@plover.com>,
Mark-Jason Dominus <mjd@plover.com> wrote:
Hey Mark, :)
| no SuperPython;
| # regular Perl code resumes
| # (not recommended; regular Perl is too hard to understand and
| maintain)
*muttergrumblesmurf* *mopping keyboard* :D
(heck, I'm even a MacPerl user, and still thought this was rather
funny.. ;)
--
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw";
# ( damn spammers. *shakes fist* take a hint. =:P )
------------------------------
Date: Mon, 02 Apr 2001 21:40:57 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Disguising Perl scripts
Message-Id: <x7hf07ugih.fsf@home.sysarch.com>
>>>>> "EtB" == Eli the Bearded <elijah@workspot.net> writes:
EtB> In comp.lang.perl.misc, Rafael Garcia-Suarez <rgarciasuarez@free.fr> wrote:
>> Tad McClellan wrote in comp.lang.perl.misc:
>> > Mark Warnes <mark.warnes@limecs.com> wrote:
>> > >The problem I have is that I need to disguise the Perl source
>> Besides the FAQ, there's a funny obfuscation module on CPAN (uploaded
>> yesterday, 1st april):
>>
>> http://search.cpan.org/search?dist=Buffy-1.00
EtB> There is also the option of translating to SuperPython and using
EtB> Mark Jason Dominus' SuperPython module to run it.
EtB> http://perl.plover.com/SuperPython/SuperPython-0.91.tar.gz
EtB> SuperPython does not come with a translator, though.
the best method is to use Bleach.pm, written by perl's resident (and
paid for) mad scientist, damian conway. when you bleach a script, ALL (i
mean ALL!!!) printable characters disappear. yet the script STILL runs
as it did before. so you can distribute bleached scripts (and the
required Bleach.pm module) and no one can read your code since it is not
printable!
this is no april fools joke. it does work. but if you have to, you can
get back the original text. for further info, you have to study the
Bleach.pm code (not that long and not too hard to figure out).
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: 2 Apr 2001 21:09:28 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: Disguising Perl scripts
Message-Id: <eli$0104021703@qz.little-neck.ny.us>
In comp.lang.perl.misc, Rafael Garcia-Suarez <rgarciasuarez@free.fr> wrote:
> Tad McClellan wrote in comp.lang.perl.misc:
> > Mark Warnes <mark.warnes@limecs.com> wrote:
> > >The problem I have is that I need to disguise the Perl source
> Besides the FAQ, there's a funny obfuscation module on CPAN (uploaded
> yesterday, 1st april):
>
> http://search.cpan.org/search?dist=Buffy-1.00
There is also the option of translating to SuperPython and using
Mark Jason Dominus' SuperPython module to run it.
http://perl.plover.com/SuperPython/SuperPython-0.91.tar.gz
SuperPython does not come with a translator, though.
Elijah
------
buffy reminds me of the old moo-moo-encode binary to ascii encoder
------------------------------
Date: Mon, 2 Apr 2001 13:49:50 +0100
From: "Andrew" <andrew@mvt.ie>
Subject: Re: Disguising Perl scripts
Message-Id: <9a9shq$e31$1@kermit.esat.net>
I just came across this earlier today, and it might do what you want.
http://www.cyberwiz.com/cgi-sys/cgiwrap/cyberwiz/hotperl.cgi
Andrew
"Mark Warnes" <mark.warnes@limecs.com> wrote in message
news:3ac83bc1.2692565@news.firstnet.co.uk...
> Hello all.
>
> I have a Perl script that I have developed that is going to be sold
> commercially. The problem I have is that I need to disguise the Perl
> source so that it cannot be copied. Is this possible?
>
> Some more info... the script is designed to run under mod_perl with
> the Apache web server. It uses DBI for database connections to various
> backend databases.
>
> I need to make sure that the script will still benefit from running
> under mod_perl. Is there some way of part-compiling to a halfway
> situation (a la Java)? Or can the main functionality of the script be
> hidden with a module that gets called by a basic script (which
> wouldn't need disguising)?
>
> Any ideas?
>
> Mark
------------------------------
Date: Sun, 01 Apr 2001 17:41:50 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: fetch back STDERR outputs
Message-Id: <3AC75D8F.E0BEFB84@home.com>
Benjamin Goldberg wrote:
>
> Of course, since in this particular case, we probably want TOUCH to be
> closed immediatly after the block, it would likely be better to say:
> {
> local *TOUCH;
> open TOUCH,"+>zero-length.file" or die $!;
> }
It has already been pointed out by Mark Jason Dominus that in this case
the right thing to do to avoid the warning would be to put in
close TOUCH;
> Or perhaps:
> new FileHandle "+>zero-length.file" or die $!;
I assume this has been mentioned also:
{ open my $touch,"+>zero-length.file" or die $! }
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Mon, 02 Apr 2001 14:08:34 -0700
From: Me <moiraine@qwest.net>
Subject: Re: Formatting HTML using Perl
Message-Id: <3AC8EA52.B1AB537C@qwest.net>
Uh.....
Did I miss something? I'm new to the group and new to more advanced CGI using
Perl...
I know it's not the most efficient templating..but it seems the easiest to
learn.
Maybe I'm wrong, but nobody else said anthing. I didn't want to leave the poor
guy hanging.
Chris Hartles wrote:
> hahahaha
>
> Uncle Zien
> Is that Right?
>
<snip>
--
Geekette
"Try Not. Do or do not. There is no try."
-If you don't know who said this,
I don't want to talk to you. ;-)
"Nothing is impossible, no matter how improbable."
-Anonymous
------------------------------
Date: 31 Mar 2001 12:47:42 GMT
From: peter.reid2000@ntlworld.com
Subject: Getting Character Codes
Message-Id: <9a4jle$b47$1@news.netmar.com>
I'm pretty new to Perl but have had plenty of experience in VisualBasic.
I'm writing a server-side login script which gets passwords from a file. This
file won't be properly encrypted as it's not exactly that important if it
gets 'hacked', but I'd like to do a little bit of character scrambling. In
VB, I'd do:
Dim strCharCode as Integer
Dim strLetter as String
strCharCode=Asc("a")
strCharCode=strCharCode+24
strLetter=Chr(strCharCode)
Is there anyway in Perl to get the character code (Asc) of a letter and also
return a letter from the character code (Chr)??? I would be most grateful if
anyone could e-mail me with an answer.
Faithfully,
Peter Reid
Leicestershire, England
----- Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web -----
http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
NewsOne.Net prohibits users from posting spam. If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net
------------------------------
Date: Mon, 2 Apr 2001 08:47:37 -0400
From: Federico Abascal <fabascal@MailAndNews.com>
Subject: hashes keys case insensitive
Message-Id: <3AD2B225@MailAndNews.com>
Hello,
I think I have read this in some place but I cannot remember where. Is
there
a way of having a hash with case insensitive keys?
Thanks in advance,
Federico
------------------------------------------------------------
Get your FREE web-based e-mail and newsgroup access at:
http://MailAndNews.com
Create a new mailbox, or access your existing IMAP4 or
POP3 mailbox from anywhere with just a web browser.
------------------------------------------------------------
------------------------------
Date: Mon, 2 Apr 2001 14:04:01 +0200
From: "Tim Lauterborn" <Tim.Lauterborn@gmx.de>
Subject: HTML conversion
Message-Id: <9a9pst$4sj$1@nets3.rz.RWTH-Aachen.DE>
Hello,
I use dynamic HTML-sites including several text fragments. When I deliver
the site to the user's browser I wanna make sure that there are no letters
left which are not allowed in a HTML document (e.g. the german ä becomes
ä and so on). For the conversion I use the module HTML::Entities. The
problem is that also Java-Script code is modified so that it can't be used
any more.
Does anyone know a solution?
Greetings,
Tim
------------------------------
Date: Mon, 2 Apr 2001 14:42:34 -0700
From: "Jürgen Exner" <juex@deja.com>
Subject: Re: HTML conversion
Message-Id: <3ac8f24a$1@news.microsoft.com>
"Tim Lauterborn" <Tim.Lauterborn@gmx.de> wrote in message
news:9a9pst$4sj$1@nets3.rz.RWTH-Aachen.DE...
> I use dynamic HTML-sites including several text fragments. When I deliver
> the site to the user's browser I wanna make sure that there are no letters
> left which are not allowed in a HTML document (e.g. the german ä becomes
> ä and so on). For the conversion I use the module HTML::Entities. The
> problem is that also Java-Script code is modified so that it can't be used
> any more.
What gave you the idea that e.g. German umlauts are not allowed in HTML?
Of course they are. I can even write HTML pages with Chinese, Japanese (all
three character sets), Vietnamese or Hindi characters, not to mention Arabic
and Hebrew.
You just have to use the proper encoding (META charset="....").
And be very wary about include files. Sometimes they inherit the encoding
settings from the parent page, sometimes they don't. And sometimes the
scripting language may not support your favorite encoding.
For details you should ask in a web authoring NG.
jue
------------------------------
Date: Mon, 2 Apr 2001 23:05:00 +0200
From: "Tim Lauterborn" <Tim.Lauterborn@gmx.de>
Subject: Re: HTML conversion
Message-Id: <9aapj5$rvq$1@nets3.rz.RWTH-Aachen.DE>
Hi,
the problem is, that I indeed use ä in messages from a Java-Script (e.g.
alert-function). I can transform the letters replacing them step by step but
what regular expression excludes HTML-comments?
Example: $input="ä<!--ä is a nice letter-->"
should become "ä<!--ä is a nice letter-->"
Greetings,
Tim
------------------------------
Date: Sun, 1 Apr 2001 10:26:34 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: list all subdirectories.....
Message-Id: <slrn9ceekq.6h8.tadmc@tadmc26.august.net>
BUCK NAKED1 <dennis100@webtv.net> wrote:
>> > I want to be able to list all subdirectories
^^^^^^^^^^^^^^
>> > from where a script is running eg: /data/members/groups/
I wonder who it was that said that?
>> This question has been asked several
>> times in the last week. You want the > File::Find module.
I wonder who it was that said that?
It is customary to include an attribution when you quote someone,
please do that in the future.
>Sorry, but I'd mark that answer as "non-responsive".
No followups would be "non-responsive".
A response _is_ responsive :-)
Perhaps you meant "non-helpful"?
>Why not tell the
>guy
The OP could not be troubled to spend a couple of minutes searching
a news archive, and others are expected to spend their time instead?
And when they do spend their own time, some jerk complains about
it (and throws in answers to random questions)?
You are really beginning to wear on me Dennis...
>how to glob?
Because he has shown that he already knows how to use readdir() to
get the filenames.
Sorry, but I'd mark that answer as "an answer to some question other
than the one that was asked".
His question was how to list subdirectories (you even quoted it above).
>@files = glob "DIR*";
How does that list all of the subdirectories?
I agree that programs are much easier to write if you are allowed
to ignore the specification, but the result may prove unsatisfying...
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 2 Apr 2001 13:04:51 +0100
From: "Darren" <darrenls21@yahoo.com>
Subject: Re: Newbies welcome
Message-Id: <OZZx6.12350$u93.1557464@news6-win.server.ntlworld.com>
nice one Tracy.
Tracy Coyle <tccoyle@chorus.net> wrote in message
news:9a8ufp$68v$1@news.chorus.net...
> Darren wrote in message
> <2xVp6.4139$t1.320148@news6-win.server.ntlworld.com>...
> >This is to all newbies on this and any other newsgroup.
> >
> >Do not ever be afraid of asking a question...
>
> From a relative newbie, thanks. I learned programming in Fortran 26
years
> ago. Did small programming here and there, knew COBOL and a few others.
I
> decided in December to get back my skills. Started with C++
IDE....exactly
> who was the brain that thought giving programmers access to manipulating
> memory directly was a good idea??!! Moved to Java....someone recommended
> PHP. I have Apache, MySQL and PHP installed and am building my site.
> Registration, login, authentication - not using cookies or the globals are
> built and functioning.
>
> (Moving it to a remote site scares the bejebees outa me!) That said, I
> have used the documentation (annotated PHP is great) and been able to
learn
> to build as I go along. Whenever I get stuck, I check here....someone is
> asking 'the' question or one close enough to it that responses usually
give
> me enough to go on.
>
> This newsgroup, like the others crossposted are excellant places to learn
> and teach. To those that answer, thank you. To those that post, there
are
> others just like you out here, to those that lurk and learn, no question
is
> stupid to the 50 others with the same question...
>
> Tracy
>
>
------------------------------
Date: 31 Mar 2001 12:54:22 GMT
From: "Scott R. Godin" <webmaster@webdragon.unmunge.net>
Subject: Re: Perl newbie
Message-Id: <9a4k1u$re5$0@216.155.32.172>
In article <3ac3d0d8.0@news-svr.tp.ac.sg>, "yc" <leongyc@tp.edu.sg>
wrote:
| Hi Rafael,
|
| Thanks for your enlightenment.
|
| How can I learn obsfuscative powers of Perl ?
scan the group for Abigail's[1] signature lines =8)
--
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw";
# ( damn spammers. *shakes fist* take a hint. =:P )
------------------------------
Date: Sun, 01 Apr 2001 10:55:31 -0000
From: not-a-real-address@usa.net (those who know me have no need of my name)
Subject: Re: Perl public key encryption
Message-Id: <tce293qhvaq724@news.supernews.com>
[dang, quite a bit of backlog. sorry for the delay.]
<kv8w6.53062$g63.7378381@nnrp3.clara.net> divulged:
>"those who know me have no need of my name" <not-a-real-address@usa.net>
>wrote in message news:tbvv0drv05dg5d@news.supernews.com...
>> [note: this is really a security rather than a cryptography issue]
>Noted. Sorry if this went to the wrong group.
no worries. i mainly mention it because while many sci.crypt readers
are also interested in this kind of security lots of people interested
in this kind of security aren't the types to read what is essentially a
math group.
[re: program tampering]
>True. Any suggestions as to how this could be prevented?
no, sorry. it's a complex problem. something that might be done,
provided the isp allows it, would be for a cron job to calculate a
series of signatures for the scripts and forward them to you via e-mail.
you check those signatures, and if there is any change you have a fit.
or you might have a cron job on your system that periodically fetches
the scripts from the web server and compares them to local copies.
those things are so full of secondary holes they are almost not worth
doing, but there isn't much else that can be done.
if you don't trust the isp's security (and i'm not saying you should or
shouldn't) why would you use them to host your e-commerce? yet, if you
do trust them you might find yourself in hot water, and them with a
liability clause that will (try to) keep them safe.
>Sadly, as I mentioned in my first post, my first choice ISP has stated that
>they will not allow the use of PGP on their webservers 'as it requires root
>access'. This sounds like a load of nonsense to me, so I'm looking at other
>ISP's who do provide PGP.
i missed that. sorry.
they are fools, it (pgp) requires no such thing. gpg is best installed
suid-root, so that it can perform page locking, but it is not necessary.
(in fact you might be able to compile gpg for their platform and upload
it somewhere within your private space to make it available to your
script. note: it should not be available to web clients directly,
i.e., not in /cgi-bin/.)
yes, you might use crypt::rsa to encrypt the files directly, but there
are some caveats which are a pain to deal with. (pgp/gpg do all that
work for you, using rsa only to encrypt a random session key to be used
by a block cipher for the encryption of the data.)
given that you have an isp that is this lame it might be better to ask
what encryption modules are already installed, since they might not want
to install anything else, and might prevent you from installing your
own.
>> umm. use https: to transfer the files.
>
>Yes, but isn't this rather tedious if there are lots of files to download?
nope.
zip everything, send the zip. that's only one possibility.
everything stored should be encrypted as a matter of course. since the
source data was delivered via ssl, or should have been, that leg is
good. before you store the data you should encrypt it to a public key
whose private key is not present on the isp's system.
--
okay, have a sig then
------------------------------
Date: Mon, 02 Apr 2001 21:36:22 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Please Flame my Benchmark: open vs. cat
Message-Id: <x7k853ugq5.fsf@home.sysarch.com>
>>>>> "r" == revjack <revjack@revjack.net> writes:
r> In order to demonstrate to my cow orkers that open() is a
r> wiser choice than `cat`, I ran this benchmark:
r> #!/usr/bin/perl
r> use Benchmark;
r> $count = 10_000;
r> timethese($count, {
r> 'cat' => '$foo = `cat temp.txt`',
r> 'open' => 'local $/; open IN, "<temp.txt"; $foo = <IN>; close IN',
r> });
looks like a fair benchmark to me. they both do the exact same function
of slurping a file into a scalar. what more would you need to add to it?
and what are your results? i know which one will win and i want to see
the look on the orker's face when he sees the results.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Sat, 31 Mar 2001 02:02:36 +0300
From: "Mihalis Tsoukalos" <mtsouk@freemail.gr>
Subject: Re: QUE: Serial port interrupt handling from perl
Message-Id: <9a33f0$ogs$1@ulysses.noc.ntua.gr>
Bbirthisel <bbirthisel@aol.com> wrote in message
news:20010324203647.25034.00000635@ng-cp1.aol.com...
> Hi Mihilis,
>
> >I want an example of how to handle serial port interrupts from perl.
> >If possible I want to have to possible options:
> >- Reading interrupt
> >- Writing interrupt
>
> You almost certainly don't want to implement the raw serial driver in
> Perl. Even I don't - Win32::CommPort talks to the driver at a rather low
API
> level, but no where near interrupt services. But most Operating
> Systems already have a serial driver to do that (even the $MS ones
starting
> with W9x - earlier attempts are disparaged even within $MS).
>
> What you probably want is read_characters_if_available, and
> write_characters_and_let_me_know_when_done. For those, the functions in
> xxx::SerialPort are a possible starting point. Versions for Windows
(Win32::)
> and POSIX-compliant (Device::). There is also
> serial code for the Mac - but not compatible with the ones above.
>
> -bill
> Making computers work in Manufacturing for over 25 years (inquiries
welcome)
First of all, thanks for answering.
Yes Bill,
you are right. What I want is what you 've said:
"What you probably want is read_characters_if_available, and
write_characters_and_let_me_know_when_done."
Especially the read_characters_if_available.
An interrupt behaviour is exactly what I wanted, but I have to find another
way to achive my purpose.
What I want to make sure is that I won't loose any characters from the
serial port. This is critical to me because characters for reading may come
pretty fast. So if I spend too mych time for writing then I might looose
data that I have to read.
If you have any code examples it would be very nice of you.
I am using the ::SerialPort perl module (SuSE Linux 7.0).
many thanks in advance,
Mihalis.
------------------------------
Date: Mon, 02 Apr 2001 21:37:29 GMT
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Read and write a hash of arrays ?
Message-Id: <3AC8F1D9.C52E9EF@earthlink.net>
u665313720@spawnkill.ip-mobilphone.net wrote:
>
> Hi,
> I would like to read data records as given in the script
> in the __DATA__ section below into a hash using the second
> field as a key and keeping the multiple entries belonging
> to one key in a array which is to be sorted in descending
> order according to the value in the third field. Using the
> script below I apparently read in the values in the hash, but
> when trying to write them out, I just get the keys printed, but no
> values from the array ???
You code is kinda hard to read. As another poster said, fixed length
fields would be better parsed using unpack, rather than a regex.
Also, your code does stuff with the symbol table using soft references,
which is bad, and then tries to store an array in a hash table, which
is impossible. You can store a *reference* to an array in a hash table,
but not the array itself.
#!/usr/bin/perl -w
use strict
my $keyword;
my %enzymes;
while(<DATA>) {
if( /^(\w+)::$/ ) {
$keyword = $1;
next;
}
my @fields = unpack "A16 A10 A10 A10 A6 A23 A49";
my ($clone, $best_hit_id, $e_value, $percent_ident,
$aln_length, $species, $desc) = @fields;
# origninal version tryied to do something like:
# my $c_id = join " ",@fields[2,0,1,3..6];
# my $c_a = "c_a_$best_hit_id";
# push @$c_a, $c_id;
# $enzymes{$best_hit_id} = @$c_a;
# mucking with the symbol table is bad, and you can't
# store arrays in a hash like that anyway.
push @$enzymes{$best_hit_id}, \@fields;
}
foreach (sort keys %enzymes) {
my $b_h_id = $_;
print "$b_h_id:\n";
my @fieldses = @$enzymes{$b_h_id};
# each item in fieldes is a reference to an array, so $a and $b
# are references to arrays (meaning you need an -> to get elements)
# The third item in the array is what you want to sort on.
# Arrays start indexing at 0, so this is $a->[2] and $b->[2]
# Using <=> means compare numerically, which should treat
# $e_value as a float, rather than as a string.
# Having b then a means sort descending, rather than ascending.
# The stuff after the or means to sort on $clone iff the two $e_values
# were equal. Presumably, every line has a unique $clone.
foreach (sort { $b->[2] <=> $a->[2] or $a->[0] cmp $b->[0] } @fieldses) {
my @fields = @$_;
# Each item in fields is one field, in the same order as unpack
# produced waay up above. I exclude item 1, cause that's $b_h_id,
# and is the same for all items in the group. Also, they're all
# already padded with spaces, so I join with "", not " ".
print join("", @fields[0,2..6]), "\n";
}
print "\n";
}
> __DATA__
> ACYLASE::
> HVSMEb0011A11f ACY1_PIG 1.10e-06 38,32% 107 Sus scrofa AMINOACYLASE-1 (EC 3.5.1.14) (N-ACYL-L-AMINO-ACID
> HVSMEb0011A21f ACY1_PIG 9.40e-35 51,15% 217 Sus scrofa AMINOACYLASE-1 (EC 3.5.1.14) (N-ACYL-L-AMINO-ACID
> HVSMEb0014B21f FABD_BACSU 2.00e-12 47,14% 140 Bacillus subtilis MALONYL COA-ACYL CARRIER PROTEIN TRANSACYLASE (EC
> HVSMEc0009D01f ACY1_HUMAN 2.60e-24 52,07% 169 Homo sapiens AMINOACYLASE-1 (EC 3.5.1.14) (N-ACYL-L-AMINO-ACID
> HVSMEf0010D05f ACY1_HUMAN 1.70e-14 52,38% 84 Homo sapiens AMINOACYLASE-1 (EC 3.5.1.14) (N-ACYL-L-AMINO-ACID
> HVSMEf0023M23f FABD_BACSU 4.00e-13 38,38% 99 Bacillus subtilis MALONYL COA-ACYL CARRIER PROTEIN TRANSACYLASE (EC
> HVSMEg0013L23f ACY1_PIG 1.20e-23 51.46% 171 Sus scrofa AMINOACYLASE-1 (EC 3.5.1.14) (N-ACYL-L-AMINO-
> HVSMEk0024P21f FABD_BACSU 6.60e-29 39,50% 200 Bacillus subtilis MALONYL COA-ACYL CARRIER PROTEIN TRANSACYLASE (EC
<..............><........><........><........><....><.....................>
0000000000111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999000000000011111111112222
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123
This is how I calculated how big each field should be. If it's wrong, sue me :)
However you figure it, make sure the lengths of all 7 fields add up to 124 bytes.
Well, assuming you use unpack.
--
Sometimes the journey *is* its own reward--but not when you're trying to get to the bathroom in time.
------------------------------
Date: Mon, 02 Apr 2001 12:41:43 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: rounding up or down with Perl
Message-Id: <slrn9cgss6.2h5.tjla@thislove.dyndns.org>
I was shocked! How could Randal L. Schwartz <merlyn@stonehenge.com>
say such a terrible thing:
>Heh. Always doing it the hard way.
>
>use constant PI => atan2(0,-1);
Heh. Always doing it the hard way.
use constant PI => 3;
print "What's Maths?"
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
PRICE
n. Value, plus a reasonable sum for the wear and tear of conscience
in demanding it.
------------------------------
Date: Mon, 02 Apr 2001 21:30:10 GMT
From: "Tom" <tom@hotversion.com>
Subject: Script or Application
Message-Id: <Cb6y6.19396$BU4.32515@news1.blktn1.nsw.optushome.com.au>
I have a question... should a perl program be called a script or an
application ?
Tom
------------------------------
Date: Mon, 02 Apr 2001 21:41:16 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Script or Application
Message-Id: <x7elvbughv.fsf@home.sysarch.com>
>>>>> "T" == Tom <tom@hotversion.com> writes:
T> I have a question... should a perl program be called a script or an
T> application ?
yes.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: 01 Apr 2001 15:16:45 +0100
From: nobull@mail.com
Subject: Re: SMTP Connections
Message-Id: <u9vgoog0xe.fsf@wcl-l.bham.ac.uk>
Ilmari Karonen <iltzu@sci.invalid> writes:
> In article <9a6vcq$g8c$1@news.netmar.com>, peter.reid2000@ntlworld.com wrote:
> >Guys, I need some help here. Can any1 give me a COMPLETE walkthrough on how
> >to send email from Perl.
>
> 1. Open a web browser.
>
> 2. Go to "http://search.cpan.org/".
>
> 3. Click on the link "Mail and Usenet News".
>
> 4. Click on the link "MailTools".
>
> 5. Click on the link "Mail::Send".
>
> 6. Read.
A good answer in all respects but one. The OP inplied that this SMTP
server required authentication but did not go into details.
So, Peter, could you please clarify the authentication situation.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Sun, 01 Apr 2001 11:01:16 -0500
From: CoralBanded <whynot117@hotmail.com>
Subject: Re: sort array contents from file question
Message-Id: <3AC750CC.84F2C927@hotmail.com>
Yes the file is being read, the foreach loop will process the contents of
the file. I am just trying to process the results in a sorted order and I
don't the actual file to change I just want to sort the results I get back
from the file before I process them. The routine works but when I put in
the sort command:
foreach $line (sort @lines)
or
@sortedlist = sort @lines;
nothing gets processed so I assume its an issue with how I should assign
the results of the sort command so that the foreach can then process it?
Jay Tilton wrote:
> On Sat, 31 Mar 2001 00:28:17 -0600, CoralBanded
> <whynot117@hotmail.com> wrote:
>
> >------------------------------------------ now I want the foreach loop
> >to wok on a sorted @lines list but hte following methods do not work,
> >the foreach line fails :
>
> Fails in what way? Dies with an error? Sorts poorly? Power supply
> catches fire?
>
> >open(FILE,"$filename");
> > foreach $line (@sortedlist) {
> > ...
> >}
>
> Should work.
>
> > foreach $line (sort @lines) {
> > ...
> >}
>
> Ditto.
>
> >open(FILE,"$filename");
>
> You're not checking the return value. Are you certain the file is
> being read?
------------------------------
Date: Sun, 01 Apr 2001 16:11:18 GMT
From: trammell@bayazid.hypersloth.invalid (John Joseph Trammell)
Subject: Re: Sorts on first six columns only
Message-Id: <slrn9ceio8.655.trammell@bayazid.hypersloth.net>
On Sun, 01 Apr 2001 10:53:49 -0500, Lance Hoffmeyer wrote:
> Can someone explain how one might sort an ASCII file with 3000
> columns on only the first 6 columns which have a unique ID number?
% cat filename | sort -n
------------------------------
Date: Mon, 02 Apr 2001 21:18:58 GMT
From: "Verio News" <anim8grl@onebox.com>
Subject: ssi #exec problem
Message-Id: <616y6.3719$Up.148398@sea-read.news.verio.net>
my stuff:
-------------------
activeperl 5.6
iis5
2k advanced server
-------------------
just installed activeperl 5.6 and appears to work. all activeperl example
scripts work fine.
trying to do an ssi exec <!-- #exec cgi=path/file.cgi --> and cannot get it
to work. no errors are thrown. just is not doing anything.
please give me ideas!
thank you in advance...
kellie
------------------------------
Date: Mon, 02 Apr 2001 14:20:08 -0700
From: Me <moiraine@qwest.net>
Subject: Re: Use Asp over Perl or Php?
Message-Id: <3AC8ED08.7FB05FAB@qwest.net>
Bertilo Wennergren wrote:
> Kati:
<snip>
> > Any objective, or non-objective opinions, would be
> > appreciated, to help us make a decision on this topic.
>
> ASP can by quite easy to work with. Some people don't like the
> VBScript syntax, but I had no problems going from Perl and JavaScript
> to VBScript. If you really can't stand to work with VBScript or
> Javascript in your ASP code, you could also use Perl, or rather
> something called PerlScript in ASP. So you could go both ways.
I haven't specifically used VBScript, but I have used VB. It is similar to
the other languages.
The problem I have with ASP, though, isn't in programming, it's in using.
I, due to circumstances not in my control, have a 56k modem. Most home
computers have 56k modems, and a lot of those have AOL and the like.
My connection is fairly high (in 56k-land), getting connection speeds of
50k.
A lot the other people in 56k-land, get 20k-30k on average. Of course,
this
isn't actual speed...blahblahblah.
I have problems with ASP sites. They are too slow. If they're slow for
me,
think about other people.
<snip>
> Bertilo Wennergren
<snip>
--
Geekette
"Try Not. Do or do not. There is no try."
-If you don't know who said this,
I don't want to talk to you. ;-)
"Nothing is impossible, no matter how improbable."
-Anonymous
------------------------------
Date: Mon, 02 Apr 2001 21:35:55 GMT
From: sariq@texas.net (Tom Briles)
Subject: Re: what are the new languages?
Message-Id: <3ac8f092.274480602@news.texas.net>
On Sat, 31 Mar 2001 03:44:35 GMT, "Todd Smith" <todd@designsouth.net>
wrote:
>So what's the next new programming language
>gonna be?
Parrot, of course.
- Tom
------------------------------
Date: Sun, 1 Apr 2001 10:29:45 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: what are the new languages?
Message-Id: <slrn9ceeqp.6h8.tadmc@tadmc26.august.net>
BUCK NAKED1 <dennis100@webtv.net> wrote:
>.. and besides...
>
>if we took to learning other languages, we'd miss Abigail and Tad
>McClellan. : /
Learning an additional language does not imply that you stop
using the languages that you already have.
Having many tools allows you to select the "best" one for
whatever the present circumstance is.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 1 Apr 2001 10:36:27 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: what are the new languages?
Message-Id: <slrn9cef7b.6h8.tadmc@tadmc26.august.net>
BUCK NAKED1 <dennis100@webtv.net> wrote:
>VB is an old language, and perl is newer
Bzzzzt!
VB came out in 1991 (http://www.johnsmiley.com/visualbasic/vbhistory.htm).
Perl came out in 1987 (perldoc perlhist).
_You_ may have discovered them in the opposite order. Most have.
Microsoft has advertising budget, so that's to be expected.
"Newer" does not imply "better" either.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 1 Apr 2001 10:43:28 +0200
From: "Francis Derive" <Francis.Derive@wanadoo.fr>
Subject: Why do "Programming Perl" Books Do This? a rgexp question.
Message-Id: <B6ECB6D9-44780@193.248.253.44>
Bonjour,
Page 266 in the french translated O'Reilly book, I read this to generate a
hash of hash from a file :
>while ( <> ) {
> next unless s/^(.*?):\s*//;
> ....
>}
This is to be applied to the line format :
>flindstones: principal=fred copain=barney femme=wilma animal=dino
I understand we loop while avoiding such garbage which do not conform to
the pattern. Which pattern ? Hmmm :
It tells the selected line has to start with zero or more ("*") of any
character ( ".") before the colon ":" .
My first question is : how could it be "zero" occurence of any character,
before the colon ? Why not *at least* one character : /.+
Secondly what is the substitution for ?
Thanks for any help.
Francis
------------------------------
Date: 1 Apr 2001 18:26:25 +0200
From: "Francis Derive" <Francis.Derive@wanadoo.fr>
To: "Charles K. Clarkson" <c_clarkson@hotmail.com>
Subject: Re: Why do "Programming Perl" Books Do This? a rgexp question.
Message-Id: <B6ED235C-992CA@193.248.254.66>
On Sun, Apr 1, 2001 3:08 PM, Charles K. Clarkson
<mailto:c_clarkson@hotmail.com> wrote:
> It was written without error handling (most likely) to improve
>readability. Yes (.+?) would make more sense, but would also
>process a line that started with ' :' (which later tries to assign
>' ' to the first key of a HOH). It might have been written as:
>
>next unless s/^(\w*?):\s*//;
> which is more likely to skip most inappropriate keys.
I like that. Because, later on, I met the case - which took me some time
to solve - adding an extra key and complaining for a value when I found
several spaces after the last written line. I could only solve it with an
ugly s/^\s+// preceeding the next unless.
>: Secondly what is the substitution for ?
>
> the substitution chops off the beginning of the line changing:
>
>flindstones: principal=fred copain=barney femme=wilma animal=dino
>
> to:
>principal=fred copain=barney femme=wilma animal=dino
>
> allowing the rest of the while block to process the line.
Perl is clever.
It remains me the lisp ( Le_Lisp from INRIA) function
(nextl list_symbol1 list_symbol2)
which leaves the first element in list_symbol1 and the rest in
list_symbol2.
With a little effort, I could have soon two loves.
Deux amours.
>HTH,
>Charles K. Clarkson
>
>Under capitalism man exploits man;
> under socialism the reverse is true. - Polish Proverb
>
Thanks a lot,
Francis.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 600
**************************************