[21944] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4166 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 23 18:05:50 2002

Date: Sat, 23 Nov 2002 15:05:12 -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, 23 Nov 2002     Volume: 10 Number: 4166

Today's topics:
    Re: @INC, use, $LD_LIBRARY_PATH, & modules (Tad McClellan)
    Re: @INC, use, $LD_LIBRARY_PATH, & modules <family2@aracnet.com>
    Re: a question on regular expression <john@imrie37.fsnet.co.uk>
        announcing plonks (was Re: search script and meta tags) (Tad McClellan)
        Binary vs ascii ??? <n_joeller@sharaziilyar.com>
    Re: Binary vs ascii ??? <bart.lateur@pandora.be>
    Re: Binary vs ascii ??? (Tad McClellan)
        Can pragma "use locale" affect sort function used in mo <d.adamkiewicz@i7.com.pl>
    Re: Can pragma "use locale" affect sort function used i (Tad McClellan)
        complex foreach loop with deep hashes (sorted hash slic <sheukels=cuthere=@yahoo.co.uk>
    Re: complex foreach loop with deep hashes (sorted hash  <sheukels=cuthere=@yahoo.co.uk>
    Re: complex foreach loop with deep hashes (sorted hash  (Tad McClellan)
    Re: Cross-Platform method to get process information <rgarciasuarez@free.fr>
        DBM compatibilty/porting FreeBSD to linux <pault@dspfx.com>
    Re: disambiguating print (was Re: Basic syntax question (Tad McClellan)
    Re: HTTP::Daemon not working in threads? (Joe)
        I love you Perl!!!!!!! <elf@ee.ryerson.ca>
    Re: Not working solution <d.adamkiewicz@i7.com.pl>
        perl compile problem on linux heitkamp@ameritech.net
    Re: Perl one-liners in Win32 <bik.mido@tiscalinet.it>
    Re: shtml and Perl <spam@all.costs.must.die>
    Re: Socket client/server example not working on Windows <jr@adslate.com>
    Re: string qustion? (Tad McClellan)
        Unpacking MHTML files on upload (Barry King)
    Re: was: Re: string qustion? (Jay Tilton)
    Re: Way to print caller() info from first to last inste <bart.lateur@pandora.be>
    Re: Why not PERL? <felix@pz4.org>
    Re: Windows XP / Perl Question <bobx@linuxmail.org>
        Working solution <d.adamkiewicz@i7.com.pl>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 23 Nov 2002 09:00:07 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: @INC, use, $LD_LIBRARY_PATH, & modules
Message-Id: <slrnatv5vn.2dg.tadmc@magna.augustmail.com>

Abernathey Family <family2@aracnet.com> wrote:

> How can I use modules that are not where "my" perl is installed?

> Please, no "perldoc -f lookyhere"-type answers 


   perldoc -q module

      "How do I keep my own module/library directory?"


I don't take direction very well.


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


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

Date: Sat, 23 Nov 2002 09:43:31 -0600
From: Abernathey Family <family2@aracnet.com>
Subject: Re: @INC, use, $LD_LIBRARY_PATH, & modules
Message-Id: <3DDFA223.73355CDE@aracnet.com>

Dave Cross wrote:
> 
> On Fri, 22 Nov 2002 21:07:35 +0000, Abernathey Family wrote:
> 
> > How can I use modules that are not where "my" perl is installed?
> 
> With "use lib"
> 
> > I need modules & libs that are scattered.
> 
> Why? Why not install them all in the same place?
> 
--snip--

I'm in a multi-national company with access via afs to groups with their
own builds/installations of Perl.
By the way, some of modules have c-libraries with them. "use lib
"pathname" works for getting the path into the @INC array but I still
get an error from Linux Dyna-loader that it can't find them. The error
goes away when I set my LD_LIBRARY_PATH variable to point at the
c-libraries. But this variable has to be set "outside" of my Perl
script. Modifying my script's local copy of this variable
$ENV{LD_LIBRARY_PATH} doesn't work.

Sorry for not being clear about the main issue of loading the c-libs
used by the Perl modules. I can't seem to find info on this anywhere.


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

Date: Sat, 23 Nov 2002 17:26:29 +0000
From: John Imrie <john@imrie37.fsnet.co.uk>
Subject: Re: a question on regular expression
Message-Id: <3DDFBA45.6060903@imrie37.fsnet.co.uk>



Kurt Gong wrote:

> hello, i wanna find inverted repeats in dna sequence. for example:
> there are 4 different nucleotides in dna sequence: A, T, C ,G
> A pairs with T, and C pairs with G.
> the inverted repeats is something like :
> XXXXATCGXXXXCGATXXX, X represents one random nucleotide of A, T, C, G.
> this kind of pattern can form stem-loop structure which is very important
> for various molecular interaction.
> my question is how to construct a regular expression to find out such a
> pattern from a long dna sequence which may contains many of this inverted
> repeats.
> thanx in advance.
> -



open DNA,"<dna_file" or die $!;
$dna=<DNA>;
while ($dna=~/(ATCG.?CGAT|CGAT.?ATCG)/g) {
   print "Inverted repeat found at nucleotide " . pos($dna) . " has a 
length of " . length($1) . " nucleotides\n$1\n";
}



Make sure you have a lot of memory as this will slurp in your entire dna 
sequence into core.

Then again if you are dealing with DNA sequencing you will know about 
this :-)

John Imrie




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

Date: Sat, 23 Nov 2002 09:23:00 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: announcing plonks (was Re: search script and meta tags)
Message-Id: <slrnatv7ak.2go.tadmc@magna.augustmail.com>

Brian McCauley <nobull@mail.com> wrote:
> tadmc@augustmail.com (Tad McClellan) writes:
>> Kevin McGurk <kgmmusic@comcast.net> wrote:
>> 
>> > PLEASE REPLY BY EMAIL AS I RARELY HAVE ACCESS TO THESE GROUPS.
>> 
>>    *plonk*
> 
> I hope you remembered to e-mail that plonk.


heh.

I do not announce plonks for the benefit of the plonkee.

If I am plonking them, then I have no interest in doing
anything for them.

The announcement is for everyone else, some of them may
wish to avoid a similar disposition for their own articles.


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


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

Date: Sat, 23 Nov 2002 20:40:31 GMT
From: Noerd <n_joeller@sharaziilyar.com>
Subject: Binary vs ascii ???
Message-Id: <3DDFE79F.947C7EDC@sharaziilyar.com>

My home computer's FTP client gives me the choice of uploading files in
binary, ascii, etc. My webserver uses Linux w/ Apache.

I've chosen to do ALL uploads and downloads in binary only. This
includes both Perl scripts, and textfiles.

In recently reviewing many Perl manuals, the recommendation is NOT to
upload in binary, but to use ascii.

My question is as follows: could there be a possible performance hit by
uploading my Perl scripts, textfiles etc., in binary? Or is it simply a
situation of either it WILL work, or it WON'T work.

What potential problems are there in uploading in binary? I'm not trying
to be a contrarian; I just remember hearing a long time ago from a
genius programmer that with Unix/Linux binary is always better.

TIA
-Noerd







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

Date: Sat, 23 Nov 2002 21:16:21 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Binary vs ascii ???
Message-Id: <6urvtu4bg38fcbpduihus01088g7erglpe@4ax.com>

Noerd wrote:

>My home computer's FTP client gives me the choice of uploading files in
>binary, ascii, etc. My webserver uses Linux w/ Apache.
>
>I've chosen to do ALL uploads and downloads in binary only. This
>includes both Perl scripts, and textfiles.
>
>In recently reviewing many Perl manuals, the recommendation is NOT to
>upload in binary, but to use ascii.
>
>My question is as follows: could there be a possible performance hit by
>uploading my Perl scripts, textfiles etc., in binary? Or is it simply a
>situation of either it WILL work, or it WON'T work.

You're lucky your perl scripts run at all. You must have a fairly recent
perl there.

Performance hit? None to speak of. However, the data read from your text
files will contain extra "\r" files you'll have to delete yourself, if
you don't want them in your data.

-- 
	Bart.


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

Date: Sat, 23 Nov 2002 15:27:13 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Binary vs ascii ???
Message-Id: <slrnatvslh.3o7.tadmc@magna.augustmail.com>

Noerd <n_joeller@sharaziilyar.com> wrote:

> My home computer's FTP client gives me the choice of uploading files in
> binary, ascii, etc. My webserver uses Linux w/ Apache.


We have half of the info needed.

What OS is at the other end of the FTP (ie. on your home computer).

If you are transferring unix-to-unix, ASCII and binary FTP mode
will behave identically, so it makes no difference.

If you are transferring windows-to-unix then...


> I've chosen to do ALL uploads and downloads in binary only. This
> includes both Perl scripts, and textfiles.


 ... you have made an extremely poor choice.  :-)


> In recently reviewing many Perl manuals, the recommendation is NOT to
> upload in binary, but to use ascii.


Right, if transferring between dissimilar systems.


> My question is as follows: could there be a possible performance hit by
> uploading my Perl scripts, textfiles etc., in binary? Or is it simply a
> situation of either it WILL work, or it WON'T work.


If windows-to-unix, then binary mode probably WON'T work.


> What potential problems are there in uploading in binary? 


The line-ending sequence will not be properly translated,
and the shebang line method of running programs won't work.


> I'm not trying
> to be a contrarian; I just remember hearing a long time ago from a
> genius programmer that with Unix/Linux binary is always better.


You cannot determine which is "better" unless you know what
OS is at _each_ end of the transfer.


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


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

Date: Sat, 23 Nov 2002 14:16:47 +0100
From: Darek Adamkiewicz <d.adamkiewicz@i7.com.pl>
Subject: Can pragma "use locale" affect sort function used in module method?
Message-Id: <3DDF7FBF.4090109@i7.com.pl>

Hello folks,
I can't figure out how this could be done - if this could be done
- perhaps anybody enlighten me?

Regards
Darek
-- 
"The biggest cause of trouble in the world today is that the stupid 
people are so sure about things and the intelligent folks are so full of 
doubts." - Bertrand Russell

TinyDB - perl 'more-than-flatfile-database':
http://search.cpan.org/author/DADAMK/MLDBM-TinyDB-0.17/
for perl/tk example of use look:
http://www.i7.com.pl/soft/



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

Date: Sat, 23 Nov 2002 09:12:29 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Can pragma "use locale" affect sort function used in module method?
Message-Id: <slrnatv6mt.2dg.tadmc@magna.augustmail.com>

Darek Adamkiewicz <d.adamkiewicz@i7.com.pl> wrote:

> Subject: Can pragma "use locale" affect sort function used in module method?


   perldoc perllocale

says:

   sort() is also affected if used without an explicit comparison function


I don't see that your "used in module method" qualification
would make any difference in the answer.


> I can't figure out how this could be done 


What have you tried as part of your "figure out" efforts?

Did you try reading the documentation for Perl's locale features?

Did you try reading the documentation for the function you
are asking about?

   perldoc -f sort

      "When C<use locale> is in effect, C<sort LIST> sorts LIST 
       according to the current collation locale.  See L<perllocale>."


> if this could be done
> - perhaps anybody enlighten me?


We are not a "read the docs to me" service.

Please try that yourself *before* posting in the future.


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


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

Date: Sat, 23 Nov 2002 22:07:14 +0100
From: "Seansan" <sheukels=cuthere=@yahoo.co.uk>
Subject: complex foreach loop with deep hashes (sorted hash slices (using an array for keys))
Message-Id: <3ddfef2e$0$94296$e4fe514c@dreader4.news.xs4all.nl>

Hi,

I use the following loop code to loop through a list contained in %LIST. The
list keys are IDs, the value is an array containing about 5 values. This
loop sorts list items based on $x (0-4), based on what I want to sort on
within the array within the hash. Still with me?

foreach $no (sort {uc @{$LIST{$a}}[$x] cmp uc @{$LIST{$b}}[$x]} %LIST)

How do I make the code functional exactly as it does, but also include the
possibility to not iterate over the whole %LIST, but only the Hash IDs that
are contained in another array @G_ITEMS ?

I tried the following :
my %NEWAR; foreach (@G_ITEMS) {$NEWVAR{$_}=[@{$LIST{$_}}];};
But this doesnt work (quick code I came up with), but also copies part of
the hash; hence using more memory. I would like to solve the problem by
doing somethin to the original code :

foreach $no (sort {uc @{$LIST{$a}}[$x] cmp uc @{$LIST{$b}}[$x]} %LIST)

If anyone knows how or has a link I would like to hear.

Thx in advance, Sean

(also posted in comp.lang.perl)







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

Date: Sat, 23 Nov 2002 22:18:03 +0100
From: "Seansan" <sheukels=cuthere=@yahoo.co.uk>
Subject: Re: complex foreach loop with deep hashes (sorted hash slices (using an array for keys))
Message-Id: <3ddff1b7$0$94304$e4fe514c@dreader4.news.xs4all.nl>

After some usenet browsing I figured the following would solve the problem :

foreach (keys %{@LIST{@G_ITEMS}}) {print "<LI> $_\n";}

But this returns the error :

Can't use an undefined value as a HASH reference at

Grtz, Sean




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

Date: Sat, 23 Nov 2002 16:47:45 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: complex foreach loop with deep hashes (sorted hash slices (using an array for keys))
Message-Id: <slrnau01ch.3pa.tadmc@magna.augustmail.com>

Seansan <sheukels=cuthere=@yahoo.co.uk> wrote:

> foreach $no (sort {uc @{$LIST{$a}}[$x] cmp uc @{$LIST{$b}}[$x]} %LIST)
                                                                ^^^

where is the call to the "keys" function ?


> How do I make the code functional exactly as it does, 


I doubt that you want it to do exactly what it does.

It uses array refs as hash keys.


> but also include the
> possibility to not iterate over the whole %LIST, but only the Hash IDs that
> are contained in another array @G_ITEMS ?


If you had "keys %LIST" there as you should, then you could
just replace it with @G_ITEMS.


> doing somethin to the original code :
> 
> foreach $no (sort {uc @{$LIST{$a}}[$x] cmp uc @{$LIST{$b}}[$x]} %LIST)
                        ^                       ^

Is that truly the code you have?

What's with the one-element slices?

Do you have warnings enabled?


> (also posted in comp.lang.perl)


That was a double mistake.

You should not post individually to multiple newsgroups, you
should instead make a single article and crosspost it to
both groups.

You should not post to comp.lang.perl, it was removed
about 7 *years* ago...


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


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

Date: 23 Nov 2002 20:45:13 GMT
From: Rafael Garcia-Suarez <rgarciasuarez@free.fr>
Subject: Re: Cross-Platform method to get process information
Message-Id: <slrnatvqa4.6nn.rgarciasuarez@rafael.example.com>

Jeff Walter wrote in comp.lang.perl.misc :
>     I have a script that needs to check the status and PID of processes by
> command name.  Right now I have it running as just substr'ing the results of
> "ps axu | grep cmd".  Problem is, the results are formatted differently on
> BSD from RedHat.  So is there a module to do this sort of thing?

There are some Proc::* modules on CPAN. Proc::ProcessTable may be the
one you're looking for.

Note also that the ps that comes with most Linux distributions is quite
flexible. Check its manpage for the -e option.

And by the way, you can avoid to fork a 'grep' process by doing it from
perl.

-- 
If strain on the lexer were a design criterion, I blew it long ago.
    -- Larry Wall


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

Date: Sat, 23 Nov 2002 21:54:25 GMT
From: "Paul Titchener" <pault@dspfx.com>
Subject: DBM compatibilty/porting FreeBSD to linux
Message-Id: <lOSD9.50530$Ik.1336387@typhoon.sonic.net>

We have some cgi scripts written in Perl currently running on FreeBSD/i386.
We need to move them to a linux based cobalt server. Both machines have Perl
5.005_03 installed. I only know Perl basics and am not very experienced in
it.

The original scripts created and maintained some big database files using
commands like:

dbmopen(%G_DATABASE_HASH, "filename", 0600) || die "Can't open DBM file\n";

This call opens the file named filename.db, automatically adding the .db
extension to the filename.

There were no use lines in the script specifying any particular database
library.

On the linux machine this same command doesn't see the file unless the .db
extension is explicitly added to the filename so
right off the bat it seems that it may be using a different library. If the
 .db extension is added, ie:

dbmopen(%G_DATABASE_HASH, "filename.db", 0600) || die "Can't open DBM
file\n";

it tries to open the file but fails.

The .db files on the FreeBSD machine are large and we have lots of them so
we are hoping we can have the linux scripts be able to read and modify these
files directly without having to rebuild them for the linux version of perl

Is a different dbm library being used in the linux perl? If so, how do I
detect which dbm library is in use and can I specify it in the linux
scripts? Looking at the build for perl on the linux machine it has various
dbm libs available (gdbm, ndbm, sdbm).

Thanks,

Paul T.




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

Date: Sat, 23 Nov 2002 08:42:56 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: disambiguating print (was Re: Basic syntax question on using arrays returned from function)
Message-Id: <slrnatv4vg.2dg.tadmc@magna.augustmail.com>

Bart Lateur <bart.lateur@pandora.be> wrote:
> "Edward Wildgoose" <Ed+nospam@ewildgoose.demon.co.uk@> wrote:
> 
>>This is a really clear answer.
> 
> I have to agree with the others, Tad. This is so well written, IMO it
> deserves a place in the FAQ.


Thanks, I'd be happy to contribute it.

It is pretty much the verbatim spiel that I present in
Stonehenge training classes.

I can't remember anymore how much of it is original from me, 
but it was probably made better with input from the other 
Stonehenge trainers (Randal et. al.).


<plug>

   This is just one example of how Perl trainings from
   Stonehenge have "distilled" the important parts of
   some strange-ish Perl feature into something that
   the beginner can understand easily enough to be
   retained until they need it.

   There are dozens of other similarly insightful approaches 
   to presenting Perl's features so that students "get it".

   We do good training. Call us.  :-)

   http://www.stonehenge.com/perltraining/

</plug>


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


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

Date: 23 Nov 2002 08:01:21 -0800
From: joemercury@gmx.net (Joe)
Subject: Re: HTTP::Daemon not working in threads?
Message-Id: <d6c57a14.0211230801.1c76cf5c@posting.google.com>

Benjamin Goldberg <goldbb2@earthlink.net> wrote in message news:<3DDF1F1B.3B8983C@earthlink.net>...

>    print STDERR "====Got request=Start=====\n";
>    print STDERR $request->as_string;
> }
> 
> __END__
> [untested]

Hi,

Thank you for your help. I copied your code (I don't fully understand
it yet), and added one line that was left out at the last part of the
code, the "offensive" line:

   my $request = $client->get_request;
   print STDERR "====Got request=Start=====\n";
   print STDERR $request->as_string;

The behaviour is still the same, the "$client->get_request" hangs on
the first connect, a second, sometimes third, connect will activate
the first connect, yet it hangs itself until next connect. :(

Is there a relatively easy way to see in the HTTP::Daemon where it
hangs so the problem can be isolated? Is this module officially
cleared for threads? At this point I like the Daemon over
IO:Socket:INET as I get the benefits of handling headers.

TIA,
J.


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

Date: 23 Nov 2002 12:11:06 -0500
From: Luis Fernandes <elf@ee.ryerson.ca>
Subject: I love you Perl!!!!!!!
Message-Id: <x08yzkjjo5.fsf@ee.ryerson.ca>

I just wanted to publically express my eternal love for Perl, Larry
Wall, Tom Christiansen and Nathan Torkington; the latter two being
the authors of the _Perl Cookbook_.

I just cooked up a program using recipes 4.6, 5.7 and 3.8. Total time
30 min. And it worked perfectly the first time!



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

Date: Sat, 23 Nov 2002 19:04:12 +0100
From: Darek Adamkiewicz <d.adamkiewicz@i7.com.pl>
Subject: Re: Not working solution
Message-Id: <3DDFC31C.9010605@i7.com.pl>

Darek Adamkiewicz wrote:
> following subname BEGIN put in module seems to work:
> BEGIN { if ($::{'locale::'}) { require locale; import locale} }
No, this is not working solution, 'if' condition is always true :(((
I would have known this if I had read the Kai's post completely
- use caller function doesn't work too - so I'm still looking for the 
solution.



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

Date: Sat, 23 Nov 2002 21:59:14 GMT
From: heitkamp@ameritech.net
Subject: perl compile problem on linux
Message-Id: <SSSD9.2633$4j5.1484359@newssvr28.news.prodigy.com>
Keywords: getprotobyname, linux, glibc, 2.3.1,

I have been trying to compile both perl 5.6.1 and 5.8.0
on my linux setup. I use glibc-2.3.1 and gcc 3.2.1 with
a very recent kernel. The perl configure process will
not pick up getprotobyname in netdb.h (along with
several other functions that appear to be in the 
system C library libraries.  Has anyone had problems
like this?  Any hints on how to fix?

-- 

Fred

Error Loading Explorer.exe
You must reinstall Windows.


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

Date: Sat, 23 Nov 2002 15:15:16 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Perl one-liners in Win32
Message-Id: <fqqutusb22ttokgsjecuk6t06jr816gqfv@4ax.com>

On Thu, 21 Nov 2002 19:01:21 -0800, Dave E
<fixerdave@hot-NoSpamPlease-mail.com> wrote:

>> ... perl -le "print for map{glob}@ARGV" *.*
>
>nifty, but how is a mere human suppose to know that:
>    "-l[octal]       enable line ending processing, specifies line terminator"
>means that each print statement gets put on a new line?  If I hadn't seen it here,

I am only a perl newbie, using it since a few months for few minutes a
day few days a week, yet the quoted description seems PERFECTLY clear
to me. OTOH yours is WRONG, since:

(i) a "print statement" is something that belongs to the source code
and I think it makes no sense to say that it "gets put on a new
line"[*],

(ii) granted that I understand what you really mean, that is wrong
too, especially if you do supply an octal value. For example try this:

perl -l100 -e "print for <*>;"

Also, I guess you got the quoted line with 'perl --help': no surprise
it's concise! But 'perldoc perlrun' tells me that

>-l[*octnum*]
>     enables automatic line-ending processing. It has two separate
>     effects. First, it automatically chomps "$/" (the input record
>     separator) when used with -n or -p. Second, it assigns "$\" (the
>     output record separator) to have the value of *octnum* so that any
>     print statements will have that separator added back on. If
>     *octnum* is omitted, sets "$\" to the current value of "$/". For


[*] This might have to do with the fact that English is not my first
language.


Michele
-- 
>It's because the universe was programmed in C++.
No, no, it was programmed in Forth.  See Genesis 1:12:
"And the earth brought Forth ..."
- Robert Israel on sci.math, thread "Why numbers?"


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

Date: Sat, 23 Nov 2002 23:23:14 +1100
From: "Tintin" <spam@all.costs.must.die>
Subject: Re: shtml and Perl
Message-Id: <3ddf7376$1_1@news.iprimus.com.au>


"Talid" <tjalbout@hotmail.com> wrote in message
news:7hwD9.62574$ka.1855003@news1.calgary.shaw.ca...
> "> Here's a suggestion:  crosspost your questions instead of multiposting
> > them.  You have followups here and in alt.perl, but they're in
> > completely different threads.
>
> Agreed, I apologise for the inconvenience. First time news users. :P

Suggest you read http://www.cs.tut.fi/~jkorpela/usenet/xpost.html as a
starter.




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

Date: Sat, 23 Nov 2002 12:48:36 +0000
From: John R Ramsden <jr@adslate.com>
Subject: Re: Socket client/server example not working on Windows 2K
Message-Id: <55uutugubpoc7vuhcoqc159lt316cre6vd@4ax.com>

Benjamin Goldberg <goldbb2@earthlink.net> wrote:
>
> John Ramsden wrote:
> >
> > [...]
> >
> > Many thanks for your reply, Rocco. I only wish I could use IO::Socket.
> > But the snag is the server will be receiving a constant stream of
> > event messages from various clients and has to store these in a
> > different MySQL database for each. So if everything had to run
> > explicitly in one process, my server code would be constantly
> > disconnecting from one database and connecting to another.
> 
> Err, why?  You can have more than one database connection open in
> a perl process.

Doh! Yes, that was the missing piece of the jigsaw. I've now recoded
the server and the client both to use IO::Select and IO::Socket and
both work fine on Windows and Unix. Thanks for the help everyone.




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

Date: Sat, 23 Nov 2002 09:15:30 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: string qustion?
Message-Id: <slrnatv6si.2dg.tadmc@magna.augustmail.com>

default <default@nih.gov> wrote:

> Thanks a lot. Ying


If you really mean that, then please see:

   http://www.geocities.com/nnqweb/nquote.html

and start quoting your followups correctly.


[ snip TOFU ]

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


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

Date: 23 Nov 2002 12:10:53 -0800
From: barry_king@hotmail.com (Barry King)
Subject: Unpacking MHTML files on upload
Message-Id: <838d54f3.0211231210.1c6acde4@posting.google.com>

Hi.  I want to have a form that allows users to upload an MHTML file
(via <input type=file>) which is then unpacked on the server by the
CGI (Perl) that received the POST.  Is there a Perl module out there
that can enable my CGI to easily unpack the MHTML?

Thanks!

Barry


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

Date: Sat, 23 Nov 2002 12:37:34 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: was: Re: string qustion?
Message-Id: <3ddf680e.167491632@news.erols.com>

Bart Lateur <bart.lateur@pandora.be> wrote:

: default wrote:
: 
: >There are some strings:
: >$str1 =                    "A1 B2 S2 D4 D3 S2";
: >$str2 =                                     "D4 D3 S2 F2 A4 A5 D2";
: >$str3 =  "X1 Z3 A11 A1 B2";
: >
: >I want to get the string:
: >$str_results = "X1 Z3 A11 A1 B2 S2 D4 D3 S2 F2 A4 A5 D2";
: >How to do it with Perl?
: 
: Actually, it looks to me that the strings actually represent ordered
: sets (if that's the proper term; a directed graph is another term I'd
: think of), and you want to merge these sets, and print out the merged
: set. Well: I asked a similar question on a more complex case, and the
: answer I got is to use a "toposort" method from the Graph package on
: CPAN.
: 
: This is how I would do it (though I'm no expert):
: 
: 	use Graph;
: 	my $graph  = new Graph::Directed;
: 
: 	my $str1 = "A1 B2 S2 D4 D3 S2";
: 	my $str2 = "D4 D3 S2 F2 A4 A5 D2";
: 	my $str3 = "X1 Z3 A11 A1 B2";
: 
: 	$graph->add_path(split " ", $str1);
: 	$graph->add_path(split " ", $str2);
: 	$graph->add_path(split " ", $str3);
: 	$str_total = join " ", $graph->toposort;
: 	print "$str_total\n";
: 
: Hmm... I get the wrong results:
: 
: 	X1 Z3 A11 A1 B2 S2 F2 A4 A5 D2 D4 D3
: 
: But the reason must be because "S2" appears in your first string twice,
: thurning "S2", "D3", "D4" into a loop.  Is my misunderstanding of your
: problem wrong?

I'm no expert either, but that looks too nice to abandon just because it
gives a bad answer.  :)

Perhaps word pairs can be used as nodes on the graph.

    use Graph;
    my $graph  = new Graph::Directed;
    my $str1 = "A1 B2 S2 D4 D3 S2";
    my $str2 = "D4 D3 S2 F2 A4 A5 D2";
    my $str3 = "X1 Z3 A11 A1 B2";

    $graph->add_path($str1 =~ /(?=(?:\s|^)(\S+ \S+))/g);
    $graph->add_path($str2 =~ /(?=(?:\s|^)(\S+ \S+))/g);
    $graph->add_path($str3 =~ /(?=(?:\s|^)(\S+ \S+))/g);
    my $str_total = join " ", $graph->toposort;
    $str_total =~ s/(\S+) \1/$1/g;
    print "Result: $str_total\n";
    print "Expect: X1 Z3 A11 A1 B2 S2 D4 D3 S2 F2 A4 A5 D2\n";

WAGging here, but it feels like that's treating what were edges as
vertices, changing a graph existing in N dimensions into a graph that
exists in N-1 dimensions.

But it too could trip over loops if the same word pair appears in more
than two places.  Same problem as before, only slightly less likely to
come up.  Maybe the program can be made to detect when this is going to
happen and adjust itself accordingly.



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

Date: Sat, 23 Nov 2002 19:06:18 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Way to print caller() info from first to last instead of last to first?
Message-Id: <ihjvtu0svccqosc96j3ev69tho2nkmra9k@4ax.com>

Carlos C. Gonzalez wrote:

>Normally caller() can be called with a number indicating how far back in 
>the call trace one wants to acquire information for.  As in the following 
>snippet of code...
>
>my $i = 1; # The previous call - NOT the very first one.
>while (@a = caller($i++))
>{
>  my ($package,$file,$line,$sub) = @a;
>  printf "%s $s $d $s\n", $package, $file, $line, $sub;

Typo: use "%" instead of "$".

>}
>
>The first call might have been 4 functions back. 
>
>That's all well and good but the last line of info printed out 
>corresponds to the first call.  Meaning that one must traverse one's way 
>back up the output to find the info for the last call.  
>
>Is there some way to find out how far back in the call trace caller() can 
>return info for?  Such that one could output the call trace from the 
>first to the last call?  Resulting in the last call showing up at the 
>bottom of the output?  

Of course you can. Either, as you thought yourself, store the data --
output string or result array -- i nan array, and print out the contents
in reversed order; or first find the index of the last valid call, and
go back through them in reverse order. I'll show code for all these
approaches.

A] Store array

	my $i = 1;
	my @stack;
	while (my @a = caller($i++))
	{
	   push @stack, \@a;
	}
	while(my $ref = pop @stack)
	{
	  my ($package,$file,$line,$sub) = @$ref;
	  printf "%s %s %d %s\n", $package, $file, $line, $sub;
	}


B] Variation: store strings
	
	my $i = 1;
	my @stack;
	while (my @a = caller($i++))
	{
	   my ($package,$file,$line,$sub) = @a;
	   push @stack, sprintf "%s %s %d %s\n", $package, $file, $line,
		 $sub;
	}
	local $_;
	print while $_ = pop @stack;


C] Other approach: call twice, second time in reversed order

	my $i = 0;
	while (caller(++$i)) {}
	while(--$i)
	{
	    my ($package,$file,$line,$sub) = caller($i);
	    printf "%s %s %d %s\n", $package, $file, $line, $sub;
	}

-- 
	Bart.


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

Date: Sat, 23 Nov 2002 16:52:37 GMT
From: "Felix F." <felix@pz4.org>
Subject: Re: Why not PERL?
Message-Id: <pnOD9.8225$hi6.1631@nwrddc02.gnilink.net>

Riiiight.
heh :)

"Teh (tî'pô)" <teh@mindless.com> wrote in message
news:te0tsu46ou2ure0ijm5n6mvj9h9gpgvhes@4ax.com...
> Jeff 'japhy' Pinyan bravely attempted to attach 23 electrodes of
> knowledge to the nipples of comp.lang.perl.misc by saying:
> >
> >The name "perl" came first.
>
> Does that mean that the next language will be called Swyne?
>
> --
> Get it? Perl before Swyne? It's a pun, you know, like in the saying
> "pearls before swine", no? OK, no need to throw me out, I'll go
> quietly.
>
> <aside>
> Well *I* thought it was funny...
> </aside>




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

Date: Sat, 23 Nov 2002 15:19:42 GMT
From: "Bob X" <bobx@linuxmail.org>
Subject: Re: Windows XP / Perl Question
Message-Id: <i0ND9.950$ov6.512099@news2.news.adelphia.net>


<btam01@ccsf.edu> wrote in message
news:Pine.HPX.4.44.0211221216450.8887-100000@hills.ccsf.cc.ca.us...
> I have a perl script that cleans out certain directories in Windows XP.
> How would I setup the computer so that this script would run automatically
> right before I shut down my computer?
>
> Thanks,
> Bill

Put it in a bat file...

On Windows XP Professional:


"Open the Group Policy snap-in (start - run - gpedit.msc).
Under computer configuration - windows setting - scripts,
right-click on shutdown, select properties, and add the
name of the program you want to run. In general, a script
is a batch file or javascript or vb script file, but I've
seen windows allow .exe files in some cases as well.
Haven't tried it in this particular case, but if it won't
allow you to run an executable directly, just create a
batch file to run it from, and run the batch file at
shutdown..."

Another thought is to do it when logging in...




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

Date: Sat, 23 Nov 2002 17:28:03 +0100
From: Darek Adamkiewicz <d.adamkiewicz@i7.com.pl>
Subject: Working solution
Message-Id: <3DDFAC93.9050204@i7.com.pl>

following subname BEGIN put in module seems to work:
BEGIN { if ($::{'locale::'}) { require locale; import locale} }

Solution found here:
http://groups.google.pl/groups?hl=pl&lr=&ie=UTF-8&inlang=pl&threadm=3BE84584.34727BA6%40earthlink.net&rnum=4&prev=/groups%3Fhl%3Dpl%26lr%3D%26ie%3DISO-8859-2%26q%3Dsort%2Blocale%2Bmodule%26meta%3Dgroup%253Dcomp.lang.perl.*

Thanks

Regards
Darek

-- 
"The biggest cause of trouble in the world today is that the stupid 
people are so sure about things and the intelligent folks are so full of 
doubts." - Bertrand Russell

TinyDB - perl 'more-than-flatfile-database':
http://search.cpan.org/author/DADAMK/MLDBM-TinyDB-0.17/
for perl/tk example of use look:
http://www.i7.com.pl/soft/



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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 4166
***************************************


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