[21692] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3896 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 1 21:05:41 2002

Date: Tue, 1 Oct 2002 18:05:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 1 Oct 2002     Volume: 10 Number: 3896

Today's topics:
    Re: A simple form problem!  <jurgenex@hotmail.com>
    Re: A simple form problem!  (Tad McClellan)
    Re: At modem/FTP script? <goldbb2@earthlink.net>
    Re: becoming a better programmer <gilham@snapdragon.csl.sri.com>
    Re: Beginning Perl <grahamland@eircom.net>
    Re: Checking tagged text. <goldbb2@earthlink.net>
    Re: compiling perl on IRIX... <goldbb2@earthlink.net>
    Re: Convert Perl script to C program (and Why was this  <Cptn.Fredo@S.S.No.Spam>
    Re: Counting Instances of @ in a Scalar (David Garde)
    Re: Downloading from a www server: Problem <flavell@mail.cern.ch>
        Extract email address (Barry Krusch)
    Re: Extract email address <brittedg@student.gvsu.edu>
    Re: Extract email address <krahnj@acm.org>
    Re: File::Copy troubleshooting michael.e.grimes@fritolay.com
    Re: File::Copy troubleshooting michael.e.grimes@fritolay.com
    Re: Floating point question <REMOVEsdnCAPS@comcast.net>
    Re: Insecure Dependency <goldbb2@earthlink.net>
    Re: module Vs package (Tad McClellan)
    Re: module Vs package <s_grazzini@hotmail.com>
    Re: Performance burden in modularization ? <goldbb2@earthlink.net>
    Re: Performance burden in modularization ? (Tad McClellan)
        Specifying TAB to -F on the command-line (J Hall)
    Re: Specifying TAB to -F on the command-line <s_grazzini@hotmail.com>
    Re: Specifying TAB to -F on the command-line <krahnj@acm.org>
    Re: stderr redir confirmation <goldbb2@earthlink.net>
    Re: Top posting (was Re: How can I count files in a dir <tom.beer@btfinancialgroup.spamfilter.com>
    Re: Use Java! Was: becoming a better programmer <hibou00000nospam@enterprise.net>
    Re: Which .exe generator? <wyzelli@yahoo.com>
        Why are the columns of a MySQL SELECT scrambled? (James)
    Re: Why are the columns of a MySQL SELECT scrambled? <goldbb2@earthlink.net>
    Re: Why are the columns of a MySQL SELECT scrambled? (Tad McClellan)
    Re: Why is there no CPAN equivalent for C++? <aaron@isotton.com>
    Re: Why is there no CPAN equivalent for C++? <E.Robert.Tisdale@jpl.nasa.gov>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 1 Oct 2002 15:13:09 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: A simple form problem! 
Message-Id: <3d9a1df6$1@news.microsoft.com>

Simon Harvey wrote:
> When the html form submits to script B, how do I get the information
> on which checkboxes have been ticked into the recieving script?. The
> point being I DON'T even know how many checkboxes there are. The only
> way I know how to get form data is if I know the name in advance,
> then I can use the param function in the CGI package. That's nice and
> easy but obviously I cant right 25 param statements to make sure i
> get all the check boxes!
>
> How would you go about handling this sort of situation?

Does this tidbit of information from "perldoc CGI" help?

  FETCHING THE NAMES OF ALL THE PARAMETERS PASSED TO YOUR SCRIPT:

         @names = $query->param

    If the script was invoked with a parameter list (e.g.
    "name1=value1&name2=value2&name3=value3"), the param() method will
    return the parameter names as a list. [...]


jue




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

Date: Tue, 01 Oct 2002 22:20:43 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: A simple form problem! 
Message-Id: <slrnapk72p.2d8.tadmc@magna.augustmail.com>

Simon Harvey <ReplyToGroup@thanks.com> wrote:

> When the html form submits to script B, how do I get the information on
> which checkboxes have been ticked into the recieving script?.

> obviously I cant
> right 25 param statements to make sure i get all the check boxes!
> 
> How would you go about handling this sort of situation?


By reading the documentation that came with the software I'm using.  :-)


> I
> cant find anything like that


Where did you look?

   perldoc CGI

-------------------------------
=head2 FETCHING THE VALUE OR VALUES OF A SINGLE NAMED PARAMETER:

    @values = $query->param('foo');

              -or-

    $value = $query->param('foo');

Pass the param() method a single argument to fetch the value of the
named parameter. If the parameter is multivalued (e.g. from multiple
selections in a scrolling list), you can ask to receive an array.  Otherwise
the method will return a single value.
-------------------------------


Ask to receive an array.


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


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

Date: Tue, 01 Oct 2002 18:59:06 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: At modem/FTP script?
Message-Id: <3D9A28BA.D4A1E3DC@earthlink.net>

Marcin Mankowski wrote:
[snip]
> Do you know (or someone) which system() commands could be used
> on Windows? Or maybe some good documentation or samples?

AFAIK, There is no *command* to do this on Windows, you have to use an
appropriate dll -- The Win32::API module will help you load the dll and
call the function in it.  However, *which* dll, and which function to
use, are Windows questions, not perl questions.

-- 
How many Monks would a Chipmonk chip,
if a Chipmonk could chip Monks?


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

Date: 01 Oct 2002 17:51:23 -0700
From: Fred Gilham <gilham@snapdragon.csl.sri.com>
Subject: Re: becoming a better programmer
Message-Id: <u7d6qtu0hg.fsf@snapdragon.csl.sri.com>


> Actually it is there under C for Common Lisp
> 
> http://99-bottles-of-beer.ls-la.net/c.html#Common-Lisp-(format-string)

Lisp is particularly appropriate for this particular application
because of the bottoms-up programming style [1] that it encourages.  I
was very pleased to see the Lisp community rise to the occasion.


[1]The concept of bottoms-up programming was first formally described
in a public forum by the author during an AI Seminar end-of-semester
party held at Stanford University in 1989. :-)
-- 
Fred Gilham                                      gilham@csl.sri.com
Ah, the 20th century, when the flight from reason crash-landed into
the slaughterhouse.  --- James Ostrowski


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

Date: Wed, 2 Oct 2002 01:40:48 +0100
From: "Gyzmo" <grahamland@eircom.net>
Subject: Re: Beginning Perl
Message-Id: <pgrm9.18962$zX3.50771@news.indigo.ie>

Cheers Guys, Much appreciated!
"Gyzmo" <grahamland@eircom.net> wrote in message
news:hmkm9.18865$zX3.50537@news.indigo.ie...
> Hi,
>
> I'm looking for advice on getting perl installed on my pc running XP &
> Debian Linux.I'd like to try and teach myself the language in order to
write
> programs for the unix,linux and microsoft environments.
>
> Is there a good Development Environment that you can recommend ?
>
> Thank You,
> Graham.
>
>




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

Date: Tue, 01 Oct 2002 20:08:50 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Checking tagged text.
Message-Id: <3D9A3912.82291BCD@earthlink.net>

Tad McClellan wrote:
[find improperly nested tags]
> ------------------------------
> #!/usr/bin/perl
> use warnings;
> use strict;
> 
> $_ = 'aaa <BOLD>bbbbbb<ITALIC>ccccccc</BOLD> ddddddd</ITALIC>';
> 
> my @stack;
> while ( m#<(/?)([\w.-]+)>#g ) {
>    if ( $1 ) {                   # end tag
>       if ( $stack[-1] eq $2 )    # balanced
>          { pop @stack }
>       else                       # not balanced
>          { warn "unbalanced '$2' tag before character number ", pos, "\n" }
>    }
>    else {                        # start tag
>       push @stack, $2;
>    }
> }
> warn "unbalanced '$stack[-1]' tag at file end\n" if @stack;
> ------------------------------

With a little bit of work, this can be made to show line numbers, too.

my $line = 1;
my @stack;
while( m#(.*?)<(/?)([\w.-]+)(.*?)>#gs ) {
   $line += $1 =~ tr/\n//;
   my $col = $-[3] - rindex( $_, "\n", $+[1] );
   if( $2 ) {
      my $i = -1;
      --$i until -$i > @stack or $stack[$i] eq $3;
      if( -$i > @stack ) {
         warn "Spurious $3 tag at line $line column $col\n";
      } else {
         splice @stack, $i, 1;
         warn "Misplaced closing tag $3 at line $line column $col\n"
            if $i != -1;
      }
   } else {
      push @stack, $3;
   }
   $line += $4 =~ tr/\n//;
}

-- 
How many Monks would a Chipmonk chip,
if a Chipmonk could chip Monks?


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

Date: Tue, 01 Oct 2002 18:44:25 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: compiling perl on IRIX...
Message-Id: <3D9A2549.504BADF9@earthlink.net>

James A. Cubeta wrote:
> 
> Greetings!
> 
> I am having problems trying to compile Perl 5.8.0 on IRIX.

Compilation problems should generally be reported by the 'perlbug'
program, if you have a working perl on your system, or else sent via
mail to the perl5porters mailing list: <perl5-porters@perl.org>.

-- 
How many Monks would a Chipmonk chip,
if a Chipmonk could chip Monks?


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

Date: Tue, 01 Oct 2002 22:27:09 GMT
From: ".Fredo" <Cptn.Fredo@S.S.No.Spam>
Subject: Re: Convert Perl script to C program (and Why was this group's name changed?)
Message-Id: <rhpm9.980$Ry1.113925375@newssvr14.news.prodigy.com>


"Alan J. Flavell" <flavell@mail.cern.ch> wrote in message
news:Pine.LNX.4.40.0210012321240.4865-100000@lxplus074.cern.ch...
>
> On Oct 1, .Fredo replied to Tad:
>
> [far too much for comfort]
>
> > > Do you see any irony there?
> >
> > Not really. In your short little reply, you had little to offer, but
a
> > misleading reply (to the OP mainly). I seemed like just another one
of
> > your rude posts, and you ending here does little persuade otherwise.
>
> I could see this coming.  A well-earned killfile entry.  Please
> don't change your posting address.

As usual you happen to perfectly avoid the issue, that happens spans way
passed what you quoted. Actually you've put a new low on "little to
offer". But then again, you, Tad are saint, rgiht? Sorry I forgot.




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

Date: 1 Oct 2002 16:36:51 -0700
From: david_garde@yahoo.com (David Garde)
Subject: Re: Counting Instances of @ in a Scalar
Message-Id: <ca6180e1.0210011536.26b0ff1@posting.google.com>

Tina Mueller <usenet@tinita.de> wrote in message news:<ancf30$cn630$1@fu-berlin.de>...
> David Garde <david_garde@yahoo.com> wrote:
> > I am very fresh at writing perl and am trying to get a count on the
> > number of @ in a scalar variable.
> 
> my $count = $scalar =~ tr/@//;
> 
> > The code I wrote is:
>  
> > $count = 0;
> > $email = <STDIN>;
> >     while ($email =~ /@/g) {
> >        $count += 1; 
> >        print "$count\n";
> >        exit;
> 
> you are exiting the program here, already after the
> first loop.
> 




Dear Tina,

Thank you for the reply. However the returned value is now one more
than the true value when I use this:

$count = 0;
$email = <STDIN>;
my $count = $email =~ tr/@//;
            $count += 1; 
            print "$count\n";


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

Date: Wed, 2 Oct 2002 00:59:30 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Downloading from a www server: Problem
Message-Id: <Pine.LNX.4.40.0210012243430.4865-100000@lxplus074.cern.ch>

On Oct 1, develop@gistenson.com inscribed on the eternal scroll:

> I have three questions

You don't win any prizes by including them all in the same posting.

> First, I am writing scripts in PERL for a web site and need server-side
> code so that when the user at the client-side clicks on the appropriate
> html link in my server web page, a binary file is downloaded from the
> server to the user's computer.

There doesn't seem to be any obvious logic in what you posted.  Are
you missing out some significant information?  Otherwise your question
seems indistinguishable from generic WWW FAQs such as
http://www.htmlhelp.com/faq/html/media.html#download-howto
without any Perl-specific content.

> Is lwp the best way to do this?

Does your web server need to retrieve the file from a different web
server first?

> Second, where can I find online documentation for lwp?

Comes with the installation, as Tad said.

> Third, what's wrong with the first line of code, below?

Can we have some context?  This appears to be a command-line
invocation, whereas you _said_ you were writing a CGI script.

> Here's the script:

What you're showing is a one-liner (folks - is there a documentation
cite for one-liners?  I'm at a loss to find the spot just now).

And it's not yet a CGI script, because it has no CGI handling in it.

I don't mean to be rude, but you seem to have gotten way ahead of
yourself.  I'd suggest working calmly through some simpler Perl usage
examples first.

But I'm suspecting an XY problem.  You're trying to do something (X)
which you haven't stated very clearly - you concluded that your three
questions (no jokes about troll bridges here) were somehow part of the
solution, but we're having a hard time guessing the question based on
your partial solutions.

So let's have some context, and see how we can make progress.  A move
to the WWW CGI authoring group might become indicated, depending on
what you really want to do.

good luck



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

Date: 1 Oct 2002 16:47:29 -0700
From: bkrusch@yahoo.com (Barry Krusch)
Subject: Extract email address
Message-Id: <c6b407df.0210011547.d00345e@posting.google.com>

Hi, I have a list of statements within parentheses, and I need to
extract everything within parentheses, leaving the rest behind.

The following does not work.  Any idea what I am doing wrong?

+++++++++++++++++

while ((DATA))
{
 
$_ =~ s/(.+)/$1/g;  

 print $_;
}

__DATA__ # PUT DATA HERE
just extract what follows.  (This is the only thing that should show
up)
likewise (pull me out.)

+++++++++++++++++

WHAT SHOULD BE RETURNED
This is the only thing that should show up
pull me out.


Thank you!


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

Date: Tue, 01 Oct 2002 20:51:26 -0400
From: David Britten <brittedg@student.gvsu.edu>
Subject: Re: Extract email address
Message-Id: <B9BFBB4E.4E00%brittedg@student.gvsu.edu>

On 10/1/02 7:47 PM, in article
c6b407df.0210011547.d00345e@posting.google.com, "Barry Krusch"
<bkrusch@yahoo.com> wrote:

> Hi, I have a list of statements within parentheses, and I need to
> extract everything within parentheses, leaving the rest behind.
> 
> The following does not work.  Any idea what I am doing wrong?
> 
> +++++++++++++++++
> 
> while ((DATA))
> {
> 
> $_ =~ s/(.+)/$1/g;
> 
> print $_;
> }
> 
> __DATA__ # PUT DATA HERE
> just extract what follows.  (This is the only thing that should show
> up)
> likewise (pull me out.)
> 
> +++++++++++++++++
> 
> WHAT SHOULD BE RETURNED
> This is the only thing that should show up
> pull me out.
> 
> 
> Thank you!


Try changing your regexp:

$_ =~ s/\((.+)\)/$1/g;

You need to escape the parentheses or they are treated as a grouping symbol.
Then another set must be added around .+ to group it as $1.


-David Britten



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

Date: Wed, 02 Oct 2002 00:52:17 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Extract email address
Message-Id: <3D9A4324.CD21A9B3@acm.org>

Barry Krusch wrote:
> 
> Hi, I have a list of statements within parentheses, and I need to
> extract everything within parentheses, leaving the rest behind.
> 
> The following does not work.  Any idea what I am doing wrong?
> 
> +++++++++++++++++
> 
> while ((DATA))
         ^    ^
If you want to read from a file handle you have to enclose it with <>
characters.
while ( <DATA> )


> {
> 
> $_ =~ s/(.+)/$1/g;

You don't have any literal parentheses in the regular expression and the
match is greedy.

print $1 if /\((.+?)\)/;

Or:

print $1 if /\(([^\)]+)\)/;


>  print $_;
> }
> 
> __DATA__ # PUT DATA HERE
> just extract what follows.  (This is the only thing that should show
> up)
> likewise (pull me out.)



John
-- 
use Perl;
program
fulfillment


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

Date: 1 Oct 2002 22:47:42 GMT
From: michael.e.grimes@fritolay.com
Subject: Re: File::Copy troubleshooting
Message-Id: <and8me$pcb$1@news.netmar.com>

>Yes, simply inspect $!, so adjust your NT_Proc() function (and please,
>also get rid of this ugly ampersand (&). It does more harm than goods.
>
>    ... || NT_Proc(50, "$Start - $ENV{COMPUTERNAME} $0 failed on copy",
>                   "${Period}_50", $!);
>                                   ^^
>                                   ^^
>                        will tell you, what went wrong

Thanks for the advice, I will give it a try-

 -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web  -----
  http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
   NewsOne.Net prohibits users from posting spam.  If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net


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

Date: 1 Oct 2002 22:49:16 GMT
From: michael.e.grimes@fritolay.com
Subject: Re: File::Copy troubleshooting
Message-Id: <and8pc$pdt$1@news.netmar.com>

>
>   perldoc File::Copy
>
>--------------------------------------
>RETURN
>       All functions return 1 on success, 0 on failure.  $! will
>       be set if an error was encountered.
>--------------------------------------
>
>
>Output the $! variable in your diagnostic message.
>
Thanks-

 -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web  -----
  http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
   NewsOne.Net prohibits users from posting spam.  If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net


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

Date: Wed, 02 Oct 2002 00:46:57 GMT
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Floating point question
Message-Id: <Xns929AD3B8FDBA0sdn.comcast@216.166.71.239>

"J" <<A@B>> wrote in news:upjooeq5n8egf0@corp.supernews.com:

> 
> "Tad McClellan" <tadmc@augustmail.com> wrote in message
> news:slrnapjmn1.1nd.tadmc@magna.augustmail.com...
>> J <<A@B> wrote:
>>
>> > Subject: Floating point question
>>
>>
>> Why are you treating the date as a number in the first place?
> 
> I like to use perl to test functions that I am going to write in
> another langauge where integers and string are different data types.

That's really really silly.

-- 
Eric
print scalar reverse sort qw p ekca lre reh 
ts uJ p, $/.r, map $_.$", qw e p h tona e;


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

Date: Tue, 01 Oct 2002 20:26:05 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Insecure Dependency
Message-Id: <3D9A3D1D.381D275@earthlink.net>

Joe Schaefer wrote:
> 
> Joel Konkle-Parker <jjk3@msstate.edu> writes:
> 
> [...]
> 
> > I keep getting "Insecure dependecy" errors. I went through the
> > process of checking the PATH_INFO variable and such, thinking that
> > would fix it, but to no avail.
> >
> > Any suggestions?
> 
> Yes- look again at the actual error message.  IIRC (from an earlier
> post of yours), it said something like
> 
>   "Insecure dependency in eval while running with -T switch at
>   /usr/lib/perl5/site_perl/5.6.1/URI.pm line 116"
> 
> URI.pm looks like this near line 116:
> 
>     no strict 'refs';
>     # check we actually have one for the scheme:
>     unless (@{"${ic}::ISA"}) {
>         # Try to load it
>         eval "require $ic";                 <---- the problem
> 
> The eval is failing because $ic is tainted. $ic is tainted because
> XML::XSLT calls URI->new with a tainted "$scheme" argument.  It's
> tainted because the value comes from, well, where the rest of
> the error message says-
> 
>   ./stylesheets/games.xsl at ...
> 
> If this stylesheet is something you alone control, then you
> could just disable taint checks (your own code is clean), but
> that's not the best solution.

No, it's not.  A better solution would be to mark that *file* as being
untainted.  Well, the filehandle (Using the IO::Handle::untaint method),
but you get the point.  Even this is unsafe.  After all, although you
know data from that file is used *here*, for this require(), you don't
know where *else* it's being used.  You might in the future recieve a
new .xsl file from someone in the mail, being told "try this, it's
cool", and install it without thinking about the consequences, or only
making a trivial check to see that it doesn't do anything evil for this
particular bit of code.

A *much* better solution would be to build a hash of valid schemes to
load, and untaint the variable if and only if it's a member of that
hash.

> I think the community would really
> benefit if you tried fixing the URI.pm source around line 116 so it
> properly untaints $ic, and then sent your patch to the URI.pm
> author.

-- 
How many Monks would a Chipmonk chip,
if a Chipmonk could chip Monks?


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

Date: Tue, 01 Oct 2002 22:59:55 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: module Vs package
Message-Id: <slrnapka2e.2rv.tadmc@magna.augustmail.com>

Sriva <sriva@invalid_nospam.com> wrote:

>     I am trying to figure out why we need BOTH modules and packages in 
> perl.  


So that we can have a package without having a module.

Freedom to do either or both is good.  :-)


> Question_1:  If a main uses 2 different modules, and funcName exists is 
> both modules,  then can those functions still be invoked from main? 
> maybe using module1::funcName()  and module2::funcName()?


Yes, exactly so.

( or:   module1'funcName()   in perl4 )


> Question_2:  If modules are more convenient, than why do we need 
> packages at all?


packages where here in perl 4.

modules were added in perl 5.


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


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

Date: Tue, 01 Oct 2002 23:01:48 GMT
From: Steve Grazzini <s_grazzini@hotmail.com>
Subject: Re: module Vs package
Message-Id: <wPpm9.44333$0H1.6036744@twister.nyc.rr.com>

Sriva <sriva@invalid_nospam.com> wrote:
> I am trying to figure out why we need BOTH modules and packages in 
> perl.  It appears as if the only new feature that a module provides over 
> a package is:
> You have a shorthand notation of accessing the subroutines..  i.e 
> like  funcName(xxx)  rather than package::funcName(xxx).
> 
> Question_1:  If a main uses 2 different modules, and funcName exists is 
> both modules,  then can those functions still be invoked from main? 
> maybe using module1::funcName()  and module2::funcName()?

Try it and see.

The classic example is:

  #!/usr/bin/perl
  use warnings;

  use CGI qw/:standard/;
  use LWP::Simple;

  ...


> Question_2:  If modules are more convenient, than why do we 
> need packages at all?

They're not even close to being equivalent.

In fact, modules are built out of packages (and .pm files, and 
use() and import() and... )

Not sure where to start explaining, other than to point you at:

  $ perldoc perlmod

-- 
Steve

perldoc -qa.j | perl -lpe '($_)=m("(.*)")'


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

Date: Tue, 01 Oct 2002 18:53:33 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Performance burden in modularization ?
Message-Id: <3D9A276D.9C0667BE@earthlink.net>

doofus wrote:
> 
> Hi,
> 
> This is not a pressing issue, but just a passing wonderment. I've
> grown to like using object-oriented style coding in perl which tends
> to result, at least the way I do it, in breaking up a long spiel into
> several modules all of which will require to be read from disk at
> runtime. Is there much of an overhead in reading these modules from
> disk, especially in the CGI context where each request normally
> requires a new instance of interpretation, if you know what I mean. (
> mod_perl excepting, that is ).
> 
> Does that make any sense. What i'm asking is whether there is any
> performance burden in breaking up code into modules, and if so, how
> much concern I ought to give it.

If you only have one script, and when it runs, it *always* loads *all*
of your modules, then it's a bit silly to do it that way.  If you have
multiple scripts, with some shared functionality, and that shared stuff
is put into a module file, then the benefits of using modules outweighs
the minor speed hit of use/require.

Keep in mind, the overhead will be *relatively* low in comparison to the
running of the CGI protocol -- the time needed to fork()/exec() perl is
quite likely to be rather more than perl will need to load up your
modules.

-- 
How many Monks would a Chipmonk chip,
if a Chipmonk could chip Monks?


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

Date: Tue, 01 Oct 2002 22:59:55 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Performance burden in modularization ?
Message-Id: <slrnapk9ff.2rv.tadmc@magna.augustmail.com>

doofus <jim.bloggs@eudoramail.com> wrote:

> This is not a pressing issue, but just a passing wonderment. 

> breaking up a long spiel into
> several modules all of which will require to be read from disk at
> runtime. 
  ^^^^^^^


If they are Real Modules, then they will be read at _compile_ time
via "use", yes?


> Is there much of an overhead in reading these modules from
> disk


The difference is reading a thousand lines from one file vs.
reading a thousand lines spread over several files?

Is that what you're asking about?

If so, then the difference is not worth worrying about.


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


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

Date: 1 Oct 2002 15:38:38 -0700
From: gmnotyet@yahoo.com (J Hall)
Subject: Specifying TAB to -F on the command-line
Message-Id: <ab25f06e.0210011438.6917bf17@posting.google.com>

Dear Perl users,
    Today I had a devil of a time trying to use the perl -F
command-line switch. I wanted to split a TAB-delimited file and tried
all kinds of incantations using -F and \t. No success. I ended up
using awk, which splits each line by space and tabs by default. What
is the correct way to get Perl's command-line switch -F to accept \t?
I am using zsh-4.0.4. Thanks.


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

Date: Tue, 01 Oct 2002 22:47:40 GMT
From: Steve Grazzini <s_grazzini@hotmail.com>
Subject: Re: Specifying TAB to -F on the command-line
Message-Id: <gCpm9.44275$0H1.6028296@twister.nyc.rr.com>

J Hall <gmnotyet@yahoo.com> wrote:
> Today I had a devil of a time trying to use the perl -F
> command-line switch. I wanted to split a TAB-delimited file and tried
> all kinds of incantations using -F and \t. No success. I ended up
> using awk, which splits each line by space and tabs by default. What
> is the correct way to get Perl's command-line switch -F to accept \t?
> I am using zsh-4.0.4. Thanks.

Just leave out the -F.  :)

-- 
Steve

perldoc -qa.j | perl -lpe '($_)=m("(.*)")'


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

Date: Tue, 01 Oct 2002 23:07:15 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Specifying TAB to -F on the command-line
Message-Id: <3D9A2A87.6CA7100C@acm.org>

J Hall wrote:
> 
>     Today I had a devil of a time trying to use the perl -F
> command-line switch. I wanted to split a TAB-delimited file and tried
> all kinds of incantations using -F and \t. No success.

-F'\t' works for me.  Note that you have to use the -a switch for the -F
switch to work.


> I ended up
> using awk, which splits each line by space and tabs by default.

As does Perl.



John
-- 
use Perl;
program
fulfillment


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

Date: Tue, 01 Oct 2002 20:59:01 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: stderr redir confirmation
Message-Id: <3D9A44D5.A693D3ED@earthlink.net>

dkoleary@attbi.com wrote:
> 
> Hey;
> 
> I would have thought this would be easier; but the docs don't seem to
> be making much sense to me today. Need more coffee...
> 
> Here's what I got.  A program opens a log file and sets stdout to it
> via:
> 
> open(Log,"> $log_file) || die "Can't create $log_file - ($!)";
> select (Log);
> $| = 1;

Perl has a special filehandle named 'stdout'.  It also has, as seperate
concept, a 'default filehandle', which, when perl starts, happens to
point at the 'stdout' filehandle.  select(filehandle) alters where the
'default filehandle' points, but it does not in any way alter the
'stdout' filehandle.

If you want to alter where the default filehandle points, then the code
you have, using select(Log), is correct.

If you want to alter the 'stdout' filehandle, then you should do:

   open(STDOUT, ">>", $log_file)
      or die "Can't open $log_file for appending: $!";

If, in addition to redirecting the 'stdout' filehandle, you want to
redirect the 'stderr' filehandle, you could either do:

   open(STDERR, ">>", $log_file)
      or die "Can't open $log_file for appending: $!";

or:

   open(STDERR, ">&STDOUT")
      or die "Can't make STDERR a dup of STDOUT: $!";

Of course, if reopening STDERR fails, then odds are, the error message
won't be able to go anywhere, and perl will die silently.

However, regardless of *what* your code does, you should properly
comment it.  If you're merely changing the default filehandle, then in
your comments, say that, don't claim you're altering stdout, since
you're not.

-- 
How many Monks would a Chipmonk chip,
if a Chipmonk could chip Monks?


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

Date: Wed, 2 Oct 2002 09:32:08 +1000
From: "Tom Beer" <tom.beer@btfinancialgroup.spamfilter.com>
Subject: Re: Top posting (was Re: How can I count files in a directory?)
Message-Id: <andb9q$r3b$1@merki.connect.com.au>

Tad McClellan wrote in message ...
>
>Rubber Duck <rubberducky703@hotmail.com> wrote:
>
>> Top Post????
>
>   http://www.tuxedo.org/~esr/jargon/html/entry/top-post.html
>
>   http://www.geocities.com/nnqweb/nquote.html
>
>   http://mail.augustmail.com/~tadmc/clpmisc.shtml
>

It's a joke, Joyce!

Tom.




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

Date: Wed, 02 Oct 2002 00:41:57 +0100
From: Donald Fisk <hibou00000nospam@enterprise.net>
Subject: Re: Use Java! Was: becoming a better programmer
Message-Id: <3D9A32C4.26008645@enterprise.net>

Kevin Cline wrote:

> So what?  The vast majority of programmers find iteration easier
> to understand.  Sure, we can compute anything using recursive functions.
> We could also compute anything with a Turing machine.  But the weight
> of 50 years of computing shows that most people are more comfortable
> with imperative programming.

Those who are only comfortable with imperative programming
should find something else to do with their lives.  They
are not good programmers, because there are some easily
solvable problems they will struggle with.

Imperative programming is fine for some problems
but it's clearly suboptimal for others.   For those problems
it's suboptimal for, other techniques -- recursion, higher
order functions, non-strictness, search, pattern matching,
object orientation, etc. -- might be called for and these are all
part of a good programmer's repertoire.   Designers of general
purpose languages should ideally include /all/ of these, in
order to give programmers /the choice/ of which to use,
instead of restricting the feature set to prevent weak
programmers from shooting themselves in the foot.

And enough of this "all languages are equivalent" nonsense.
Is Java 1.0 as good as Java 1.2?   Is Perl 4 as good as
Perl 6?   Is Lisp 1.5 as good as Common Lisp?   Of course not.

And now, some Lisp.   Here's factorial, three different
ways:

(defun fac (n)
  (if (zerop n)
      1
    (* n (fac (1- n)))))

(defun fac (n)
  (do ((i n (1- i))
       (result 1 (* i result)))
      ((= i 1) result)))

(defun fac (n)
  (collect-sum (scan-range :from 1 :upto n)))

I'll leave you to sort those solutions by elegance.
My point is not about Lisp /per se/, it's about the
benefits of supporting multiple ways of solving problems.

(NB I have not tested the third solution, only proven it.)

> > It doesn't matter in the context of my argument whether Perl has these
> > features or not. (But to note this again: I don't see the point when
> > language designers try to include as much features as possible.
> > Questions that are equally important include: Are these features well
> > integrated? Do they follow some orthogonality principle? Is it easy for
> > programmers to comprehend these features? Are they proven in practice? ...)
> 
> Those questions are not equally important.  The last two are the only
> two of any importance for programmers trying to deliver useful systems.

I disagree strongly that features should necessarily be easily
comprehended.   The test should be: Does knowing the feature make
the problem easier to solve?   If yes, then it's a good feature
for that problem.

Le Hibou
-- 
Dalinian: Lisp. Java. Which one sounds sexier?
RevAaron: Definitely Lisp. Lisp conjures up images of hippy coders,
drugs,
sex, and rock & roll. Late nights at Berkeley, coding in Lisp fueled by
LSD.
Java evokes a vision of a stereotypical nerd, with no life or social
skills.



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

Date: Wed, 2 Oct 2002 08:47:06 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Which .exe generator?
Message-Id: <K0qm9.2$D86.24013@vicpull1.telstra.net>

"Richard S Beckett" <spikey-wan@bigfoot.com> wrote in message
news:anbr8p$f90$1@newshost.mot.com...
> Guys,
>
> I'm now at the point where I'm going to be shipping out my Perl script to
> other users!
>
> Obviously, even if the did have Perl installed, the chance of them having
> all the modules I used is small, so I need to create a self contained .exe
> file.
>
> It seems that there are 2 main contenders, Active State's Dev kit, and
> perl2exe.
>
> I was wondering what the general opinion of these is, to help me with my
> decision, being a newbie and all that.
>
> Generally I want to be able to create self contained programmes that will
> run on a variety of operating systems, but would like to be able to
generate
> them all from the same scripts that I have written on my PC, on W2K.
>
> Also, ease of getting updates would be useful, as I'm sure my company will
> be upgrading us all to XP pro or similar at some point, so something that
I
> can get for a one off payment with free updates would save me a lot of
> trouble.

I am very happy with Activestate's PDK. Currently v 4 works very well.

Wyzelli
--
push@x,$_ for(a..z);push@x,' ';
@z='092018192600131419070417261504171126070002100417'=~/(..)/g;
foreach $y(@z){$_.=$x[$y]}y/jp/JP/;print;




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

Date: 1 Oct 2002 15:06:21 -0700
From: caligari2k@yahoo.com (James)
Subject: Why are the columns of a MySQL SELECT scrambled?
Message-Id: <3b25bd38.0210011406.cecb586@posting.google.com>

This is an interesting situation I have.  I have something like:

    $myquery = "SELECT * FROM main where centernumber = ?";
    $sth = $dbh->prepare($myquery);
    $sth->execute(2);

Now, I know I only have 1 row that is being returned, but due to the
nature of the code I'm trying to write (ie very very generic) I return
the row via the following:

    my $row = $sth->fetchrow_hashref;

Then I can parse the hash to get the column names plus the value of
said column associated with centernumber=2.  Here's the kicker, the
hash is all scrambled.  If I use the command line client for mysql and
execute the same query, it is ordered like I want it.  But not here! 
I can see this by using

    print Dumper($row);

So when I loop through the the columnnames, everything is out of
whack.  So is there a way to tell the DBI or something so that the
columns are returned in the order they are set in the database? 
phpMyAdmin seems to do OK at returning the correct column order.

What I'm doing is taking the data in the database and comparing it to
the data just submitted via a web page.  That's right, not the other
way around, because not all paramenters are necessarily passed by the
webpage and I am validating the database data.  So I know the database
has all the parameter names, ie columns.

If there is a problem, then I can output appropriate HTML.  I am open
to all sorts of suggestions, but as I said, I'm trying to keep this
totally generic.  In other words, the code doesn't have a clue about
the structure of the database, the parameters on the webpage, etc, and
so far I've done pretty good job of it.  I'm just up against the wall
right now because I want the discrepancies displayed in the same order
they were entered.  Which of course matches the order of the database.

Confused yet?  Good, so am I!  I'm stumped!  Either that, or my brain
just finally decided to quit telling me the answers!  :-)

Thanks

James


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

Date: Tue, 01 Oct 2002 18:41:10 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Why are the columns of a MySQL SELECT scrambled?
Message-Id: <3D9A2486.56F63985@earthlink.net>

James wrote:
> 
> This is an interesting situation I have.  I have something like:
> 
>     $myquery = "SELECT * FROM main where centernumber = ?";
>     $sth = $dbh->prepare($myquery);
>     $sth->execute(2);
> 
> Now, I know I only have 1 row that is being returned, but due to the
> nature of the code I'm trying to write (ie very very generic) I return
> the row via the following:
> 
>     my $row = $sth->fetchrow_hashref;
>
> Then I can parse the hash to get the column names plus the value of
> said column associated with centernumber=2.  Here's the kicker, the
> hash is all scrambled.

Perls hashes are intrinsically unordered.

If you dump them out, they will be in the order of the hashing function,
not in the order that they were put into the hash.

The solution, then, is to do something like this:
   my @row_array = $sth->fetchrow_array;
   my @cols = @{$sth->{COLS}};
   my %row_hash;
   @row_hash{ @cols } = @row_array;

   #my %colname_to_colnumber;
   #@colname_to_colnumber{ @cols } = 0 .. $#cols;

Actually, if you *really* want it to be a hash, and you need it to be in
order, then you could use Tie::IxHash somehow.

-- 
How many Monks would a Chipmonk chip,
if a Chipmonk could chip Monks?


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

Date: Tue, 01 Oct 2002 22:59:54 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Why are the columns of a MySQL SELECT scrambled?
Message-Id: <slrnapk94s.2rv.tadmc@magna.augustmail.com>

James <caligari2k@yahoo.com> wrote:
> This is an interesting situation I have.  I have something like:
> 
>     $myquery = "SELECT * FROM main where centernumber = ?";
>     $sth = $dbh->prepare($myquery);
>     $sth->execute(2);
> 
> Now, I know I only have 1 row that is being returned, but due to the
> nature of the code I'm trying to write (ie very very generic) I return
> the row via the following:
> 
>     my $row = $sth->fetchrow_hashref;
> 
> Then I can parse the hash to get the column names plus the value of
> said column associated with centernumber=2.  Here's the kicker, the
> hash is all scrambled.


The very first paragraph of perldata.pod has your answer:

(my underlining)

------------------------------------
Perl has three built-in data types: scalars, arrays of scalars, and
associative arrays of scalars, known as "hashes".  Normal arrays
are ordered lists of scalars indexed by number, starting with 0 and with
negative subscripts counting from the end.  Hashes are unordered
                                            ^^^^^^^^^^^^^^^^^^^^
collections of scalar values indexed by their associated string key.
------------------------------------


You can look things up much faster in a hash than in an array,
that is Good.

The pragmatic programmer will then be looking for the 
consequent Bad that offsets it. All of engineering is trade-offs.  :-)

To get really fast lookups no matter how many elements there are,
we gave up ordering. The perl interpreter is free to order them
any way it wants to (in support of delivering fast lookups).


> Confused yet?  Good, so am I!  I'm stumped!  Either that, or my brain
> just finally decided to quit telling me the answers!  :-)


Don't use a hash if the original order is important to you,
it is might not be the proper data structure for such situations.


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


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

Date: 02 Oct 2002 01:03:27 +0200
From: Aaron Isotton <aaron@isotton.com>
Subject: Re: Why is there no CPAN equivalent for C++?
Message-Id: <c7mp6-942.ln1@zarathustra.isotton.com>

Oleg <oleg_inconnu@myrealbox.com> writes:

> Hi
> 
> I'm wondering why C++ doesn't have the same kind of [reasonably 
> cross-platform] super-library like CPAN for Perl?
> 
> Thanks
> Oleg

The main problems are, as far as I can see, the following.

1. There is only one Perl.  It has a clear center, and there are no
such problems as incompatibilities between different implementations.
There are dozens of different C++ compilers, each of them with a
different set of bugs, limitations and extensions.  The most used
compilers are probably Visual C++ (on Windows) and gcc (on Unix and
many others).  I don't believe Microsoft and GNU will ever cooperate.
They'd probably try to make each other's life as difficult as
possible.

2. C++ runs on many more platforms than Perl.  Perl is mostly used on
"real" computers, and much less on embedded systems and that kind of
thing.

3. Perl is Internet oriented (even if it can be used for many more
tasks).  C++ isn't.  Thus it is more natural to have one central code
repository such as CPAN for Perl than for C++.

-- 
Aaron Isotton

http://www.isotton.com/
My GPG Public Key: http://www.isotton.com/gpg-public-key


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

Date: Tue, 01 Oct 2002 20:21:30 -0400
From: "E. Robert Tisdale" <E.Robert.Tisdale@jpl.nasa.gov>
Subject: Re: Why is there no CPAN equivalent for C++?
Message-Id: <3D9A3C0A.C72D36A7@jpl.nasa.gov>

Oleg wrote:

> I'm wondering why C++ doesn't have the same kind of
> [reasonably cross-platform] super-library like CPAN for Perl?

I can only assume that you meant to ask,
"Why isn't their just ONE super-library for C++?"

The collection of libraries -- both proprietary and open source --
for C++ is many times larger than the libraries available for Perl.

Some people think (I'm not sure that I'm one of them)
that these C++ libraries should be "standardized"
so that applications that use the standard library APIs
would be portable everywhere.



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

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


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