[13047] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 457 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 11 03:07:28 1999

Date: Wed, 11 Aug 1999 00:05:11 -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           Wed, 11 Aug 1999     Volume: 9 Number: 457

Today's topics:
    Re: ActivePerl PerlScript -- funny problems (Abigail)
    Re: Anyone know how to use perl to parse data and gener (Eric Bohlman)
        Browser detection - write different html <ducott@intergate.bc.ca>
    Re: Creating variables on the fly with CGI.pm? <Tim.Potter@anu.edu.au>
    Re: Creating variables on the fly with CGI.pm? <tchrist@mox.perl.com>
    Re: Date::Manip SLOW (Abigail)
    Re: Date::Manip SLOW (Abigail)
    Re: Date::Manip SLOW (Abigail)
    Re: Fastest way to search a txt file? (Eric Bohlman)
    Re: Flocking, whassat? (Eric Bohlman)
        From C to Perl5:A Conversion Problem. jahagir@my-deja.com
    Re: getting perl onto windows laptop <dchrist@dnai.com>
    Re: Help - Split Function Blowing My Mind Away!! (Larry Rosler)
    Re: Help - Split Function Blowing My Mind Away!! (Andreas Fehr)
    Re: Improving speed of a sub <neutron@bamboo.verinet.com>
    Re: Improving speed of a sub (Larry Rosler)
    Re: IO::Socket dilemma (Eric Bohlman)
        is our reese the author of mysql book? <uri@sysarch.com>
    Re: Known Issues with perl (Abigail)
        Mini-objects (Sean McAfee)
    Re: Newbie: File I/O + Locking question (Abigail)
    Re: pricing a perl job <erict@cc.wwu.edu>
        Quoting Strategies and the Jeopardy Game <tchrist@mox.perl.com>
    Re: Storing email messages <Tim.Potter@anu.edu.au>
    Re: suggestions for CRAP (Abigail)
    Re: turn $6 into $6000 (Abigail)
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: 11 Aug 1999 01:05:04 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: ActivePerl PerlScript -- funny problems
Message-Id: <slrn7r24k1.cat.abigail@alexandra.delanet.com>

Nick Liebmann (Nick@ucecom.com) wrote on MMCLXX September MCMXCIII in
<URL:news:7oor1q$b29$1@nclient9-gui.server.ntli.net>:
&& You cannot embed perl script into HTML code. It's the other way round, the
&& HTML code can be embedde inot the perl and the code cxan then be called up.
&& 
&& You can't use Language= "Perlscript"...

Or any other value for Language. Language is not an allowed attribute
in the HTML 4.0 strict DTD.



Abigail
-- 
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 11 Aug 1999 05:22:46 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Anyone know how to use perl to parse data and generate excel
Message-Id: <7or1b6$s5a@dfw-ixnews9.ix.netcom.com>

Kurt Leucht (KLeucht@bigfoot.com) wrote:
: I'm confused.  I saw an example somewhere in a perl newsgroup of using
: the Win32::OLE Module to write data into an Excel spreadsheet.  My
: question is:  Was this module written strictly for perl on Windows
: machines, or can I use it to write an Excel spreadsheet from a perl
: script on my Solaris?

The former.  It assumes that you can run a copy of Excel on your 
machine.  Your best bet is to write out the data in some portable format 
(like CSV) that Excel can understand.



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

Date: Tue, 10 Aug 1999 06:58:30 -0700
From: "Robert" <ducott@intergate.bc.ca>
Subject: Browser detection - write different html
Message-Id: <37b02e4e@carrera.intergate.ca>

What we are looking for is a perl/cgi script or a java script that will
accomplish the following...When a user comes to our page, the script will
detect the browser app ver # and take an action base on that result. What we
want is when a browser is 4.0 or better, we want the page to load a
shockwave slideshow, if the browser is lower and can't handle shockwave we
want the page to load a java applet slide show. Now, were not sure if this
can be done so we'll end by saying this. Our company is will to pay top
dollar for a working script that will do this. Please reply or send to
enquiries to ducott@intergate.bc.ca




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

Date: 11 Aug 1999 16:06:49 +1000
From: Tim Potter <Tim.Potter@anu.edu.au>
Subject: Re: Creating variables on the fly with CGI.pm?
Message-Id: <6y4si6vojq.fsf@acronym.anu.edu.au>

<vlad@doom.net> writes:

> Abigail <abigail@delanet.com> wrote:
> > 83 chars. Again. Enough of this bullshit.
> > *ploink*
> 
> Whatever Abigail, I can't believe you have nothing better to do than
> sift through posts and and and make lame remarks like the above.  If
> you have nothing useful to say, then

You're only making it more difficult for people to read and reply to
your posts.  A well formatted and easy to read message will more
likely be noticed and responded to in amongst the rest of the noise in
this newsgroup.

> don't say it.  Or better yet don't read any of my posts...

Since you've been *ploink*ed there's every chance of that happening
now.


Tim.

PS: I tried to post this message leaving your >80 character lines in
place to illustrate the point.  My newsreader said 'You have lines
greater than 80 characters.  Really post?'.  Heh.

> -v

-- 
Tim Potter, System Admin/Programmer              "Disco Stu doesn't advertise"
Advanced Computational Systems CRC, RSISE Bldg Australian National University,
Canberra 0200, AUSTRALIA Ph: +61 2 62798813 Fax: +61 2 62798602


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

Date: 11 Aug 1999 00:12:39 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Creating variables on the fly with CGI.pm?
Message-Id: <37b11457@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    <vlad@doom.net> writes:
:I used to create variables for them the following way:

No you don't.  You just think you do.

:
:my $var1 = param("var1");
:my $var2 = param("var2");
:my $var3 = param("var3");
:etc.
:
:The above ended up being a page or two worth of declarations, so instead
:I did this, which is a lot smaller obviously:
:
:my @fields = param ();
:
:for (@fields) {
:	${$_} = param ($_);
:}

Oh blech.  Use a real data structure.  Don't use the symbol table
as your hash.  Sheesh.

--tom

=head2 How can I use a variable as a variable name?

Beginners often think they want to have a variable contain the name
of a variable.

    $fred    = 23;
    $varname = "fred";
    ++$$varname;         # $fred now 24

This works I<sometimes>, but it is a very bad idea for two reasons.

The first reason is that they I<only work on global variables>.
That means above that if $fred is a lexical variable created with my(),
that the code won't work at all: you'll accidentally access the global
and skip right over the private lexical altogether.  Global variables
are bad because they can easily collide accidentally and in general make
for non-scalable and confusing code.

Symbolic references are forbidden under the C<use strict> pragma.
They are not true references and consequently are not reference counted
or garbage collected.

The other reason why using a variable to hold the name of another
variable a bad idea is that the question often stems from a lack of
understanding of Perl data structures, particularly hashes.  By using
symbolic references, you are just using the package's symbol-table hash
(like C<%main::>) instead of a user-defined hash.  The solution is to
use your own hash or a real reference instead.

    $fred    = 23;
    $varname = "fred";
    $USER_VARS{$varname}++;  # not $$varname++

There we're using the %USER_VARS hash instead of symbolic references.
Sometimes this comes up in reading strings from the user with variable
references and wanting to expand them to the values of your perl
program's variables.  This is also a bad idea because it conflates the
program-addressable namespace and the user-addressable one.  Instead of
reading a string and expanding it to the actual contents of your program's
own variables:

    $str = 'this has a $fred and $barney in it';
    $str =~ s/(\$\w+)/$1/eeg;		  # need double eval

Instead, it would be better to keep a hash around like %USER_VARS and have
variable references actually refer to entries in that hash:

    $str =~ s/\$(\w+)/$USER_VARS{$1}/g;   # no /e here at all

That's faster, cleaner, and safer than the previous approach.  Of course,
you don't need to use a dollar sign.  You could use your own scheme to
make it less confusing, like bracketed percent symbols, etc.

    $str = 'this has a %fred% and %barney% in it';
    $str =~ s/%(\w+)%/$USER_VARS{$1}/g;   # no /e here at all

Another reason that folks sometimes think they want a variable to contain
the name of a variable is because they don't know how to build proper
data structures using hashes.  For example, let's say they wanted two
hashes in their program: %fred and %barney, and to use another scalar
variable to refer to those by name.

    $name = "fred";
    $$name{WIFE} = "wilma";     # set %fred

    $name = "barney";           
    $$name{WIFE} = "betty";	# set %barney

This is still a symbolic reference, and is still saddled with the
problems enumerated above.  It would be far better to write:

    $folks{"fred"}{WIFE}   = "wilma";
    $folks{"barney"}{WIFE} = "betty";

And just use a multilevel hash to start with.

The only times that you absolutely I<must> use symbolic references are
when you really must refer to the symbol table.  This may be because it's
something that can't take a real reference to, such as a format name.
Doing so may also be important for method calls, since these always go
through the symbol table for resolution.

In those cases, you would turn off C<strict 'refs'> temporarily so you
can play around with the symbol table.  For example:

    @colors = qw(red blue green yellow orange purple violet);
    for my $name (@colors) {
        no strict 'refs';  # renege for the block
        *$name = sub { "<FONT COLOR='$name'>@_</FONT>" };
    } 

All those functions (red(), blue(), green(), etc.) appear to be separate,
but the real code in the closure actually was compiled only once.

So, sometimes you might want to use symbolic references to directly
manipulate the symbol table.  This doesn't matter for formats, handles, and
subroutines, because they are always global -- you can't use my() on them.
But for scalars, arrays, and hashes -- and usually for subroutines --
you probably want to use hard references only.
-- 
Never try to outstubborn a cat.
                -- Lazarus Long, "Time Enough for Love"


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

Date: 11 Aug 1999 01:09:52 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Date::Manip SLOW
Message-Id: <slrn7r24sm.cat.abigail@alexandra.delanet.com>

Stone Cold (paulm@dirigo.com) wrote on MMCLXX September MCMXCIII in
<URL:news:7opbv7$br3$1@nnrp1.deja.com>:
__ I'm using the Date::manip module to print a range of dates (e.g. Jan-
__ 99, Feb-99, Mar-99, etc).  I'm finding, though, that this modules
__ really slowed down my CGI program.  Before I started using the module,
__ my output would come up in browser pretty fast.
__ 
__ So, does anyone know how to speed up the date::manip module?


Yes. Don't use it. Date::Manip was never intended to be fast.
The goals of Date::Manip lie more in completeness and pure Perlness.

Directly from the manual of Date::Manip:

    if speed is a primary issue, you should look elsewhere.


Had you read the documentation, you wouldn't have used Date::Manip
in the first place.

Of course, all the standard things you can do to speed up CGI apply
here as well.


Abigail
-- 
perl -we 'print q{print q{print q{print q{print q{print q{print q{print q{print 
               qq{Just Another Perl Hacker\n}}}}}}}}}'    |\
perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 11 Aug 1999 01:11:54 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Date::Manip SLOW
Message-Id: <slrn7r250q.cat.abigail@alexandra.delanet.com>

Sean McAfee (mcafee@waits.facilities.med.umich.edu) wrote on MMCLXX
September MCMXCIII in <URL:news:MHXr3.1075$J72.156986@news.itd.umich.edu>:
"" 
"" >So, does anyone know how to speed up the date::manip module?
"" 
"" Have you tried A) using Devel::DProf to profile your code and locate the
"" bottlenecks, or B) contacting the module's author with your concerns?


Considering that the author addresses these concerns in the documentation,
including suggestions what the do about it, I'd think B) is not something
you should do.

And in fact, it invalidates A) as well.


Abigail
-- 
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 11 Aug 1999 01:13:04 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Date::Manip SLOW
Message-Id: <slrn7r2530.cat.abigail@alexandra.delanet.com>

Jeff Pinyan (jeffp@crusoe.net) wrote on MMCLXX September MCMXCIII in
<URL:news:Pine.GSO.4.10.9908101212090.5367-100000@crusoe.crusoe.net>:
() 
() From the 'purl' bot on #perl on EFnet:
() 	Rumour has it Date::Manip is cool, but has two drawbacks.  1) It
() 	reads a config file, so -T is going to whine loudly.  2) It's big,
() 	you'll notice that in startup time.


Purl remembers me!



Abigail
-- 
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 11 Aug 1999 05:11:03 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Fastest way to search a txt file?
Message-Id: <7or0l7$s5a@dfw-ixnews9.ix.netcom.com>

srhadden@my-deja.com wrote:
: I was wondering what would be a very efficient (fast) way to examine a
: text file line by line to search for keywords, such as "error", or
: "warning".
: 
: The code I'm working on now takes the file and redefines $/, which
: allows a chunk of the file to be extracted, and then has perl search the
: entire chunk for one of the keywords. If a keyword is detected in the
: chunk, then the chunk is split into lines and each line is examined for
: the information and certain count variables are updated depending on how
: many lines contain a keyword.
: 
: I suppose some issues are that maybe the file doesn't contain any
: keywords at all.  Would it be too slow to have perl search the entire
: file for a keyword?  Is it quicker to search the file chunk by chunk
: rather than just search the entire file once for a keyword?

This will all depend on the statistical properties of your file and the 
amount of memory you have available to you.  In general, bigger chunks 
will mean faster initial searches, because you're spending more time 
inside the regex engine and less time doing loops that involve Perl 
operations.  But if your chunks get so big that your system starts 
swapping, you'll lose most of that advantage.

One thing that will probably speed up your processing is to minimize the 
number of passes you make over your data.  Rather than searching a chunk 
and then, if it matches, splitting it up into lines and then re-searching 
each of them, why not do both in one fell swoop?  Instead of something like

while (<INPUT>) { #reading bigger-than-one-line chunks
  next unless /\Q$keyword/;
  foreach (split /\n/) {
    if (/\Q$keyword/) {
      # do something with $_
    } 
  }
}

try

while (<INPUT>) {
  while (/^(.*\Q$keyword\E.*\n)/gm) {
    # do something with $1
  }
}

Of course, you'd need to benchmark this to make sure the more complicated 
regex doesn't eat up the savings.



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

Date: 11 Aug 1999 05:44:33 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Flocking, whassat?
Message-Id: <7or2k1$s5a@dfw-ixnews9.ix.netcom.com>

Matthew David Zimmerman (mdz4c@node8.unix.Virginia.EDU) wrote:
: If you have a website with CGI scripts, and there's heavy traffic on the
: site, chances are 2 or more people may be running copies of the same CGI
: script at the same time.

And one of the main reasons we roast The Other Matt to a crisp in this 
group is that most of his freely-available scripts do *not* deal with 
this situation correctly.



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

Date: Wed, 11 Aug 1999 05:28:29 GMT
From: jahagir@my-deja.com
Subject: From C to Perl5:A Conversion Problem.
Message-Id: <7or1lm$jfr$1@nnrp1.deja.com>

Hi Gurus,
I want to convert the following piece of C-Code to Perl5. I am including
the C-code as well as the the latest perl5 equivalent i tried to convert
to.
The Problem statement is as follows :
A floating point number(8 bytes i.e. 64 bits) is stored in
binary(machine) format as a character string.This representation of the
floating point number has following charecteristics;
The MSB of the first byte indicates the sign of the float number, the
rest of the 7 "bits" of the first byte indicate the exponent in
excess-64 format. The remaining 7 bytes form the mantissa of the
floating point number,and this mantissa is to the right of an 'implied'
decimal point. The conversion process is :
floating-point-number-------->character-string---->binary-format.

I hope the following example should be more explainative :

float_number=n;
converted_string=(1byte)(1byte)....(1byte)
                    |      |          |
                    +      +          +
                   char    char       char
This string is then written in binary format.
I want to convert this string back to floating point number. I am
listing pointwise what I am able to achieve.

1>My code reads this binary string.
2>It converts it in to characters.
3>These characters are then suitably transformed in to exponent,sign
and
the mantissa.


The output of the Perl Equivalent and the C-code perfectly match till
step two. The converted characters from C-Code and Perl Equivalent are
the same, but my perl script messes up when it tries to convert these
characters to the original floating point number. Here is the C-Code and
the perl5 equivalent.
############################C-Code##################################
int sign,exponent,in_bytes;
unsigned long long base_int;
double base_float,out_float;
 n=something;
 /*The float number is contained in a 8 byte number.Each of these bytes
  * have been converted to characters and stored. The MSB of the first
  * bytes denotes the sign while remaining 7 bits of the first byte
denote
  * a excess-64 exponent */
 in_bytes=read(f1,in_data,n);
         for (i=2;i<in_bytes;i+=8)
                 {
                 sign=record[i] & 0x80;
                 exponent=(record[i] & 0x7f) - 64;
                 base_int=0;
                 for (j=1;j<8;j++)
                 {
                         base_int<<=8;
                         base_int+=record[i+j];
                 }
                 base_float=(double)base_int/pow(2, 56);
                 out_float=base_float*pow(16,(float)exponent);
                 if (sign)
                 {
                 out_float*=-1;
                 }
                 }
#############################C-Code Ends##########################



#######Perl Equivalent##################################
#!/usr/bin/perl
read(f1,$something,n);
&Read_8_Bytes_Float($something);


sub Read_8_Bytes_Float {
        local ($something)=@_;
        local ($data_int,$data_float,$sign,$exponent)=(0,0,0,0);
        local @X=();
        local @string=();
                @X=unpack("C*",$something);
                $sign=$X[0] & 128;
                $exponent=($X[0] & 127)-64;
                for($i=1;$i<@X;$i+=8)
                        {
$data_int=((((((($X[$i]<<8)+$X[$i+1])<<8)+$X[$i+2])<<8)+$X[$i+3])<<8);
$data_int+=(((((($X[$i+4]<<8)+$X[$i+5])<<8)+$X[$i+6])<<8));
                $data_float=$data_int/(2**56);
                $data_float=unpack("d",$data_float);
                $exponent_float=unpack("f",$exponent);
                $data=$data_float*(16**$exponent_float);
                $data*=-1 if($sign);
                push(@string,"$data");
                print "$data\n";
                        }
                return @string;
}

1;

####################Perl Equivalent Ends###########################

If any kind soul has had enough patience to go through the above pieces
of codes, I would request him to look more deeply in to the perl part
where shifting operation has been carried out.

THE C-CODE WORKS PERFECTLY FINE.PLEASE IGNORE THE SYNTAX, IT CAN BE A
TYPO WHILE PUTTING THE STUFF HERE. I AM DAMN SURE THERE IS A GROSS
LOGICAL ERROR IN THE PERL5 PART.

-- Thank You Very Much
-- Jahagirdar Bhalchandra N.


--
Ships Are Safe In Harbour,
But They Are Not Meant To Be There.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Tue, 10 Aug 1999 22:17:00 -0700
From: "David Christensen" <dchrist@dnai.com>
Subject: Re: getting perl onto windows laptop
Message-Id: <7or1v8$rqh$1@pollux.dnai.com>

Jim:

How about connecting the laptop and to another Windows PC using a null modem
cable and using Hyperterminal to do a binary file transfer of the zipped
binary distribution?

--
David Christensen
dchrist@dnai.com



JAMES GRONQUIST wrote in message <37B0B28F.C4DB382C@Sun.COM>...
>I've got an older laptop computer. It is not connected to the net and
>I'm trying to get perls for windows loaded onto it. The zip file is too
>big for 1 disk. I've tried directly connecting the notebook to another
>desktop using a serial cable but it would not work. Any ideas how I can
>get perl onto this system? Is there anyplace that I can get perl on
>floppies?
>
>Tia,
>
>Jim
>
>*************************************************
>james.gronquist@sun.com
>M/S NWK11-205
>Phone: 510/574-8415
>Fax: 510/574-6591
>Cell:   408/836-5207
>*************************************************




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

Date: Tue, 10 Aug 1999 22:11:24 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Help - Split Function Blowing My Mind Away!!
Message-Id: <MPG.121aa5d04ddf27e0989e2e@nntp.hpl.hp.com>

In article <1dwchml.ieaun8nk3m7aN@p144.tc19a.metro.ma.tiac.com> on Wed, 
11 Aug 1999 00:22:24 -0400, Ronald J Kimball 
<rjk@linguist.dartmouth.edu> says...
> Larry Rosler <lr@hpl.hp.com> wrote:
> > In article <37b076fd$0$225@nntp1.ba.best.com> on 10 Aug 1999 19:01:17
> > GMT, John Callender <jbc@shell2.la.best.com> says...
> > > Larry Rosler <lr@hpl.hp.com> wrote:
> > > 
> > > > And all will be well.  (This is on my Top Ten list of Perl surprises for
> > > > beginners.  The vertical bar is a popular field separator!)
> > > 
> > > If you really have such a list, I'd be very interested in seeing it.
> > 
> > Well, I'll show them, in no particular order.  I'm sure others will be
> > able to slice and dice, transmogrify and improve.
> 
> > [snip]
> 
> That looked more like a list of Top Ten beginner mistakes, and
> split(/|/) wasn't even on it.

Huh?

Failure to escape metacharacters in split().


>    Where's the list of Top Ten Perl surprises for beginners?  :)

The surprises come at runtime, when things don't work as they *should*.

OK, surprises.  Gotchas.  That's harder.  Let's start with the one at 
hand:

1. The first argument to join() is a string, but to split() is a regex 
(no matter that it might look like a string).

2. "e:\foo\bar" is unlikely to be a good filename, but 'e:/foo/bar' is.

I'll keep thinking.  Anyone???

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 11 Aug 1999 07:00:09 GMT
From: backwards.saerdna@srm.hc (Andreas Fehr)
Subject: Re: Help - Split Function Blowing My Mind Away!!
Message-Id: <37b11f42.5577800@news.uniplus.ch>

On Wed, 11 Aug 1999 00:22:24 -0400, rjk@linguist.dartmouth.edu (Ronald
J Kimball) wrote:

>
>> [snip]
>
>That looked more like a list of Top Ten beginner mistakes, and
>split(/|/) wasn't even on it.  Where's the list of Top Ten Perl
>surprises for beginners?  :)
>

???

Failure to escape metacharacters in split().

Andreas


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

Date: Wed, 11 Aug 1999 05:17:41 GMT
From: Jack Applin <neutron@bamboo.verinet.com>
Subject: Re: Improving speed of a sub
Message-Id: <VH7s3.315$gp7.189956096@news.frii.net>

Duncan Hill <dhill@sunbeach.net> wrote:

>         while (<COPYRIGHT>)
>         {
>                 s/referrer/$foo/;
>                 print;
>         }

The /o flag would make it faster, since $foo doesn't change in the loop:

                 s/referrer/$foo/o;

					-Jack Applin
					 neutron@verinet.com
					 http://www.verinet.com/~neutron/


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

Date: Tue, 10 Aug 1999 22:56:52 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Improving speed of a sub
Message-Id: <MPG.121ab07eb0649629989e2f@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <VH7s3.315$gp7.189956096@news.frii.net> on Wed, 11 Aug 1999 
05:17:41 GMT, Jack Applin <neutron@bamboo.verinet.com> says...
> Duncan Hill <dhill@sunbeach.net> wrote:
> 
> >         while (<COPYRIGHT>)
> >         {
> >                 s/referrer/$foo/;
> >                 print;
> >         }
> 
> The /o flag would make it faster, since $foo doesn't change in the loop:
> 
>                  s/referrer/$foo/o;

Sorry, Jack, that's irrelevant.  The /o flag affects whether the regex 
part of the operation should be recompiled or not for each repetition of 
the loop; because there are no interpolations into the regex, it never 
needs recompilation.

The substitution part of the operation is computed every time, in any 
case.  In this case, it just involves copying the value of a scalar.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 11 Aug 1999 05:57:12 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: IO::Socket dilemma
Message-Id: <7or3bo$s5a@dfw-ixnews9.ix.netcom.com>

Brundle (brundlefly76@hotmail.com) wrote:
: How do I test $socket to see if there is data on the pipe before trying
: to read it?

perldoc -f select
(You'll want the "four argument form")




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

Date: 11 Aug 1999 01:31:16 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: is our reese the author of mysql book?
Message-Id: <x7g11qanob.fsf@home.sysarch.com>


i noticed the name george reese as one of the authors of the new
o'reilly book mysql & msql. is that the same twit who kept a stupid
flame war going for weeks last year? i don't feel like i can stomach
reading those old posts again. the book page claims he wrote a jdbc and
java book which i seem to recall from the war and that explains his
total lunkheadedness about perl.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.


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

Date: 11 Aug 1999 01:33:44 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Known Issues with perl
Message-Id: <slrn7r269o.cat.abigail@alexandra.delanet.com>

Seshu Adunuthula (sadunuth@us.oracle.com) wrote on MMCLXX September
MCMXCIII in <URL:news:37B05B34.56908569@us.oracle.com>:
== Are there any resources to check for known issues with perl
== specifically on NT, (Bug fixes between different releases) etc.

perldelta for an overview of the main differences between major
releases, and the Changes file for a detailed overview of all
the changes.

== I am running into problems with perl on NT. version 5.004_01
== specifically with running shell scripts from within a perl CGI
== script
== 
== open (FD, "c:\\temp\\foo.bat | ");
== while (<FD>)
== {
==    print;
== }
== 
== The above script worked for most part and failed after a long
== regress. Now perl refuses to execute the command foo.bat and
== I am not sure where to start investigating.
== (Rebooting the @#$% NT is not an option :-(  )
== 
== Does perl have any dependencies on any registry variables
== that could potentionally have gotten corrupted during the
== long regress?


Who knows? You're not asking Perl, so, why should we know?



Abigail
-- 
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Wed, 11 Aug 1999 06:32:00 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Mini-objects
Message-Id: <AN8s3.1226$J72.186788@news.itd.umich.edu>

Today I was looking for a way to simplify the making of Oracle queries
using the DBI module.  Each query call looked pretty much the same:

my $sth = prepare $dbh "select ... from ...";
execute $sth;
while ($row = fetch $sth) { ... }

 ...not too bad, really, but I thought it would be better to factor out the
common "prepare $dbh" and "execute" code and simply pass a SQL query to a
function which would return a cursor-like object.  But this didn't seem
to be a big enough job to warrant a full-blown module, and I don't really
like to put multiple unrelated packages in the same source file because I
then have to always be aware of which package is in effect when I add new
code.  So after a bit of experimentation, I came up with the following
approach:

sub start_query {
    my $sql = shift;
    my $sth = prepare $dbh $sql;
    execute $sth;
    bless \$sth, "__start_query";
    sub __start_query::fetch { ${$_[0]}->fetch }
}

my $csr = start_query "select ... from ...";
while ($row = fetch $csr) { ... }

All of the cursor's functionality is defined within the only subroutine
that returns one--it's a nice, neat little "package".

Later, I tried applying the same technique to a program I'm writing that
uses the Curses module.  It's awkward to have to store the dimensions and
screen location of a Curses pad separately from the pad itself, to be used
each time the pad is refreshed, so my new pad object encapsulates both the
underlying pad and its location and dimensions.  I also decided to reverse
Curses's irritating (y,x) coordinate convention while I was at it, as well
as combine functionality from multiple Curses functions that I'd always
had to call separately (addstr and standout/standend).

Here's what I have so far:

use Curses qw{ !newpad };

sub newpad {
    my ($sx, $sy, $width, $height) = @_;
    my $pad = Curses::newpad($height + $LINES, $width);
    $pad->erase;
    bless [ $pad, $sx, $sy, $width, $height ], "__pad";
    sub __pad::refresh {
        my ($self, $padx, $pady) = @_;
        my ($pad, $sx, $sy, $width, $height) = @$self;
        $pad->prefresh($pady, $padx, $sy, $sx, $height - 1, $width - 1);
    }
    sub __pad::addstr {
        my ($self, $x, $y, $str, $standout) = @_;
        my $pad = $self->[0];
        $pad->standout if $standout;
        $pad->addstr($y, $x, $str);
        $pad->standend if $standout;
    }
    sub __pad::move {
        $_[0][0]->move(@_[2,1]);
    }
}

Anyway, just thought I'd share.

-- 
Sean McAfee                                                mcafee@umich.edu
print eval eval eval eval eval eval eval eval eval eval eval eval eval eval
q!q@q#q$q%q^q&q*q-q=q+q|q~q:q? Just Another Perl Hacker ?:~|+=-*&^%$#@!


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

Date: 11 Aug 1999 01:35:46 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Newbie: File I/O + Locking question
Message-Id: <slrn7r26dj.cat.abigail@alexandra.delanet.com>

Chris (chrisl@hamptons.com) wrote on MMCLXIX September MCMXCIII in
<URL:news:37ae4dd8.560199@news.swbell.net>:
@@ 
@@ I have to write some simple CGI scripts. Thes scripts are going to be
@@ writing to some common files, and I have to have some kind of
@@ synchronization. Is there any file locking in Perl?

Well, if there would be, it would be in the manual, right?
Since you didn't find it, shouldn't you conclude it isn't there?


Oh. You didn't check? Well, then _I_ am not going to tell you
whether it exists or not.



Abigail
-- 
perl -we '$_ = q ?4a75737420616e6f74686572205065726c204861636b65720as?;??;
          for (??;(??)x??;??)
              {??;s;(..)s?;qq ?print chr 0x$1 and \161 ss?;excess;??}'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Tue, 10 Aug 1999 22:31:26 -0700
From: Eric Turner <erict@cc.wwu.edu>
Subject: Re: pricing a perl job
Message-Id: <37B10AAE.29AC90@cc.wwu.edu>

Scratchie wrote:
> Are you being intentionally dense or did you miss the rest of this thread.

No, I've read every post so far. I guess I'm being unintentionally
dense, in which case you've just insulted me! Oh well. The majority of
people in comp.lang.perl.misc seem to be nice, but there are always a
few rotten apples in the barrel...

> He's trying to find out how much an experienced perl programmer would
> charge for this script.

If you read his original post he says: "It took me about 16 hours, but
I'm a newbie and much of that
time was debugging and head-scratching." I can only interpret "newbie"
to mean he is NOT experienced. What led you to believe otherwise?

> The average salary for full-time beginning programmers seems tangential at best.

If you had been following the thread closely you would have noticed this
statement in one of the messages that Max posted: "While I've given up
on getting any kind of usable answer here, I should point out there are,
in fact, guidelines for artwork pricing. For instance, 'Graphic Artists
Guild Handbook: Pricing & Ethical Guidelines' isn't shy about giving
hard dollar amounts, with the understanding that they will, *of course*,
vary." Since he alluded to established guidelines, and since he himself
admits he is a "newbie," I offered the most reasonable advise I could
give. The Occupational Outlook Handbooks are widely used and
distributed, and are based on good statistical methodology.

Eric Turner


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

Date: 11 Aug 1999 00:20:00 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Quoting Strategies and the Jeopardy Game
Message-Id: <37b11610@cs.colorado.edu>

The following message will be posted periodically until observed
clue-levels in these parts improve, or until the heat death of the
Universe arrives.

EXECUTIVE SUMMARY: 
    To send better messages, please trim and summarize what you're
    replying to, and integrate your quoted text with the body of your
    message. Don't just put everything at the end.  This isn't Jeopardy.
    People expect question-and-answer, not answer-and-question responses.

LONG STORY:

Wouldn't you like to make your messages easier for others to read and
understand?  If so, I have some news posting tips for you.  If not,
just ignore this.  (Of course, if you don't want your messages
easier to read and understand, it's not clear why to bother to 
send them in the first place. :-)  I'm going to take a bit of 
time to explain this, because newcomers to Usenet often lack the 
cultural background were I to send a superbrief message.  

Here's the issue: you appear to have quoted the entire message to which
you were replying.  Worst of all, you have done so by merely appending
the complete message at the bottom.  Folks are used to reading the
original material first, then the follow-up.  That's why it's called a
"follow-up", you know. :-)

If all you want to do is forward a copy of the message, that's one thing,
but here you seem to have just blindly pasted the complete old message at
the end without providing any content.  This is neither a proper public
followup nor even a decent private reply.  Here's why.

First of all, this is massive overkill -- you're supposed to trim your
quoted text to only what you're replying to.  Otherwise you'll probably
violate the netiquette target quoting percentage of 50%.  See below.
This isn't really an issue of space (I know that a few bytes here and
there mean less today than 20 years go), so much as it is of integrating
your comments with the old material for continuity.

Second, putting everything at the bottom does little good.  It doesn't
provide the proper context.  It's far too late.  When you reply to
someone's content, the reason you quote the previous message is so that
you can provide some degree of contextual continuity.  The best way to
do this is to interleave what you're quoting with your responses to that
particular piece.  That means that you should provide a quoted portion,
then address what the points therein, then another quoted section, etc.

For example, here's how followup replies *should* look if you'd
like them to be more effective.

    > Joe said we should eat noodles.

    But I don't like noodles.  They are a pain to prepare -- remember
    that what started this thread was how to cook using only a microwave,
    not real cooking -- and they provide you with very little sustenance
    in the long run.  It's like eating cardboard, nutritionally speaking.

    > He also suggests adding anchovies.

    What is this fish fetish?  Not all of us like the little minnows
    with the lingering briny taste swimming around our mouths for the
    next few hours or days.  Can you imagine this on a date?  Iccccch!

Notice how in the text above, alternate quoted passages are interleaved
with new response text.  Notice also that the new text far exceeds the
old text.  This is the way it should be.

If you are receiving this message in response to a news posting, please
understand that all modern newsreaders provide a mechanism to fetch
the parent article, so it is seldom necessary to quote the whole thing.
Sometimes even mail readers provide this, depending on the mail headers
and the list archival mechanism on your own system.

Here's a section from the essential netiquette guide, "A Primer
on How to Work With the Usenet Community", which is available in
news.announce.newusers.  Perhaps your service provider neglected to point
you at this newsgroup before you got swallowed up by all of Usenet.
It's not only a good read; it's critical to understanding the culture
you're now moving in.

                    Summarize What You are Following Up.

  When you are following up someone's article, please summarize the
  parts of the article to which you are responding.  This allows readers
  to appreciate your comments rather than trying to remember what the
  original article said.  It is also possible for your response to get
  to some sites before the original article.

  Summarization is best done by including appropriate quotes from
  the original article.  Do not include the entire article since it
  will irritate the people who have already seen it.  Even if you are
  responding to the entire article, summarize only the major points you
  are discussing.

It's even more annoying when people needlessly quote the original's
automatic trailing matter, like signatures, adverts, or disclaimers.
Please don't do that.

I'm honestly not trying to annoy you!  I'm just trying to give tips
about what works well in electronic messages, and what doesn't.  This
used to be standard fare before one got a Usenet account, but now
something seems to be lost.  
-- 
_doprnt(pat, args, &fakebuf); /* what a kludge */
    --Larry Wall, from util.c in the v5.0 perl distribution


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

Date: 11 Aug 1999 16:18:24 +1000
From: Tim Potter <Tim.Potter@anu.edu.au>
Subject: Re: Storing email messages
Message-Id: <6y3dxqvo0f.fsf@acronym.anu.edu.au>

Doraemon <cs454@hotmail.com> writes:

>    I created an HTML form which will invoke a perl script when the form
> is being submit.  This perl script will parse the form elements and use
> the perl module Mail::Send to sent email.  The problem I am having is
> storing this email in a file.  I want to save all sent email in a file,
> kinda like a "Sent" Folder in a hotmail account so that sent email can
> be retrieve later for reference.

Why don't you Cc: or Bcc: the message to another email address/alias 
and get your mail program to do the work for you?


Tim.

-- 
Tim Potter, System Admin/Programmer              "Disco Stu doesn't advertise"
Advanced Computational Systems CRC, RSISE Bldg Australian National University,
Canberra 0200, AUSTRALIA Ph: +61 2 62798813 Fax: +61 2 62798602


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

Date: 11 Aug 1999 00:24:18 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: suggestions for CRAP
Message-Id: <slrn7r227i.cat.abigail@alexandra.delanet.com>

Jeff Pinyan (jeffp@crusoe.net) wrote on MMCLXX September MCMXCIII in
<URL:news:Pine.GSO.4.10.9908101833130.19643-100000@crusoe.crusoe.net>:
$$ 
$$ If you ask me, and perhaps you should, I would be thrilled to have a
$$ section of CRAP's web site (soon to be at http://www.mattright.com/) to be
$$ a CGI Repository.  The CRAP project is beginning to pick up speed -- I'm
$$ waiting for a couple articles to be written -- and this site should become
$$ a well-tapped resource.

If you want to be serious about this project, you should not become
personal and name your domain after a person different from yourself.

And although IANAL, I can easily imagine that if Matt Wright gets ticked
off, a bunch of lawyers will have a field day.


But 'mattright' is certainly cute.



Abigail
-- 
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 11 Aug 1999 01:02:44 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: turn $6 into $6000
Message-Id: <slrn7r24fl.cat.abigail@alexandra.delanet.com>

Elaine -HFB- Ashton (elaine@chaos.wustl.edu) wrote on MMCLXX September
MCMXCIII in <URL:news:37B016A6.4582D637@chaos.wustl.edu>:
<> 
<> Well, you always could...as long as you weren't counterfeiting US
<> currency which would grab the attention of the Secret Service. :)
<> Hmmm...Perl Bucks. What economy could we form with those?


Water and salt trading in the desert. With the occasional gold,
silver and white slave deals.



Abigail
-- 
perl -MNet::Dict -we '(Net::Dict -> new (server => "dict.org")
                       -> define ("foldoc", "perl")) [0] -> print'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. Due to their sizes, neither the Meta-FAQ nor
the FAQ are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq" from
almanac@ruby.oce.orst.edu. 

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 V9 Issue 457
*************************************


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