[22572] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4793 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 31 14:06:10 2003

Date: Mon, 31 Mar 2003 11:05:11 -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           Mon, 31 Mar 2003     Volume: 10 Number: 4793

Today's topics:
        ANNOUNCE: Tie::Tk::Listbox <6jrwvn6d02@sneakemail.com>
        Bot to modify a resume on monster.com <darkdan666@hotmail.com>
        capitalize songs names (pattern question) <elvar@vaip.werro.ee>
    Re: capitalize songs names (pattern question) <jasonhood@tiscali.co.uk>
    Re: capitalize songs names (pattern question) <somewhere@nowhere.com>
    Re: CGI.pm or roll-your-own? <noreply@gunnar.cc>
    Re: CGI.pm or roll-your-own? (Peter Scott)
    Re: CGI.pm or roll-your-own? <usrsa@racquettech.com>
    Re: CGI.pm or roll-your-own? <usrsa@racquettech.com>
    Re: CGI::ContactForm 1.03 - Feedback request <noreply@gunnar.cc>
        Cookie Question (Captain Zod)
    Re: Cookie Question <nobull@mail.com>
    Re: counting repetition in an array with Perl (Justin)
    Re: counting repetition in an array with Perl <me@verizon.invalid>
        CPAN is now Matt's Script Archive <clay@panix.com>
    Re: CPAN is now Matt's Script Archive <scriptyrich@yahoo.co.uk>
    Re: help understand dereferencing <usenet@tinita.de>
        implementing a threaded serial device (or any other par <stacom@stacom-software.de>
        make.pl 0.4 released <occitan@esperanto.org>
    Re: MSWin32 Active State Perl Question <mooncm.lbkejwiAhEgSfSe@dAcEbSaS>
        Perl Debugger : ptkdb (zzapper)
    Re: Perl doing server builds/LDAP/IMAP/DNS/Bind/Sendmai <kermit.tensmeyer@ti.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 31 Mar 2003 15:41:53 GMT
From: Steffen Mueller <6jrwvn6d02@sneakemail.com>
Subject: ANNOUNCE: Tie::Tk::Listbox
Message-Id: <f3a01aa207c444c0b334ce63ca268242@news.teranews.com>

I would like to announce a new addition to CPAN:
Tie::Tk::Listbox, version 1.01

-- Steffen Müller

An excerpt from the README file:

Tie::Tk::Listbox version 1.01
=============================
Access Tk::Listbox and similar widgets as arrays

The Tie::Tk::Listbox module allows you to tie the contents of a
Tk::Listbox widget to an ordinary Perl array for easy
modification. Additionally, you may tie a Tk::Scrolled widget or any
other widget that advertises a Tk::Listbox subwidget.

DEPENDENCIES

This module requires these other modules and libraries:

    Test::More
    Tk
    Tk::Scrolled
    Tk::Listbox
[...]

-- 
@n=([283488072,6076],[2105905181,8583184],[1823729722,9282996],[281232,
1312416],[1823790605,791604],[2104676663,884944]);$b=6;@c=' -/\_|'=~/./g
;for(@n){for$n(@$_){map{$h=int$n/$b**$_;$n-=$b**$_*$h;$c[@c]=$h}reverse
0..11;push@p,map{$c[$_]}@c[reverse$b..$#c];$#c=$b-1}$p[@p]="\n"}print@p;




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

Date: Mon, 31 Mar 2003 17:00:03 +0200
From: "BlueTrin" <darkdan666@hotmail.com>
Subject: Bot to modify a resume on monster.com
Message-Id: <b69l5m$c82$1@news-reader10.wanadoo.fr>

Hi,

I m new to perl, I wanted to write a script that would log
on monster.com, fetch the URL of the first resume, then
edit some part of it and validate it.

Anyone knows what module/functions should I use or
have written already a script to do this.


Anthony




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

Date: Mon, 31 Mar 2003 17:16:56 +0300
From: "Elvar Ojar" <elvar@vaip.werro.ee>
Subject: capitalize songs names (pattern question)
Message-Id: <3e884d99$1_1@news.estpak.ee>

So.., I have list of files names in lowercase:

$names[0] = "kruder&dorfmeister - livin' free";
$names[1] = "b-tribe - haklame";
$names[2] = "r.e.m. - everybody hurts";
$names[3] = "sinead o'connor - nothing compares 2u";
$names[4] = "bob dylan - knockin' on heaven's door";

And I want to capitalize them. But traditional use don't give always result
I want. I understand that somewhere I must make compromize anyway. Beacuse
you newer know how bands wants their songs names to appear. Sometimes it
don't follow grammar rules. So I did some patterns. It does in most cases
what I want.

foreach $_ (@names) {
    $_ =~ s[(\w{1})(\')(\w{3,}\S*)] [\u$1$2\u$3]gc;
    $_ =~ s[(\d*)(\w\S*)] [$1\u$2]gc;
    $_ =~ s[(\w{2,})(\W+)(\w{2,})] [$1$2\u$3]gc;
    $_ =~ s[(\-|\.|\&)(\w+)] [$1\u$2]gc;
    print "$_\n";
};

---------------------------
In here is comparison of some traditional (simple) patterns and mine.
! means that this is not good

$_ =~ s/(\w+)/\u$1/gc;
$_ =~ s/(\w+\S*)/\u$1/gc;
$_ =~ s/ <my style> /gc;

Kruder&Dorfmeister - Livin' Free    # OK
Kruder&dorfmeister - Livin' Free    # ! Kruder&dorfmeister
Kruder&Dorfmeister - Livin' Free    # OK

B-Tribe - Haklame    # OK
B-tribe - Haklame    # ! B-tribe
B-Tribe - Haklame    # OK

R.E.M. - Everybody Hurts    # OK
R.e.m. - Everybody Hurts    # ! R.e.m.
R.E.M. - Everybody Hurts    # OK

Sinead O'Connor - Nothing Compares 2u    # ! 2u
Sinead O'connor - Nothing Compares 2u    # ! O'connor 2u
Sinead O'Connor - Nothing Compares 2U    # OK

Bob Dylan - Knockin' On Heaven'S Door # ! Heaven'S
Bob Dylan - Knockin' On Heaven's Door # OK
Bob Dylan - Knockin' On Heaven's Door # OK
-------------------

So finally my question is: is there some simple, shorter, faster way that i
did? Probably is.


Elvar




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

Date: Mon, 31 Mar 2003 15:32:00 +0100
From: "Jason Hood" <jasonhood@tiscali.co.uk>
Subject: Re: capitalize songs names (pattern question)
Message-Id: <3e885124_2@mk-nntp-2.news.uk.tiscali.com>

"Elvar Ojar" <elvar@vaip.werro.ee> wrote in message
news:3e884d99$1_1@news.estpak.ee...
> So.., I have list of files names in lowercase:
>
> $names[0] = "kruder&dorfmeister - livin' free";
> $names[1] = "b-tribe - haklame";
> $names[2] = "r.e.m. - everybody hurts";
> $names[3] = "sinead o'connor - nothing compares 2u";
> $names[4] = "bob dylan - knockin' on heaven's door";
>
> And I want to capitalize them. But traditional use don't give always
result
> I want. I understand that somewhere I must make compromize anyway. Beacuse
> you newer know how bands wants their songs names to appear. Sometimes it
> don't follow grammar rules. So I did some patterns. It does in most cases
> what I want.
>
> foreach $_ (@names) {
>     $_ =~ s[(\w{1})(\')(\w{3,}\S*)] [\u$1$2\u$3]gc;
>     $_ =~ s[(\d*)(\w\S*)] [$1\u$2]gc;
>     $_ =~ s[(\w{2,})(\W+)(\w{2,})] [$1$2\u$3]gc;
>     $_ =~ s[(\-|\.|\&)(\w+)] [$1\u$2]gc;
>     print "$_\n";
> };
>
> ---------------------------
> In here is comparison of some traditional (simple) patterns and mine.
> ! means that this is not good
>
> $_ =~ s/(\w+)/\u$1/gc;
> $_ =~ s/(\w+\S*)/\u$1/gc;
> $_ =~ s/ <my style> /gc;

Elvar put an i as one of the flags... this makes it cactch any case.

ie: - $_ =~ s/(\w+)/\u$1/gci;

HTH.

J


>
> Kruder&Dorfmeister - Livin' Free    # OK
> Kruder&dorfmeister - Livin' Free    # ! Kruder&dorfmeister
> Kruder&Dorfmeister - Livin' Free    # OK
>
> B-Tribe - Haklame    # OK
> B-tribe - Haklame    # ! B-tribe
> B-Tribe - Haklame    # OK
>
> R.E.M. - Everybody Hurts    # OK
> R.e.m. - Everybody Hurts    # ! R.e.m.
> R.E.M. - Everybody Hurts    # OK
>
> Sinead O'Connor - Nothing Compares 2u    # ! 2u
> Sinead O'connor - Nothing Compares 2u    # ! O'connor 2u
> Sinead O'Connor - Nothing Compares 2U    # OK
>
> Bob Dylan - Knockin' On Heaven'S Door # ! Heaven'S
> Bob Dylan - Knockin' On Heaven's Door # OK
> Bob Dylan - Knockin' On Heaven's Door # OK
> -------------------
>



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.465 / Virus Database: 263 - Release Date: 25/03/2003




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

Date: Mon, 31 Mar 2003 15:58:39 +0100
From: "Bigus" <somewhere@nowhere.com>
Subject: Re: capitalize songs names (pattern question)
Message-Id: <b69l2v$kk0@newton.cc.rl.ac.uk>

I can make it slightly shorter, but probably holes in it somewhere:

  $_ =~ s/\b(.*?)\b/\u$1/g;                      # make all words upper case
first
  $_ =~ s/([^O\'|\W+])\'(\w+)/$1\'\l$2/g; # corrects words with apostrophes
except O' names
  $_ =~ s/(\d+)(\D+)/$1\u$2/g;               # capitalise constanants where
word starts with number

Given the nature of language, I don't think there is any easier way than
building a set of rules and applying them systematically.

Bigus

Elvar Ojar wrote:
> So.., I have list of files names in lowercase:
>
> $names[0] = "kruder&dorfmeister - livin' free";
> $names[1] = "b-tribe - haklame";
> $names[2] = "r.e.m. - everybody hurts";
> $names[3] = "sinead o'connor - nothing compares 2u";
> $names[4] = "bob dylan - knockin' on heaven's door";
>
> And I want to capitalize them. But traditional use don't give always
> result I want. I understand that somewhere I must make compromize
> anyway. Beacuse you newer know how bands wants their songs names to
> appear. Sometimes it don't follow grammar rules. So I did some
> patterns. It does in most cases what I want.
>
> foreach $_ (@names) {
>     $_ =~ s[(\w{1})(\')(\w{3,}\S*)] [\u$1$2\u$3]gc;
>     $_ =~ s[(\d*)(\w\S*)] [$1\u$2]gc;
>     $_ =~ s[(\w{2,})(\W+)(\w{2,})] [$1$2\u$3]gc;
>     $_ =~ s[(\-|\.|\&)(\w+)] [$1\u$2]gc;
>     print "$_\n";
> };
>
> ---------------------------
> In here is comparison of some traditional (simple) patterns and mine.
> ! means that this is not good
>
> $_ =~ s/(\w+)/\u$1/gc;
> $_ =~ s/(\w+\S*)/\u$1/gc;
> $_ =~ s/ <my style> /gc;
>
> Kruder&Dorfmeister - Livin' Free    # OK
> Kruder&dorfmeister - Livin' Free    # ! Kruder&dorfmeister
> Kruder&Dorfmeister - Livin' Free    # OK
>
> B-Tribe - Haklame    # OK
> B-tribe - Haklame    # ! B-tribe
> B-Tribe - Haklame    # OK
>
> R.E.M. - Everybody Hurts    # OK
> R.e.m. - Everybody Hurts    # ! R.e.m.
> R.E.M. - Everybody Hurts    # OK
>
> Sinead O'Connor - Nothing Compares 2u    # ! 2u
> Sinead O'connor - Nothing Compares 2u    # ! O'connor 2u
> Sinead O'Connor - Nothing Compares 2U    # OK
>
> Bob Dylan - Knockin' On Heaven'S Door # ! Heaven'S
> Bob Dylan - Knockin' On Heaven's Door # OK
> Bob Dylan - Knockin' On Heaven's Door # OK
> -------------------
>
> So finally my question is: is there some simple, shorter, faster way
> that i did? Probably is.
>
>
> Elvar

--





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

Date: Mon, 31 Mar 2003 16:19:37 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <b69is8$31pei$1@ID-184292.news.dfncis.de>

Helgi Briem wrote:
> On Sat, 29 Mar 2003 23:32:09 +0100, Gunnar Hjalmarsson
> <noreply@gunnar.cc> wrote:
> 
>>>>2) I haven't (yet) studied CGI.pm enough to feel 
>>>>comfortable with it.
>>>
>>>It's time to start.
>>
>>Maybe true.
> 
> Gunnar.  Have you studied the guts of your 
> Perl compiler in enough detail to be comfortable
> with it?  
> 
> [snipped other similar examples]

No, I have not.

> At some point you have to trust the experts
> and take their advice.

I know how to read STDIN and parse its contents, but I have never 
learned any of those other things you mention. I believe that that's 
the reason why it is more difficult to convince me (and a lot of other 
people) about the benefits of CGI.pm, than it is to convince us about 
the benefits of "trusting the experts" in all those other fields. 
Starting to use CGI.pm means that you replace code where you are in 
control with a black box.

> - CGI.pm is dead easy to use.
> - It is safe from every known bug and exploit.  
> - It is fast enough for any purpose to which
>   CGI is an adequate solution.
> - It has been tested and critiqued to death
>   by legions of experts.
> - CGI in itself is a trivial and uninteresting
>   interface protocol and there is little of general
>   value in learning to program every detail of
>   it yourself.

I'm convinced that all that is true, and, accordingly, I have now 
taken my first steps using it.

/ Gunnar

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Mon, 31 Mar 2003 14:21:18 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <y9Yha.598908$Yo4.45376021@news1.calgary.shaw.ca>

In article <raven-06E71F.14060530032003@netnews.attbi.com>,
 Greg Raven <raven@corax.org> writes:
>In article <slrnb86k1u.4ck.tadmc@magna.augustmail.com>,
> tadmc@augustmail.com (Tad McClellan) wrote:
>
>> Rather than have them learn the 2 lines of code they'd need
>> with CGI.pm, you would have them learn a Whole Lot More lines
>> of punctuation-intensive gobbledy gook?
>> 
>> How can that be better for an already overloaded beginner? 
>
>Let me give you an example. Let's say that the AOB wants to try CGI.pm, 
>and comes across this:
>
>          #!/usr/local/bin/perl -w
>          use CGI;                             # load CGI routines
>          $q = new CGI;                        # create new CGI object
>          print $q->header,                    # create the HTTP header
>                $q->start_html('hello world'), # start the HTML
>                $q->h1('hello world'),         # level 1 header
>                $q->end_html;                  # end the HTML

Why go so far down in the documentation to find something you don't
understand when the *very first* code example uses the more common
functional interface:

	use CGI qw/:standard/;
        print header,
        start_html('A Simple Example'),
        h1('A Simple Example'),
	[...]

(See http://www.perldoc.com/perl5.8.0/lib/CGI.html)  And 10 lines later,
there's the use of param().  This is the very first thing after the table
of contents.  It's even before the abstract.  How much easier can it get?

>With a cgi-lib.pl-type of construction, everything seems more or less to 
>be right in front of you.

cgi-lib.pl doesn't have an equivalent of the h1() function from the code
you quoted.  Or any other HTML generating code aside from the equivalents
of start_html() and end_html().

I note that cgi-lib.pl has a home page (http://cgi-lib.berkeley.edu/) which
says, "The cgi-lib.pl library has become the de facto standard library for 
creating CGI scripts."  Sigh.

-- 
Peter Scott
http://www.perldebugged.com


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

Date: 31 Mar 2003 16:50:07 GMT
From: Greg Raven <usrsa@racquettech.com>
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <usrsa-0A4D71.08501331032003@tribune.sj.sys.us.xo.net>

In article <b685tf$cqv$2@slb2.atl.mindspring.net>,
 "William Alexander Segraves" <wsegrave@mindspring.com> wrote:

> "Greg Raven" <raven@corax.org> wrote in message
> news:raven-5783A7.16333530032003@netnews.attbi.com...
> <snip>
> > On the basis of what Randal Schwartz and others have posted, I'm going
> > to have another look at CGI.pm. I'm slated soon to take over a web site
> > that makes fairly heavy use of perl, and the input coding on the CGI
> > side isn't even up to the cgi-lib.pl standard -- that is, each field
> > value
> 
> You mean name, I think.
> 
> > is "hand-harvested" from the form, for assignment to a variable.
> > (That is, there is no looping through the fields/field values.) I figure
> > that just about anything is an improvement.
> 
> Hand harvested? Would you still do that if you knew you could loop through
> and print out all of the name value pairs of a form without knowing the
> names?

That's my point ... the person has been writing the perl code for the 
site up to this point hasn't even been looping through the variables, 
let alone getting them through CGI.pm. An example from a file chosen at 
random:

####initialize variable for calculations

$currentstring = $FORM{'currentstring'};
$rechoose = $FORM{'rechoose'};

if ($rechoose eq 'yes') {
   $diaop = $FORM{'diaop'};
   $stiffop = $FORM{'stiffop'};
   $forceop = $FORM{'forceop'};
   $dtop = $FORM{'dtop'};
   $dwellop = $FORM{'dwellop'};
   $defop = $FORM{'defop'};
   $totlossop = $FORM{'totlossop'};
   $cofop = $FORM{'cofop'};

   $diapref = $FORM{'diapref'};
   $stiffpref = $FORM{'stiffpref'};
   $forcepref = $FORM{'forcepref'};
   $dtpref = $FORM{'dtpref'};
   $dwellpref = $FORM{'dwellpref'};
   $defpref = $FORM{'defpref'};
   $totlosspref = $FORM{'totlosspref'};
   $cofpref = $FORM{'cofpref'};
   $mfg_select = $FORM{'mfg_select'};
   $fuzziness = $FORM{'fuzziness'};
   $selector_units = $FORM{'selector_units'};
   @mfg_list = split(/,/,$mfg_select);
   $sfield = $FORM{'sfield'};
   
}

@specs=split(/\t/,$currentstring);
($mfgA, $stringA, $typeA, $diaA, $stiffA, $forceA, $dtA, $peaktenA, 
$dwellA, $defA, $tenlossA, $implossA, $totlossA, $cofA, $playA, $durA, 
$overallA) = @specs;

-- 
Greg Raven (greg at racquettech dot com)
U.S. Racquet Stringers Association
Solana Beach, CA


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

Date: 31 Mar 2003 16:53:05 GMT
From: Greg Raven <usrsa@racquettech.com>
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <usrsa-A2B5B4.08531131032003@tribune.sj.sys.us.xo.net>

In article <y9Yha.598908$Yo4.45376021@news1.calgary.shaw.ca>,
 peter@PSDT.com (Peter Scott) wrote:

> In article <raven-06E71F.14060530032003@netnews.attbi.com>,
>  Greg Raven <raven@corax.org> writes:
> >In article <slrnb86k1u.4ck.tadmc@magna.augustmail.com>,
> > tadmc@augustmail.com (Tad McClellan) wrote:
> >
> >> Rather than have them learn the 2 lines of code they'd need
> >> with CGI.pm, you would have them learn a Whole Lot More lines
> >> of punctuation-intensive gobbledy gook?
> >> 
> >> How can that be better for an already overloaded beginner? 
> >
> >Let me give you an example. Let's say that the AOB wants to try CGI.pm, 
> >and comes across this:
> >
> >          #!/usr/local/bin/perl -w
> >          use CGI;                             # load CGI routines
> >          $q = new CGI;                        # create new CGI object
> >          print $q->header,                    # create the HTTP header
> >                $q->start_html('hello world'), # start the HTML
> >                $q->h1('hello world'),         # level 1 header
> >                $q->end_html;                  # end the HTML
> 
> Why go so far down in the documentation to find something you don't
> understand when the *very first* code example uses the more common
> functional interface:
> 
> 	use CGI qw/:standard/;
>         print header,
>         start_html('A Simple Example'),
>         h1('A Simple Example'),
> 	[...]
> 
> (See http://www.perldoc.com/perl5.8.0/lib/CGI.html)  And 10 lines later,
> there's the use of param().  This is the very first thing after the table
> of contents.  It's even before the abstract.  How much easier can it get?

I was trying to read everything before doing anything. Also, the first 
example didn't address the task I was attempting to accomplish, so I 
hoped that by reading more of the documentation I might understand how 
to approach my task optimally.

-- 
Greg Raven (greg at racquettech dot com)
U.S. Racquet Stringers Association
Solana Beach, CA


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

Date: Mon, 31 Mar 2003 16:44:51 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: CGI::ContactForm 1.03 - Feedback request
Message-Id: <b69kbq$31ii5$1@ID-184292.news.dfncis.de>

Tore Aursand wrote:
> I just had a look at your code (again), and there are still room for
> improvements;
> 
>   1. Use CGI.pm wherever possible.  There are a few places where
>      you ignore the superior CGI.pm. :)

Hmm.. On *that* there are different views, also among the regulars in 
this group, right? :)  Nevertheless, I intend to study the rest of 
CGI.pm (i.e. besides the 'param' method) as well, and consider the use 
of other parts of it, both in this module, and in other programs. But 
that will take its time.

>   2. Separate Perl code from "other";  I see there is room for
>      separating HTML, text and configuration directives into
>      separate files.

I see your point with that. But do you really think that doing so is 
always an advantage, irrespective of the size of a program? This 
module is small.

>   3. Instead of 'sub htmlize' I would have used a module for that.
>      There are a few entitites modules at CPAN.

Will check them out.

Thanks for your comments, Tore!

/ Gunnar

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: 31 Mar 2003 09:28:10 -0800
From: cptnzod@yahoo.com (Captain Zod)
Subject: Cookie Question
Message-Id: <9433af5b.0303310928.316d31a2@posting.google.com>

Hello Folks,
I am writing a shopping cart program. The way I designed it is that
there is one central cgi script which gets called all the time and
depending on the parameter that is passed to this script different
part of the script gets executed. Now here is the problem:
If I print http header and other things, then I can no longer
manipulate the cookies. So what is one to do? Is there a way to close
out the current http ( session is right word? ) and start out new so
that I can manipulate the cookies again?

thx yall


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

Date: 31 Mar 2003 19:12:30 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Cookie Question
Message-Id: <u9vfxzs8vl.fsf@wcl-l.bham.ac.uk>

cptnzod@yahoo.com (Captain Zod) writes:

> Newsgroups: comp.lang.perl.misc
> Subject: Cookie Question

Your question has nothing whatever to do with Perl.

> I am writing a shopping cart program. The way I designed it is that
> there is one central cgi script which gets called all the time and
> depending on the parameter that is passed to this script different
> part of the script gets executed. Now here is the problem:
> If I print http header and other things, then I can no longer
> manipulate the cookies. So what is one to do?

Not print the headers until you are sure you have finished
manipulating the cookies.

> Is there a way to close out the current http ( session is right
> word? ) and start out new so that I can manipulate the cookies
> again?

This is a question about HTTP.

I think the answer is no, but you'll maybe get more reliable answers
in a newsgroup where this is on-topic.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 31 Mar 2003 07:31:43 -0800
From: justingrondines@hotmail.com (Justin)
Subject: Re: counting repetition in an array with Perl
Message-Id: <a595fb13.0303310731.13957ee4@posting.google.com>

Benjamin Goldberg <goldbb2@earthlink.net> wrote in message news:<3E851B1B.A5519189@earthlink.net>...
> dw wrote:
> [snip]
> > foreach $idx1 (sort keys %data) {
> >   foreach $idx2 (sort keys %{$data{$idx1}}) {
> >     print OUTDB "$idx1 $idx2 $data{$idx1}{$idx2}\n"
> >   }
> > }
> 
> These are numbers, so a numeric comparison is needed.
> 
> foreach $idx1 (sort { $a <=> $b } keys %data) {
>    foreach $idx2 (sort { $a <=> $b } keys %{$data{$idx1}}) {
>       print OUTDB "$idx1 $idx2 $data{$idx1}{$idx2}\n"
>    }
> }
> 
> Also, you might get a small speed gain by doing the following:
> 
> foreach $idx1 (sort { $a <=> $b } keys %data) {
>    my $subhash = $data{$idx1};
>    foreach $idx2 (sort { $a <=> $b } keys %$subhash) {
>       print OUTDB "$idx1 $idx2 $$subhash{$idx2}\n"
>    }
> }


thank you so much for your quick answers. There's a little detail that
i forget to mention, the format of the variable BW (second field) is
not fix (3 or 4 caracters).

so the sorted output look like this

17 140
 3
17 1000 1
18 857
 2
18 3000 3
 ...


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

Date: Mon, 31 Mar 2003 16:06:39 GMT
From: "dw" <me@verizon.invalid>
Subject: Re: counting repetition in an array with Perl
Message-Id: <jIZha.27605$HR6.7863@nwrdny01.gnilink.net>


"Justin" <justingrondines@hotmail.com> wrote in message
news:a595fb13.0303310731.13957ee4@posting.google.com...
> Benjamin Goldberg <goldbb2@earthlink.net> wrote in message
news:<3E851B1B.A5519189@earthlink.net>...
> > dw wrote:
> > [snip]
>
> There's a little detail that
> i forget to mention, the format of the variable BW (second field) is
> not fix (3 or 4 caracters).
>
> so the sorted output look like this
>
> 17 140
>  3
> 17 1000 1
> 18 857
>  2
> 18 3000 3
> ...

Then instead of
  $data{substr($_,0,2)}{substr($_,3,4)} ++;
use something a little better suited for the job.  If there are just the two
values separated by a space:
  m/^(\d+)\s+(\d+)/;
  $data{$1}{$2}++;

dw




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

Date: Mon, 31 Mar 2003 18:58:04 +0000 (UTC)
From: Clay Irving <clay@panix.com>
Subject: CPAN is now Matt's Script Archive
Message-Id: <slrnb8h3ts.7f5.clay@panix3.panix.com>

What happened? http://www.cpan.org load Matt's Script Archive.
April Fools Day isn't until tomorrow.

-- 
Clay Irving <clay@panix.com>
There is nothing more exhilarating than to be shot at without result. 
- Winston Churchill 


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

Date: Mon, 31 Mar 2003 20:07:35 +0000
From: Rich <scriptyrich@yahoo.co.uk>
Subject: Re: CPAN is now Matt's Script Archive
Message-Id: <b6a3fe$e00$1@newsg2.svr.pol.co.uk>

Clay Irving wrote:

> What happened? http://www.cpan.org load Matt's Script Archive.
> April Fools Day isn't until tomorrow.

Oh man - it got me for a second - try clicking on (most) of the links!
-- 
Rich
scriptyrich@yahoo.co.uk


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

Date: 31 Mar 2003 15:20:48 GMT
From: Tina Mueller <usenet@tinita.de>
Subject: Re: help understand dereferencing
Message-Id: <tinhcmdhv$1w4$tina@news01.tinita.de>

Uri Guttman <uri@stemsystems.com> wrote:
>>>>>> "c" == chance  <chance@austin.rr.com> writes:

>   c> What should I  read that I haven't read (or understood?) 

>   c> I wasn't aware that 'my @test_array = @$array_ref; ' created an
>   c> array copy either.

> remember, that when you deref an array/hash ref as the whole thing, it
> is now a proper array/hash. how else would @foo = @bar work? same with
> the above code.

just a note to the OP:
if there are references inside of $hash_ref, then changing
them in the copy will also change them in the original.
e.g.:
 $a = { a=> 23, b => { c => 42 } };
 %b = %$a;
 $b{b}->{c}++;

$a->{b}->{c} will now be 43.

forgetting this can sometimes lead to difficult errors / debugging...
regards, tina
-- 
http://www.tinita.de/     \  enter__| |__the___ _ _ ___
http://Movies.tinita.de/   \     / _` / _ \/ _ \ '_(_-< of
http://www.perlquotes.de/   \    \ _,_\ __/\ __/_| /__/ perception
http://www.tinita.de/peace/link.html - Spread Peace


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

Date: Mon, 31 Mar 2003 18:29:19 +0000
From: Alexander Eisenhuth <stacom@stacom-software.de>
Subject: implementing a threaded serial device (or any other parallel way)
Message-Id: <b69qd6$30kjm$1@ID-155280.news.dfncis.de>

Hallo together,

I'm quite new to perl, but with enough experiences in other programming languages.

What I need is a serial device class, where each object waits for a special
character to receive. After receiving the "termination char" it calls a callback
to evaluate the received message.

Because I don't want to do it in a loop, asking each serial device ... i tried
to do it with threads. After some tests I got to the point that perl creates a
copy of a object I give to the thread (here $comObj)

# real code and pseudocode
package CComClass;
 ...
sub new {
	my ($packageName, $osDeviceName) = @_;
	my $comObj = {
		inputBuffer=>"",
		running=>1,
		watchThread=>0,
		internalCountr=>0,
		serialPort=>0,
		osDeviceName => $osDeviceName
	};
	bless  $comObj, $packageName;
	$comObj->{serialPort} = ...
	&threads::shared::share ({$comObj});

	...

	$comObj->{$watchThread} = create threads \&watchDevice, $comObj, <termination char>
	...
	return $comObj

sub watchDevice {
	my ($comObj, $terminationChar) = @_;
	while ($comObj->{running}) {
		# check serial device
		$comObj->{serialPort}->...
		sleep 1;
	};
	print "thread finished(",$comObj,")\n";
}


My questions:

1) Has anybody a idea to solve it with threads (or heard of similar serial
communication needs) ?

2) Is there another approach to do parallel processing (win32 and linux) ?

3) Any other thoughts, hints, code snips, .... :)

Thanks in advance
Alexander



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

Date: Mon, 31 Mar 2003 15:41:53 GMT
From: Daniel Pfeiffer <occitan@esperanto.org>
Subject: make.pl 0.4 released
Message-Id: <14ba6a68bbe8b59e5b59f91a6e733d5e@news.teranews.com>

Here comes a make in everybody's favourite programming language, Perl, giving you the best of both worlds. You can use it to write a plain makefile, though in Perl syntax. Or, at the other extreme, you can write a program, that among others does a few file-dependency driven things.

New in this version:

- Function io now allows chaining redirections, e.g. for pipelines.
- Function command replaced by directive use command.
- Replaced --keep-going/keep_going by --ignore-errors/ignore_errors, matching GNU make
- When you ignore errors, failing commands now consistently return undef.
- New options --keep-going, --no-builtin-commands, --no-builtin-rules and --no-builtin-variables, matching GNU make

http://dapfy.bei.t-online.de/make.pl/
http://www.cpan.org/scripts/

coralament / best Grötens / liebe Grüße / best regards / elkorajn salutojn
Daniel Pfeiffer

-- GPL 3: take the wind out of Palladium's sails! --
 ------
  -- My other stuff here too, sawfish, make.pl...: --
   ------
    -- http://dapfy.bei.t-online.de/ --




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

Date: Mon, 31 Mar 2003 16:07:19 GMT
From: "BSK" <mooncm.lbkejwiAhEgSfSe@dAcEbSaS>
Subject: Re: MSWin32 Active State Perl Question
Message-Id: <XIZha.1449$4P1.128377@newsread2.prod.itd.earthlink.net>

Rob,

Thanks for your help.  I'm new to Win32 Perl, so I'm wondering if the
Term::Readkey you mentioned is just a simple matter of downloading it from
CPAN-- or do I have to be careful to make sure that it is compatible with
Win32?  I suspect that there is a UNIX and a Win32 version.  Forgive me, I
should have checked out CPAN before writing this email, but is it possible
to get Win32 Perl stuff from CPAN in the first place?

Thanks.

BSK
[For AntiSpam: Email address is spelled
backwards.  Remove every other letter
starting with 'a' in 'SaS'.]



"Sisyphus" <kalinabears@hdc.com.au> wrote in message
news:3e882f17$0$14872@echo-01.iinet.net.au...
>
> "BSK" <mooncm.lbkejwiAhEgSfSe@dAcEbSaS> wrote in message
> news:4fSha.1071$4P1.86820@newsread2.prod.itd.earthlink.net...
> > Hello All,
> >
> > I am trying to put together some Perl code that will timeout after
waiting
> > so many seconds for input from STDIN.  That is, after waiting so many
> > seconds for the user to supply input by way of STDIN, if the user does
not
> > supply anything then the code just continues on executing by assuming
some
> > default values that would have otherwise been provided by the user.  I
am
> > trying to do this with Active State Perl (Version 5.008) on an MSWin32
> > system (WindowsNT4.0sp6a to be exact).
>
> alarm() doesn't work with STDIN (as you suspected) on Win32, at least.
> Calling for input via the keyboard blocks the alarm signal until the
'enter'
> key is pressed.
>
> Instead, consider using alarm() with Term::Readkey.
> Here's some very simple code which should (I hope) give you the general
> idea. See 'perldoc Term::Readkey' once you've installed the module for a
> proper appreciation of how to use this module.
>
>  use Term::ReadKey;
>  use strict;
>  use warnings;
>
>  my $key;
>  $SIG{ALRM} = sub {die "timeout"};
>
>  eval {
>  alarm(3);
>  while(!defined($key = ReadKey(-1))){}
>  };
>
>  if($@ =~ /timeout/) {print "Nothing entered within the 3 seconds"}
>
>  elsif($@) {die "$@"}
>
>  else {print "INPUT => $key\n"}
>
> Cheers,
> Rob
>
>
>




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

Date: 31 Mar 2003 08:19:25 -0800
From: david@tvis.co.uk (zzapper)
Subject: Perl Debugger : ptkdb
Message-Id: <f677762.0303310819.55bcff9d@posting.google.com>

Hi Perlies

I'm just getting used to ptkdb which amongst another things can
display the contents of an array of hashes just by hovering the mouse
over it.

Download from  V1.108 http://world.std.com/~aep/ptkdb/

But I'm a little concerned that no seems to be updating it; since 01
Oct 2000

 . I also can't much info on how to use it.

Does anyone know the situation?

zzapper
--

vim -c ":%s/^/WhfgTNabgureRIvzSUnpxre/|:%s/[R-T]/ /Ig|:normal ggVGg?"

http://www.vim.org/tips/tip.php?tip_id=305  Best of Vim Tips


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

Date: Mon, 31 Mar 2003 09:01:41 -0600
From: "Kermit T Tensmeyer" <kermit.tensmeyer@ti.com>
Subject: Re: Perl doing server builds/LDAP/IMAP/DNS/Bind/Sendmail
Message-Id: <b69l8n$32u$1@tilde.itg.ti.com>


"Leon Roberts" <nikkirob-7spams@nospamzar.com.au> wrote in message
news:3e8056c5_1@bn.ar.com.au...
> I have joined an ISP as a junior Perl programmer. "Junior" in the sense
> that I know Perl quite well, but it will be used heavily in a Unix admin
> environment, which is rather outside my experience at the moment.
>
> I'm wondering whether there's one or two books which may cover my needs,
> or a particularly suitable reference on the internet.
>
> This ISP is big on doing
> - 'automatic server builds'
> - using huge Perl hashes to store config information (stored with Tied
>     variables, I think)
> - protocols like IMAP, LDAP, SMTP

> I've seen some thick O'Reilly books for Sendmail, and for DNS/BIND, and
> others publishers' books for LDAP. And of course there's many references
> to each of these, separately, on the internet.

  There is also an OReilly book on "Perl for Sysadmin's"
http://www.oreilly.com/catalog/perlsysadm/

 besides building systems in a consistant fashion, perl would also assist
one in detecting that there is
in fact errors in some log file.

 The point of being a lazy sysadmin, is to find ways to avoid repetious
donkey work. Scripts are
-the- method of substituing what a computer can do, for what I could do.
Some scripts work
better in perl, than say ksh, bash  (or  ..shudder... TCL, but I digress..)

 much of the content of the above book has been improved upon, and should
you desire to use
priorly developed code. (hey it wasn't invented here..)  besure to use
cpan.perl.org or better
yet try a mirror.  (things are much closer to you in a mirror..)


begin 666 oreilly.com -- Online Catalog- Perl for System Administration.URL
M6TEN=&5R;F5T4VAO<G1C=71=#0I54DP]:'1T<#HO+W=W=RYO<F5I;&QY+F-O
8;2]C871A;&]G+W!E<FQS>7-A9&TO#0H`
`
end



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

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


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