[22571] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4792 Volume: 10

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

Date: Mon, 31 Mar 2003 06:05:08 -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: 4792

Today's topics:
    Re: array keys for hashes (Interesting) <fxn@hashref.com>
    Re: CGI.pm or roll-your-own? <me@privacy.net>
    Re: CGI.pm or roll-your-own? (Helgi Briem)
    Re: CGI.pm or roll-your-own? (Helgi Briem)
    Re: CGI.pm or roll-your-own? (Helgi Briem)
    Re: CGI.pm or roll-your-own? <tore@aursand.no>
    Re: CGI.pm or roll-your-own? <flavell@mail.cern.ch>
    Re: CGI.pm or roll-your-own? <noreply@gunnar.cc>
    Re: DBD-ODBC <somewhere@nowhere.com>
    Re: DBI problem <somewhere@nowhere.com>
        modules using modules - shared objects <nwzmattXX@XXnetscape.net>
    Re: modules using modules - shared objects <tassilo.parseval@rwth-aachen.de>
    Re: MSWin32 Active State Perl Question <kalinabears@hdc.com.au>
    Re: Multiple POSTS and GETS from one perl script <tore@aursand.no>
    Re: Multiple POSTS and GETS from one perl script <meanblue@rascalsdesign.biz>
    Re: pattern matching (Helgi Briem)
    Re: Perl modules. (Helgi Briem)
    Re: seemingly simple problem <abigail@abigail.nl>
        slow file access under windows (Michael Bickel)
        sort array of structs <vervoom@hotmail.com>
        sort array of structs <vervoom@hotmail.com>
    Re: sort array of structs <vervoom@hotmail.com>
    Re: sort array of structs <tore@aursand.no>
        Statistics for comp.lang.perl.misc <gbacon@cs.uah.edu>
    Re: suid not working <root@localhost.spam.me.not>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 31 Mar 2003 09:42:17 +0000 (UTC)
From: Xavier Noria <fxn@hashref.com>
Subject: Re: array keys for hashes (Interesting)
Message-Id: <b692hp$4j0$1@news.ya.com>

In article <rPOha.71354$Y47.245195@weber.videotron.net>, Frank Rudzicz wrote:

: If I create a hash with anonymous arrays as keys, as in:
: 
: %hash{($a,$b,$c)} = $value;

Cough, cough, besides what others have already said Hash::MultiKey could be
of interest too.

-- fxn


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

Date: Mon, 31 Mar 2003 19:03:11 +1000
From: "Tintin" <me@privacy.net>
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <b6908g$2rmv8$1@ID-172104.news.dfncis.de>


"Greg Raven" <raven@corax.org> wrote in message
news:raven-5591E8.16163130032003@netnews.attbi.com...
> In article <x7of3swky4.fsf@mail.sysarch.com>,
>  Uri Guttman <uri@stemsystems.com> wrote:
>
> >   GR> Thanks for the offer, but what i was looking for was something
> >   GR> along the lines of cgi-lib.pl, the latest version of which works
> >   GR> perfectly for me.
> >
> > have you even followed this thread at all? that library is not supported
> > anymore, it doesn't have all the security stuff that cgi.pm has and it
> > has a very poor interface for multivalued widgets. so why are you using
> > it?
>
> I've tried to follow the thread. I understand that there may be security
> issues, but that's pretty abstract for a beginner. As for the library
> not being supported, as long as it runs as expected, I don't see the
> problem. More beginner myopia, no doubt.

The problem with unsupported software is that serious problems don't get
fixed.




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

Date: Mon, 31 Mar 2003 10:01:47 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <3e88105b.191227420@news.cis.dfn.de>

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?  

Have you studied every line of source code for
your operating system in enough detail to be
comfortable with it?

Have you read and studied the source code for
every application you use in sufficient detail
to be comfortable with it?

Have you studied in detail the metallurgical
properties of your car doors to be comfortable
that they are able to protect you in a crash?

Have you analysed the chemical details of the
air you breath to make sure it is safe?

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

- 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.
-- 
Regards, Helgi Briem
helgi DOT briem AT decode DOT is


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

Date: Mon, 31 Mar 2003 10:09:10 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <3e881393.192051035@news.cis.dfn.de>

On 28 Mar 2003 17:05:45 -0500,
ray@soyokaze.biosci.ohio-state.edu (William C. Ray) wrote:

>I agree that John's cautioning readers that CGI.pm might be more
>complex than they're going to be comfortable with, is not the
>right way to put things, but I don't agree that it's the place
>of OS topics survey books to teach formal, production-grade
>programming topics. 

*Using* CGI.pm is dead simple.  

*Writing* CGI.om is very complex.

*Big* difference, dude.
-- 
Regards, Helgi Briem
helgi DOT briem AT decode DOT is


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

Date: Mon, 31 Mar 2003 10:13:29 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <3e881495.192309326@news.cis.dfn.de>

On Mon, 31 Mar 2003 00:16:32 GMT, Greg Raven
<raven@corax.org> wrote:

>In article <x7of3swky4.fsf@mail.sysarch.com>,
> Uri Guttman <uri@stemsystems.com> wrote:
>
>>   GR> Thanks for the offer, but what i was looking for was something
>>   GR> along the lines of cgi-lib.pl, the latest version of which works
>>   GR> perfectly for me.
>> 
>> have you even followed this thread at all? that library is not supported
>> anymore, it doesn't have all the security stuff that cgi.pm has and it
>> has a very poor interface for multivalued widgets. so why are you using
>> it?
>
>I've tried to follow the thread. I understand that there may be security 
>issues, but that's pretty abstract for a beginner. As for the library 
>not being supported, as long as it runs as expected, I don't see the 
>problem. More beginner myopia, no doubt.

It's not abstract if some script kiddie nukes your website,
steals your password and sends a bomb threat in your
name to the FBI.  Security affects us all.
-- 
Regards, Helgi Briem
helgi DOT briem AT decode DOT is


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

Date: Mon, 31 Mar 2003 13:30:38 +0200
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <pan.2003.03.31.10.49.13.538122@aursand.no>

On Mon, 31 Mar 2003 08:58:38 +0200, Gunnar Hjalmarsson wrote:
>>> After all, checking $ENV{'CONTENT_LENGTH'} directly isn't appreciably
>>> harder, is it?

>> It is.  Updating this in _one module_ is still much better than
>> updating in thousands of scripts.

> It just struck me...  You are talking about editing CGI.pm [...]

No!  I'm talking about the CGI.pm module in general.  In fact, all use of
modules in general.

> while I was comparing checking the env variable directly with setting
> the $CGI::POST_MAX variable in the programs that use CGI. I have never
> had root access to a web server, so the other option didn't cross my
> mind.

Do you have to be root to edit CGI.pm?  No.  Do you need to be root to
install CGI modules?  No.  What's your problem, really?

I'm about to give up.  I'm getting more and more convinced that you're
trolling, as you still don't seem to get the idea.

But!  Go ahead!  Reinvent the wheel as much as you like in production
code.  Sooner or later (most certainly sooner) it'll bite back at you.

*sigh*


-- 
Tore Aursand


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

Date: Mon, 31 Mar 2003 13:51:06 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <Pine.LNX.4.53.0303311347140.6245@lxplus010.cern.ch>

On Mon, Mar 31, Tintin inscribed on the eternal scroll:

> The problem with unsupported software is that serious problems don't get
> fixed.

Or, the unsupported original forks out into numerous break-out
versions in which one or other of the bugs are hacked by different
people, but never quite merged back into the original.  Which can be
worse in the end, because scattered around the net one finds numerous
differently-half-fixed versions: someone coming fresh to the field
never quite knows where to start.


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

Date: Mon, 31 Mar 2003 15:50:12 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: CGI.pm or roll-your-own?
Message-Id: <b69h4s$2vpgo$1@ID-184292.news.dfncis.de>

Tore Aursand wrote:
> On Mon, 31 Mar 2003 08:58:38 +0200, Gunnar Hjalmarsson wrote:
> 
>>>> After all, checking $ENV{'CONTENT_LENGTH'} directly isn't
>>>> appreciably harder, is it?
> 
>>> It is.  Updating this in _one module_ is still much better than
>>> updating in thousands of scripts.
> 
>> It just struck me...  You are talking about editing CGI.pm [...]
> 
> No!  I'm talking about the CGI.pm module in general.  In fact, all
> use of modules in general.
> 
>> while I was comparing checking the env variable directly with
>> setting the $CGI::POST_MAX variable in the programs that use CGI.
>> I have never had root access to a web server, so the other option
>> didn't cross my mind.
> 
> Do you have to be root to edit CGI.pm?  No.  Do you need to be root
> to install CGI modules?  No.  What's your problem, really?
> 
> I'm about to give up.  I'm getting more and more convinced that
> you're trolling, as you still don't seem to get the idea.
> 
> But!  Go ahead!  Reinvent the wheel as much as you like in
> production code.  Sooner or later (most certainly sooner) it'll
> bite back at you.
> 
> *sigh*

That attack was totally uncalled for, Tore.

You mentioned CGI.pm's implementation of limited protection against
DoS attacks as an example where you don't need to edit the programs
that use CGI in order to benefit from improvements of the module. When
I checked it out, I found that this protection is *not* activated by
default, but you must set one or two variables, either in the programs
that use CGI, or in CGI.pm itself.

In an effort to understand what you were saying, it struck me that you
must have been talking about editing CGI.pm. And now you say that
that's not what you were talking about...?

As you well know, I *am* listening to the advise from the experienced
people in this group, and *despite* the unnecessarily aggressive way
you often make your points with respect to CGI.pm, you have made me
take my first steps in using it.

/ Gunnar

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



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

Date: Mon, 31 Mar 2003 09:17:56 +0100
From: "Bigus" <somewhere@nowhere.com>
Subject: Re: DBD-ODBC
Message-Id: <b68tjp$ile@newton.cc.rl.ac.uk>

Randy Kobes wrote:
> "Bigus" <bigus NO @ SPAM creationfactor .net> wrote in
>   message news:Eh1ha.179$Qt4.21@newsfep4-winn.server.ntli.net...
>
>> I'm on a Win2k box with ActiveState Perl 5.8. I can't find DBD-ODBC
>> when I search via PPM.
> [ .. ]
> We have a copy in our repository at
>    http://theoryx5.uwinnipeg.ca/ppms/
> which you can access by setting the repository within the ppm shell to
>   http://theoryx5.uwinnipeg.ca/cgi-bin/ppmserver?urn:/PPMServer58

Thanks.. I downgraded to 5.6 in the end, but have noted the URL for when I
go back again :)

Bigus




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

Date: Mon, 31 Mar 2003 09:48:55 +0100
From: "Bigus" <somewhere@nowhere.com>
Subject: Re: DBI problem
Message-Id: <b68vdn$13p2@newton.cc.rl.ac.uk>

Benjamin Goldberg wrote:
[..]
>> Unless I give each "lock" file a unique name, like "lock-1234.txt",
>> "lock-3456", etc using a number randomly generated. Then when an
>> instance of the script comes to performing a write task on the DB, it
>> can check all files "lock-". In each file there could be a time stamp
>> and the name of the table requiring locking (there is a table per
>> newsgroup amd about 5 newsgroups). If the instance wants to amend a
>> "locked" table it first of all checks the elapsed time between the
>> timestamp in the file and present. If this is greater than the
>> timeout length of the web server, then it assumes the lock file
>> hasn't been deleted properly by a previous instance of the CGI and
>> deletes it, and carries on with updating the DB. Otherwise it loops
>> or sleep/loops until the lock is freed.
>
> You're making things more and more and more complicated.  And there's
> probably still a race condition in the scheme you've outlined.

Huh, it sounded quite clever to me at the time.. well, anyway, I have a
black-belt in making things more complicated than they need to be ;-)

> I would suggest you try and find some actual, pre-made, locking
> scheme, and not try to roll your own.

You've given me plenty of food for thought on ways of lessening the need for
locking, so maybe I can avoid it :-)

[..]
>> Yuk.. that sounds a bit messy on the part of DBI if you have to start
>> worrying about what length the string in a column in a record that
>> you are trying to retrieve is. There are numerous circumstances
>> where you might need to collect data of varying length and since a
>> text field in Access can only hold 255 chars, it is presumably quite
>> common to need to use a memo field.
>
> It's not DBI's fault.  It's just how databases (including Access)
> handle memo fields.

Hmmm.. Win32::ODBC didn't have any problems with it, unless it has a similar
setting to the $dbh->{LongReadLen} one but with a higher default value that
I just hadn't stepped over.

[..]
>> So, in the DBI scheme of things,
>> if I were to set $dbh->{LongReadLen} to say 2k, would that be quite
>> feasible?
>
> If that's longer than the longest 'refs' field, then yes.
>
> Of course, there's an even easier way -- don't fetch the 'refs' field
> unless you need it!  In the code you posted, you weren't even using
> it, and were only examining the 'article' field.  If you'd written
> your query as "SELECT article from $groupdb", you wouldn't be running
> into this trouble.

Good point! I'm going to rewrite several parts of the program tonight with
that and your previous suggestions in mind. Thanks for your patience and
invaluable help, even if it did turn out to be more a lesson in SQL/DB
design than Perl :)

Bigus




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

Date: Mon, 31 Mar 2003 09:24:56 GMT
From: Matt <nwzmattXX@XXnetscape.net>
Subject: modules using modules - shared objects
Message-Id: <uwuigjbmx.fsf@XXnetscape.net>


I have been playing around with writing a module. I was suprised to
find that I can use a module from within my module, and return an
object ref from the other module with all of its methods.

Ok, now let me explain what I mean. Take this code:

### Test Module ####

use strict;
package test;
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw(newDBH selectSomething);
our @EXPORT_OK = qw();
our $VERSION = 1.00;

use DBI;

my $dbh;
sub newDBH {

    $dbh = DBI->connect("DBI:mysqlPP:test:localhost",
			"root",
			"") or die $!;
    return $dbh;
}

sub selectSomething {

 my $value = 
     ($dbh->selectrow_array("select something from nothing"))[0];
 return $value;
}
1;
####################

### Test script ####

use strict;
use warnings;
use test;

my $dbh = newDBH();

my $stuff = 
    ($dbh->selectrow_array("select something from nothing"))[0]; 
print 
    $stuff,
    "\n", 
    selectSomething();

####################

The script works. The output is:

hello
hello

("hello" is the value of `something' in the first row of the table `nothing'). 

Ok, now obviously I am able to use all of the methods exported from
DBI in my script. How/why is this. I have not been able to find
documentation that has completely made me understand how this
works. Also, as you see, I declare both the $dbh variable in the
module and in the script with my(). In the script, I am getting the
object ref from the return value of a function in my module, so they
are both pointing to the same object, right? And when I call
selectSomething(), it is using this same object right?

I just need a little help understanding how this is all
working. Thanks in advance.

Matt
-- 
Remove the X's to reply directly.


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

Date: 31 Mar 2003 10:30:57 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: modules using modules - shared objects
Message-Id: <b695d1$kh5$1@nets3.rz.RWTH-Aachen.DE>

Subject: Re: modules using modules - shared objects

The subject is a little misleading. When I hear "shared object" I think
of .so files (the Linux equivalent of a dll). 

Also sprach Matt:

> I have been playing around with writing a module. I was suprised to
> find that I can use a module from within my module, and return an
> object ref from the other module with all of its methods.
> 
> Ok, now let me explain what I mean. Take this code:
> 
> ### Test Module ####
> 
> use strict;
> package test;
> require Exporter;
> our @ISA = qw(Exporter);
> our @EXPORT = qw(newDBH selectSomething);
> our @EXPORT_OK = qw();
> our $VERSION = 1.00;
> 
> use DBI;
> 
> my $dbh;
> sub newDBH {
> 
>     $dbh = DBI->connect("DBI:mysqlPP:test:localhost",
> 			"root",
> 			"") or die $!;
>     return $dbh;
> }

You are returning an object here, keep this in mind for later.

> sub selectSomething {
> 
>  my $value = 
>      ($dbh->selectrow_array("select something from nothing"))[0];
>  return $value;
> }
> 1;
> ####################
> 
> ### Test script ####
> 
> use strict;
> use warnings;
> use test;
> 
> my $dbh = newDBH();
> 
> my $stuff = 
>     ($dbh->selectrow_array("select something from nothing"))[0]; 
> print 
>     $stuff,
>     "\n", 
>     selectSomething();
> 
> ####################
> 
> The script works. The output is:
> 
> hello
> hello
> 
> ("hello" is the value of `something' in the first row of the table `nothing'). 
> Ok, now obviously I am able to use all of the methods exported from
> DBI in my script. How/why is this. I have not been able to find
> documentation that has completely made me understand how this
> works. 

Not quite. You are calling methods on the object previously returned. An
object is something that combines data, a namespace and a couple of
functions (methods in this context). There is no exporting involved
really. When you do:

    $obj->method(@args);

perl finds out the class to which $obj belongs and does roughly this:

    CLASS_OF_OBJ::method($obj, @args);

Of course, what perl does is more complicated especially when
inheritance etc. is involved.

> Also, as you see, I declare both the $dbh variable in the
> module and in the script with my(). In the script, I am getting the
> object ref from the return value of a function in my module, so they
> are both pointing to the same object, right? And when I call
> selectSomething(), it is using this same object right?

Yes, you are. What you have (unknowingly perhaps) created here is a sort
of closure: A function that "closes over" attached data ($dbh in this
case) so that it always has access to this variable later. Like this:

    {   my $var;
        sub get_var { $var }
        sub set_var { $var = shift }
    }
    set_var("foobar");
    print get_var();

The only way to get to $var is by calling the two functions get_var()
and set_var(). Since you used a my()ed variable in your little module,
you can't directly access $dbh from the outside. Only functions that
live in the same scope (like selectSomething()) can.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Mon, 31 Mar 2003 22:01:56 +1000
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: MSWin32 Active State Perl Question
Message-Id: <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: Mon, 31 Mar 2003 13:30:38 +0200
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: Multiple POSTS and GETS from one perl script
Message-Id: <pan.2003.03.31.10.55.21.208748@aursand.no>

On Mon, 31 Mar 2003 08:29:41 +0100, Meanblue wrote:
> I have no script of my own that I need to perform this arrangement,
> however I am working with a payment gateway that posts data to a POST
> URL as well as forwarding users to a GET URL.

This seems like a design flaw?  Why can't you have _one_ script doing all
this work?  Have a look at this pseudo-like code;

  #!/usr/bin/perl
  #
  use strict;
  use warnings;
  use CGI qw(:cgi);

  # Create the CGI object
  my $cgi = CGI->new();

  # Fetch a lot of CGI parameters
  my $save = ( defined $cgi->param('save') ) ? 1 : 0; # Save?

  # Find out what to do
  if ( $save ) {
      # Security checks etc.
      if ( $ok_to_save ) {
          # Save to the database
      }
      else {
          # Return to the form with error messages displayed
      }
  else {
      # Show the form
  }

Something like this.

> I run an online community site and each movement within the site
> requires different database entries to be altered, [...]

Do you have examples on the different database entries?  Aren't you using
the same database layout for each community?


-- 
Tore Aursand


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

Date: Mon, 31 Mar 2003 12:31:47 +0100
From: Meanblue <meanblue@rascalsdesign.biz>
Subject: Re: Multiple POSTS and GETS from one perl script
Message-Id: <6n9g8vo2ee8pej5sf31dk5n34c13tk7d2o@4ax.com>

On Mon, 31 Mar 2003 13:30:38 +0200, "Tore Aursand" <tore@aursand.no>
wrote:

>On Mon, 31 Mar 2003 08:29:41 +0100, Meanblue wrote:
>> I have no script of my own that I need to perform this arrangement,
>> however I am working with a payment gateway that posts data to a POST
>> URL as well as forwarding users to a GET URL.
>
>This seems like a design flaw?  Why can't you have _one_ script doing all
>this work?  Have a look at this pseudo-like code;
>
>  #!/usr/bin/perl
>  #
>  use strict;
>  use warnings;
>  use CGI qw(:cgi);
>
>  # Create the CGI object
>  my $cgi = CGI->new();
>
>  # Fetch a lot of CGI parameters
>  my $save = ( defined $cgi->param('save') ) ? 1 : 0; # Save?
>
>  # Find out what to do
>  if ( $save ) {
>      # Security checks etc.
>      if ( $ok_to_save ) {
>          # Save to the database
>      }
>      else {
>          # Return to the form with error messages displayed
>      }
>  else {
>      # Show the form
>  }
>
>Something like this.
>
>> I run an online community site and each movement within the site
>> requires different database entries to be altered, [...]
>
>Do you have examples on the different database entries?  Aren't you using
>the same database layout for each community?

This is no design flaw - merely me looking at different ways of doing
the same thing. - I am curious :)




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

Date: Mon, 31 Mar 2003 11:14:50 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: pattern matching
Message-Id: <3e882212.195762712@news.cis.dfn.de>

On Sat, 29 Mar 2003 03:54:46 +0000 (UTC), Vlad Tepes
<minceme@start.no> wrote:

>>>Why don't you read the docs?
>
>Helgi> Now, the perlop page is pretty big, 31 pages or so,
>Helgi> with one hell of a lot of sections and no convenient
>Helgi> way to search [...]
>
>If you prefer reading html (with a table of contents at the top), make
>a file like this

Don't worry about me, I know perldoc perlop pretty
well. On the other hand, I think its structure could
be better and there should be a way to search the docs
for reserved words other than functions.

For example, just as you can do perldoc -f split
to find out about split, you should be able to
do perldoc -f tr or perldoc -f for or perldoc -f "
to find out how to use the transliteration operator,
construct a for loop and use double quotes.

I wouldn't mind if a switch other than -f were used
if people want to be pedantic about operators vs
functions.  It could be added to the FAQ so you
could use the -q switch, for example.

-- 
Regards, Helgi Briem
helgi DOT briem AT decode DOT is


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

Date: Mon, 31 Mar 2003 10:15:09 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Perl modules.
Message-Id: <3e8814e2.192385936@news.cis.dfn.de>

On Fri, 28 Mar 2003 16:06:39 GMT, "Jürgen Exner"
<jurgenex@hotmail.com> wrote:

>Phil Latio wrote:
>> "Helgi Briem" <helgi@decode.is> wrote in message
>> I don't have Perl on this Windows PC, only on my Linux server.
>
>Then for your own and other peoples sake install it.
>I don't understand how someone would insist on developing software in the
>most complicated way by not being able to consult the documentation or even
>to run a simple syntax check on his developement computer.
>It's like boxing with both your hands tied behind your back.

Just to be absolutely clear, I didn't write that.

I do have Perl installed on my desktop machine, my
home computer and the dozens of Linux and Solaris
boxes that I use at work.
-- 
Regards, Helgi Briem
helgi DOT briem AT decode DOT is


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

Date: 31 Mar 2003 09:42:12 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: seemingly simple problem
Message-Id: <slrnb8g3bk.ts6.abigail@alexandra.abigail.nl>

Bill Smith (wksmith@optonline.net) wrote on MMMCDXCIX September MCMXCIII
in <URL:news:L3Qha.815$%U1.373897@news4.srv.hcvlny.cv.net>:
::  
::   s!(/[\w/.]+)!uc($1)!e;

     s!(/[\w/.]+)!\U$1!g;



Abigail
-- 
$_ = "\nrekcaH lreP rehtona tsuJ"; my $chop; $chop = sub {print chop; $chop};
$chop -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()
-> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()


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

Date: 31 Mar 2003 00:49:10 -0800
From: mfb@gmx.net (Michael Bickel)
Subject: slow file access under windows
Message-Id: <7e748eaa.0303310049.7a55f623@posting.google.com>

Hi,
I recognice, that a simple file access is much slower under Windows
(W2K, Perl 5.6.1) than under Unix (AIX). I just check 5 directories if
they exist or not  (with switch and opendir) and it took more than 10
sec.
Also using File::Find (see below) take much longer under Win than
under AIX (Win: 25 sec., AIX <2 sec).
Has anyone suggestions to increase the speed?

find(\&wanted, $INPUTMODEL);
sub wanted {
  if (index(lc($File::Find::name),".model") >= 0) {
    if ($OS eq "intel_a") {
      my $tmp = $File::Find::name;
      $tmp =~ s/\//\\/g;
      print FILE "$tmp\n";
    }
    else {
      print FILE ("$File::Find::name\n");
    }
  }
}

Michael


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

Date: Sun, 30 Mar 2003 11:38:21 +0100
From: vervoom <vervoom@hotmail.com>
Subject: sort array of structs
Message-Id: <b695rr$n8k$1@cspc1n11.baplc.com>

Hi,

I have an array @maillist of Mail structs :

struct Mail =>
     [
         qkey    => 'qidKey',
         msgid   => '$',
         client  => '$',
         from    => '$',
         to      => '@',
         size    => '$',
         month   => '$',
         day     => '$',
         time    => '$',
         localqids => '@'
     ];

struct qidKey =>
     [
         host    => '$',
         qid     => '$',
     ];

which I need to sort on by qkey (the qidKey struct).
I've tried various combinations of sorts eg,

foreach $nmail (sort $mail->qkey->host($a) <=> $mail->qkey->host($b) ) 
@maillist{

but I'm getting nowhere. Would appreciate any help you can give me.

Thanks,

JS.



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

Date: Mon, 31 Mar 2003 13:12:27 +0100
From: vervoom <vervoom@hotmail.com>
Subject: sort array of structs
Message-Id: <b69bcb$jkc$1@cspc1n11.baplc.com>

Hi,

I have an array @maillist of Mail structs :

struct Mail =>
     [
         qkey    => 'qidKey',
         msgid   => '$',
         client  => '$',
         from    => '$',
         to      => '@',
         size    => '$',
         month   => '$',
         day     => '$',
         time    => '$',
         localqids => '@'
     ];

struct qidKey =>
     [
         host    => '$',
         qid     => '$',
     ];

which I need to sort on by qkey (the qidKey struct).
I've tried various combinations of sorts eg,

foreach $nmail (sort $mail->qkey->host($a) <=> $mail->qkey->host($b) ) 
@maillist{

but I'm getting nowhere. Would appreciate any help you can give me.

Thanks,

JS.



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

Date: Mon, 31 Mar 2003 13:38:50 +0100
From: vervoom <vervoom@hotmail.com>
Subject: Re: sort array of structs
Message-Id: <b69ctp$jkm$1@cspc1n11.baplc.com>

vervoom wrote:
> Hi,
> 
> I have an array @maillist of Mail structs :
> 
> struct Mail =>
>     [
>         qkey    => 'qidKey',
>         msgid   => '$',
>         client  => '$',
>         from    => '$',
>         to      => '@',
>         size    => '$',
>         month   => '$',
>         day     => '$',
>         time    => '$',
>         localqids => '@'
>     ];
> 
> struct qidKey =>
>     [
>         host    => '$',
>         qid     => '$',
>     ];
> 
> which I need to sort on by qkey (the qidKey struct).
> I've tried various combinations of sorts eg,
> 
> foreach $nmail (sort $mail->qkey->host($a) <=> $mail->qkey->host($b) ) 
> @maillist{
> 
> but I'm getting nowhere. Would appreciate any help you can give me.
> 
> Thanks,
> 
> JS.
> 

Does this look right?

@maillist=sort {$a->qkey->qid <=> $b->qkey->qid && $a->qkey->host <=> 
$b->qkey->host } @maillist;



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

Date: Mon, 31 Mar 2003 15:28:42 +0200
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: sort array of structs
Message-Id: <pan.2003.03.31.11.57.31.298707@aursand.no>

On Sun, 30 Mar 2003 11:38:21 +0100, vervoom wrote:
> I have an array @maillist of Mail structs :

You mean an array of hashes?  Try 'perldoc -q sort'.


-- 
Tore Aursand


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

Date: Mon, 31 Mar 2003 11:44:50 -0000
From: Greg Bacon <gbacon@cs.uah.edu>
Subject: Statistics for comp.lang.perl.misc
Message-Id: <v8gahip7a163f6@corp.supernews.com>

Following is a summary of articles spanning a 7 day period,
beginning at 24 Mar 2003 11:45:22 GMT and ending at
31 Mar 2003 11:31:47 GMT.

Notes
=====

    - A line in the body of a post is considered to be original if it
      does *not* match the regular expression /^\s{0,3}(?:>|:|\S+>|\+\+)/.
    - All text after the last cut line (/^-- $/) in the body is
      considered to be the author's signature.
    - The scanner prefers the Reply-To: header over the From: header
      in determining the "real" email address and name.
    - Original Content Rating (OCR) is the ratio of the original content
      volume to the total body volume.
    - Find the News-Scan distribution on the CPAN!
      <URL:http://www.perl.com/CPAN/modules/by-module/News/>
    - Please send all comments to Greg Bacon <gbacon@cs.uah.edu>.
    - Copyright (c) 2003 Greg Bacon.
      Verbatim copying and redistribution is permitted without royalty;
      alteration is not permitted.  Redistribution and/or use for any
      commercial purpose is prohibited.

Excluded Posters
================

perlfaq-suggestions\@(?:.*\.)?perl\.com
faq\@(?:.*\.)?denver\.pm\.org
comdog\@panix\.com

Totals
======

Posters:  245
Articles: 817 (372 with cutlined signatures)
Threads:  176
Volume generated: 1628.7 kb
    - headers:    748.7 kb (13,474 lines)
    - bodies:     834.8 kb (26,847 lines)
    - original:   491.2 kb (17,348 lines)
    - signatures: 44.5 kb (1,068 lines)

Original Content Rating: 0.588

Averages
========

Posts per poster: 3.3
    median: 1 post
    mode:   1 post - 124 posters
    s:      5.9 posts
Posts per thread: 4.6
    median: 3.0 posts
    mode:   2 posts - 38 threads
    s:      8.6 posts
Message size: 2041.4 bytes
    - header:     938.3 bytes (16.5 lines)
    - body:       1046.3 bytes (32.9 lines)
    - original:   615.6 bytes (21.2 lines)
    - signature:  55.8 bytes (1.3 lines)

Top 10 Posters by Number of Posts
=================================

         (kb)   (kb)  (kb)  (kb)
Posts  Volume (  hdr/ body/ orig)  Address
-----  --------------------------  -------

   44   109.4 ( 38.3/ 63.6/ 29.2)  Benjamin Goldberg <goldbb2@earthlink.net>
   41    69.8 ( 42.0/ 27.2/ 16.6)  "Tore Aursand" <tore@aursand.no>
   33    69.4 ( 38.4/ 28.9/ 14.4)  Gunnar Hjalmarsson <noreply@gunnar.cc>
   30    90.5 ( 33.8/ 52.8/ 44.7)  tadmc@augustmail.com
   20    52.2 ( 19.6/ 28.1/ 15.3)  tassilo.parseval@post.rwth-aachen.de
   19    34.0 ( 16.3/ 16.6/  9.4)  helgi@decode.is
   18    29.2 ( 13.8/ 15.4/  6.1)  Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>
   14    21.5 ( 13.0/  8.5/  4.0)  "Jürgen Exner" <jurgenex@hotmail.com>
   14    21.7 ( 10.1/ 11.6/  5.8)  "Ami" <amiba128@sd6.so-net.ne.jp>
   13    27.6 ( 12.1/ 13.2/  6.3)  Chris Lowth <please@no.spam>

These posters accounted for 30.1% of all articles.

Top 10 Posters by Volume
========================

  (kb)   (kb)  (kb)  (kb)
Volume (  hdr/ body/ orig)  Posts  Address
--------------------------  -----  -------

 109.4 ( 38.3/ 63.6/ 29.2)     44  Benjamin Goldberg <goldbb2@earthlink.net>
  90.5 ( 33.8/ 52.8/ 44.7)     30  tadmc@augustmail.com
  69.8 ( 42.0/ 27.2/ 16.6)     41  "Tore Aursand" <tore@aursand.no>
  69.4 ( 38.4/ 28.9/ 14.4)     33  Gunnar Hjalmarsson <noreply@gunnar.cc>
  52.2 ( 19.6/ 28.1/ 15.3)     20  tassilo.parseval@post.rwth-aachen.de
  34.0 ( 16.3/ 16.6/  9.4)     19  helgi@decode.is
  31.2 ( 10.3/ 20.9/ 11.2)     11  "Bigus" <bigusNO@SPAMcreationfactor.net>
  29.2 ( 13.8/ 15.4/  6.1)     18  Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>
  27.6 ( 12.1/ 13.2/  6.3)     13  Chris Lowth <please@no.spam>
  26.5 ( 11.5/ 15.0/ 10.4)     10  "Alan J. Flavell" <flavell@mail.cern.ch>

These posters accounted for 33.1% of the total volume.

Top 10 Posters by Volume of Original Content (min. five posts)
==============================================================

        (kb)
Posts   orig  Address
-----  -----  -------

   30   44.7  tadmc@augustmail.com
   44   29.2  Benjamin Goldberg <goldbb2@earthlink.net>
   41   16.6  "Tore Aursand" <tore@aursand.no>
   20   15.3  tassilo.parseval@post.rwth-aachen.de
   33   14.4  Gunnar Hjalmarsson <noreply@gunnar.cc>
   11   11.2  "Bigus" <bigusNO@SPAMcreationfactor.net>
   10   10.4  "Alan J. Flavell" <flavell@mail.cern.ch>
    9   10.0  "Phil Latio" <phil.latio@f-in-stupid.co.uk>
   19    9.4  helgi@decode.is
    6    8.1  chance@austin.rr.com

These posters accounted for 34.4% of the original volume.

Top 10 Posters by OCR (minimum of five posts)
==============================================

         (kb)    (kb)
OCR      orig /  body  Posts  Address
-----  --------------  -----  -------

0.941  (  4.5 /  4.8)      9  istink <istink@real.bad.com>
0.886  (  8.1 /  9.1)      6  chance@austin.rr.com
0.846  ( 44.7 / 52.8)     30  tadmc@augustmail.com
0.843  (  6.9 /  8.1)      5  Eric Osman <ericosman@rcn.com>
0.782  ( 10.0 / 12.8)      9  "Phil Latio" <phil.latio@f-in-stupid.co.uk>
0.716  (  6.1 /  8.5)     12  abigail@abigail.nl
0.693  ( 10.4 / 15.0)     10  "Alan J. Flavell" <flavell@mail.cern.ch>
0.663  (  2.9 /  4.4)      5  pkent <pkent77tea@yahoo.com.tea>
0.656  (  3.3 /  5.0)      5  C Marshall <c_j_marshall@hotmail.com>
0.609  ( 16.6 / 27.2)     41  "Tore Aursand" <tore@aursand.no>

Bottom 10 Posters by OCR (minimum of five posts)
================================================

         (kb)    (kb)
OCR      orig /  body  Posts  Address
-----  --------------  -----  -------

0.424  (  2.3 /  5.3)      5  sholden@cs.usyd.edu.au
0.415  (  2.3 /  5.5)      7  Brian McCauley <nobull@mail.com>
0.395  (  6.1 / 15.4)     18  Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>
0.375  (  3.5 /  9.3)      8  Andrew Newlands <meanblue@rascalsdesign.biz>
0.369  (  2.8 /  7.5)      7  Joe Creaney <mail@annuna.com>
0.367  (  3.7 / 10.1)     11  "Tintin" <me@privacy.net>
0.358  (  0.8 /  2.2)      5  "Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net>
0.343  (  3.5 / 10.1)     13  Uri Guttman <uri@stemsystems.com>
0.224  (  1.3 /  5.9)      5  "Bigus" <somewhere@nowhere.com>
0.217  (  2.0 /  9.3)      8  Michael Budash <mbudash@sonic.net>

40 posters (16%) had at least five posts.

Top 10 Threads by Number of Posts
=================================

Posts  Subject
-----  -------

  103  CGI.pm or roll-your-own?
   24  Perl modules.
   19  And...
   19  pattern matching
   17  Sorting keys in a hash runs slower now.
   16  Multiple POSTS and GETS from one perl script
   15  help understand dereferencing
   13  simple substitution also changes line endings
   12  Simple, but I can't figure it out.
   12  Please tell me I'm beginner

These threads accounted for 30.6% of all articles.

Top 10 Threads by Volume
========================

  (kb)   (kb)  (kb)  (kb)
Volume (  hdr/ body/ orig)  Posts  Subject
--------------------------  -----  -------

 248.5 (120.5/121.2/ 69.0)    103  CGI.pm or roll-your-own?
  49.0 ( 25.2/ 23.1/ 16.5)     24  Perl modules.
  42.9 ( 14.6/ 24.3/ 12.3)     15  help understand dereferencing
  41.0 (  7.2/ 33.2/ 13.4)      8  DBI problem
  33.9 (  1.9/ 32.0/ 32.0)      2  Posting Guidelines for comp.lang.perl.misc ($Revision: 1.4 $)
  33.3 ( 17.9/ 14.5/  7.1)     19  And...
  32.9 ( 15.4/ 17.0/  9.3)     17  Sorting keys in a hash runs slower now.
  32.5 ( 16.9/ 15.4/  6.9)     16  Multiple POSTS and GETS from one perl script
  31.7 ( 11.1/ 19.5/  8.9)     13  simple substitution also changes line endings
  31.5 ( 18.0/ 13.0/  7.7)     19  pattern matching

These threads accounted for 35.4% of the total volume.

Top 10 Threads by OCR (minimum of five posts)
=============================================

         (kb)    (kb)
OCR      orig /  body  Posts  Subject
-----  --------------  -----  -------

0.869  (  3.2/   3.7)      5  match except between...
0.714  ( 16.5/  23.1)     24  Perl modules.
0.711  (  2.6/   3.6)      5  seemingly simple problem
0.709  (  3.5/   4.9)      7  How to use Net::FTP - FTP Client class through a Firewall
0.708  (  3.2/   4.6)      6  sort by columns
0.706  (  1.6/   2.3)      5  Assiging values to parameters in strings
0.647  (  2.2/   3.3)      6  implicit vs explicit variable usage in loop w/ range regexp
0.645  (  3.2/   5.0)      5  Help for Net::FTP and Net::SMTP
0.633  (  3.3/   5.2)      6  @statarray = split /\n/,`dir c:\\seismo\\miniseisnet\\*.station /b`;
0.632  (  3.7/   5.9)      7  Mail::Sender - comma separated email address lists

Bottom 10 Threads by OCR (minimum of five posts)
================================================

         (kb)    (kb)
OCR      orig /  body  Posts  Subject
-----  --------------  -----  -------

0.454  (  8.9 / 19.5)     13  simple substitution also changes line endings
0.449  (  6.9 / 15.4)     16  Multiple POSTS and GETS from one perl script
0.431  (  3.0 /  6.9)      7  doubts on \n
0.418  (  2.7 /  6.4)     11  perl generating bad html
0.403  ( 13.4 / 33.2)      8  DBI problem
0.361  (  0.9 /  2.4)      5  regex question
0.353  (  1.6 /  4.5)      5  Perl ODBC and SQL
0.331  (  0.5 /  1.6)      5  Perl and C++
0.268  (  3.1 / 11.4)      8  Algorithm for Text Subsets
0.163  (  1.4 /  8.6)      7  currency number to text conversion

56 threads (31%) had at least five posts.

Top 10 Targets for Crossposts
=============================

Articles  Newsgroup
--------  ---------

      17  comp.lang.perl
       5  comp.lang.javascript
       5  alt.www.webmaster
       5  comp.lang.perl.modules
       4  fj.comp.lang.perl
       3  comp.text.xml
       2  comp.unix.admin
       2  comp.lang.c++
       2  comp.lang.c
       2  comp.lang.java

Top 10 Crossposters
===================

Articles  Address
--------  -------

       7  "gm" <george_m@bigpond.net.au>
       5  Joona I Palaste <palaste@cc.helsinki.fi>
       3  "Kelly Greer" <kellygreer1@hell.rr.com>
       2  "Tore Aursand" <tore@aursand.no>
       2  Clyde Ellul <cellul@msn.com>
       2  Andy <cabaretfest@yahoo.com>
       2  Ivan Marsh <annoyed@you.now>
       2  "William Tasso" <ngx@tbdata.com>
       2  chance@austin.rr.com
       2  L D Jones <45673&5@yahoo.co.uk>


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

Date: Mon, 31 Mar 2003 12:31:38 GMT
From: "Phil Langerholc" <root@localhost.spam.me.not>
Subject: Re: suid not working
Message-Id: <KyWha.17448$gp1.3702@nwrddc02.gnilink.net>

 > Yes, but what are permissions of 'suidperl'?  If that is not suid root
> > then the perl -U switch is not going to work.  Note from 'perldoc
> > perlsec':
> >
> > Prior to release 5.6.1 of Perl, bugs in the code of suidperl
> > could introduce a security hole

Hmm, seems like suidperl does not ship with the perl compiled for AIX...
I've check on CPAN and I can't find just the suid binary...




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

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


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