[16982] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4394 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 21 06:05:30 2000

Date: Thu, 21 Sep 2000 03:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <969530710-v9-i4394@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 21 Sep 2000     Volume: 9 Number: 4394

Today's topics:
    Re: 100 levels deep in subroutine calls! (Daniel Chetlin)
    Re: 100 levels deep in subroutine calls! (Daniel Chetlin)
    Re: 2 Questions (J French)
    Re: Candidate for the top ten perl mistakes list <glynFOOdwr@FSCKdeleteEmeD.co.uk>
        creating XS wrapper for C functions inport,inportb,outp <jdb@wcoil.com>
    Re: File Parsing, Skipping lines <bart.lateur@skynet.be>
    Re: File Parsing, Skipping lines (Abigail)
    Re: Gratuitous incompatibilities (Was: Re: Range operat <bart.lateur@skynet.be>
    Re: How to install perl in win98? <bart.lateur@skynet.be>
        How to use perl to read content of a gdbm file? <carfield@my-deja.com>
        How to use perl to read content of a gdbm file? <carfield@my-deja.com>
        How to use perl to read content of a gdbm file? <carfield@my-deja.com>
        How to use perl to read content of a gdbm file? <carfield@my-deja.com>
    Re: How To? Setting External Subroutine as Method of Pe <jdb@wcoil.com>
    Re: Interpolation on the fly <philipg@atl.mediaone.net>
    Re: Interpolation on the fly (Abigail)
    Re: Interpolation on the fly <glynFOOdwr@FSCKdeleteEmeD.co.uk>
    Re: Joining strings <g.soper@soundhouse.co.uk>
    Re: Joining strings <g.soper@soundhouse.co.uk>
        NT non blocking socket <alex.turner@enformatica.com>
    Re: perl URL download from a site that needs a cookie <bart.lateur@skynet.be>
    Re: Perl vs. Java or C++ <alex.turner@enformatica.com>
        print, chop, \n grrr... <lmoran@wtsg.com>
    Re: print, chop, \n grrr... (Gwyn Judd)
    Re: print, chop, \n grrr... <anmcguire@ce.mediaone.net>
        Problem with Perlscript IO::socket in ASP on IIS4 <nospam.joost@travelplan.com>
    Re: Pure perl encrypt/decryption? <andrew.flisher@onyx.net>
    Re: Pure perl encrypt/decryption? <bart.lateur@skynet.be>
    Re: reading from a file <bart.lateur@skynet.be>
    Re: Shortest code for Fibonacci? <bart.lateur@skynet.be>
        Sitemanager script (=?ISO-8859-1?Q?BigB=90=90=99?=)
        storing HoH in database <bart.lateur@skynet.be>
    Re: storing HoH in database (Tony L. Svanstrom)
        Threads are broken in ActiveState Perl v5.6. <jdb@wcoil.com>
        Unrecognized character \327 <udo.kuehne@inatec.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 21 Sep 2000 05:40:01 GMT
From: daniel@chetlin.com (Daniel Chetlin)
Subject: Re: 100 levels deep in subroutine calls!
Message-Id: <8qc6vh031f1@news2.newsguy.com>

On 19 Sep 2000 21:07:44 GMT, Ron D. Smith~ <rdsmith@sedona.ch.intel.com> wrote:
>I am having a problem with a GUI application I am working on where I keep
>getting the error message "100 levels deep in subroutine calls!", and it happens
>more frequently when I am in the debugger.

I would think _only_ when in the debugger, as this is the only time the
warning should appear.

>1) why 100?  Why not 1000, 10,000 or any other arbitrary (or even better,
>programmable) number.  It does not take too much imagination to envision a case
>where you might have a recursive function call that could easily go more than
>100 subroutines deep.  I appreciate the courtesy of the error, but damn-it, I
>know what I'm doing (I think :-) so "do me a favor" and "don't do me any favors".

100 is the level set for the "deep recursion" warning. I'm not sure why
it is, but it is.

>2) can I defeat this "warning"?  (Actually it is annoyingly fatal...) 
>preferably without touching the source code (which I do not control at my job).

It _definitely_ shouldn't be fatal. If you're seeing it "halt" your code
in the debugger, just type "r" to resume. I don't think it can be
disabled -- it's intended to give you a chance to jump in and stop
something that's not going to stop on its own.

>3) why is it also WRONG?  If, when I get this error message, I dump the stack
>with a 'while ( ... caller ...) {print...}' loop I *always* get much less than
>100 levels deep.  So not only is perl doing me an unwanted favor, it is doing it
>incorrectly.  I also noticed this problem when using the libwww modules.  What
>both Tk and libwww have in common is some rather sophistocated uses of 'eval'
>to protect against faulting conditions.

I don't think it's wrong, but I suppose it's possible. I'd love to see
what you're actually doing so I can make sure.

Again ... if you're seeing that message and you're not using the
debugger, something is _seriously_ broken. Please do post a test case or
something that exhibits the problem if my responses above don't fit you.

-dlc


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

Date: 21 Sep 2000 05:41:42 GMT
From: daniel@chetlin.com (Daniel Chetlin)
Subject: Re: 100 levels deep in subroutine calls!
Message-Id: <8qc72m131f1@news2.newsguy.com>

On 19 Sep 2000 23:19:28 GMT, Abigail <abigail@foad.org> wrote:
>Ron D. Smith~ (rdsmith@sedona.ch.intel.com) wrote on MMDLXXVI September
>MCMXCIII in <URL:news:8q8kj0$o5e@news.or.intel.com>:
>$$ 
>$$ 2) can I defeat this "warning"?  (Actually it is annoyingly fatal...) 
>$$ preferably without touching the source code (which I do not control at my job
>
>    no warnings 'recursion';
>
>for modern versions of Perl.

No; I don't think this will fix his problem. While the "deep recursion"
warning and the "levels deep" debugger message both occur at 100, they
aren't connected. Also, deep recursion won't be fatal unless you ask it
to be, whereas levels deep will stop you inside of the debugger.

-dlc


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

Date: Thu, 21 Sep 2000 08:53:22 GMT
From: jerry@iss.u-net.com (J French)
Subject: Re: 2 Questions
Message-Id: <39c9c4d0.3486952@news.u-net.com>

Bob - I would take another look at Delphi - it is excellent for
writing DLLs for use with VB and gives access to inline Assembler.

The compiler produces *very* fast code, also because it does not (by
default) mess around with Unicode, disk operations and string/memory
operations (search & replace) are very much quicker than VB

I regard Delphi as a useful extension to VB

On Wed, 20 Sep 2000 14:34:54 -0700, "Bob May" <bobmay@nethere.com>
wrote:

>Seeing programs written in either Delphi or Perl reinforces my desire
>not to dig into those languages.  Both are huge files for simple
>things and very slow executing them.  Bloatware at it's best.
>I like to do things fast and usually program in assembly when
>circumstances allow and if not, BASIC for quickly assembled programs
>that do simple things with a short development time.  I've gotten
>servoloop control temp systems working in a day without any further
>work on the program necessary and that's quick enough, especially when
>the hardware took 2 days to make and the testing was another 3 days.
>
>--
>Bob May
>Access1 has gone Chapter 7 so I don't know how long my website is
>going to last.
>Bob May
>
>



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

Date: Thu, 21 Sep 2000 08:39:42 +0100
From: "Glyndwr" <glynFOOdwr@FSCKdeleteEmeD.co.uk>
Subject: Re: Candidate for the top ten perl mistakes list
Message-Id: <5Viy5.188$6b2.1598@news6-win.server.ntlworld.com>

"Damian Conway" <damian@cs.monash.edu.au> wrote in message
news:8qbqe0$pu9$1@towncrier.cc.monash.edu.au...
> > Then please explain the mnemonic for push @array, $value :)
>
> C<push @array, $value> puts the $value at the *end* of the @array,
> so $value is at the *end* of the call.

 ...and the rest of that family (pop, shift, unshift) work just like push,
which we have a handy mnemonic for

> C<join $value, @list> puts the $value in the *middle* of the @list,
> so $value is in the *middle* of the call.

I think I'll start using this.

Still no neat mnemonic for splice though. Other than the Camel Book ;o)

--
                                           -=G=-
print join " ",reverse split /\s+/,'hacker. Perl another Just',"\n";
Web: http://www.fscked.co.uk                             ICQ: 66545073




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

Date: 21 Sep 2000 09:19:56 GMT
From: "Josiah Bryan" <jdb@wcoil.com>
Subject: creating XS wrapper for C functions inport,inportb,outport,outportb
Message-Id: <8qcjrs$l0h$0@206.230.71.31>

Ok, i give up! I have been trying for the past several days to compile XS
extensions for Perl (activestate 5.6, win32), with NO luck. After finding a
make that works (i tried make, nmake, dmake, finally pmake worked) and
installing Borland C++ 5.2 (dmake was supposdly to work with "Borland 5.x ",
to quote the readme, but it screwed up and had errors all over)...first off,
perl Makefile.PL always had errors when calling xsubpp, it would print out
Usage: stuf, so i had to hack out a way to use xsubpp myself (first time).
After i got that hurdle crossed, then i got pmake to parse the files
correctly and figured out what stuff needed chaning in makefile, after all
that, Broland comes up with 46 errors in the headers alone (btw the xs i was
trying to compile was the "Hello world" from perldoc xstut). I tried to fix
the headers myself, but it finally came to some internal headers of
Borlands, and I just gave up with that.

So i have finally given up on compiling XS extensions on Win32...my linux
box compiles them just fine..(it has perl 5.005_05...btw can i compile XS
exts on linux and copy to Win32? the bin files prob are incompat, eh?)....

Why am i writing all this? The reason i want XS right now is I am trying to
write a simply interface via LPT between my Linux box and Win32 (so i need
to compile the XS on both boxes)...and please dont go telling me about PLIP-
it doesnt work in win32 and my kernel crashed when i tried to recompile for
plip. And please dont go flaming me...I have honestly been trying to get
this to work...for the past several days.

I am writing to inquire if someone with win32 that knows how to compile
XS..would...out of the goodness and kindess of their heart, compile a
wrapper for the four C functions: inport, inportb, outport, outportb. Thats
it, just a wrapper to pass the 2 or 1 args and return the approp values.
Nothing else at all. Could someone possibly be kind enough to do that? I
know its a long shot but i know there are some good people still out here on
usenet somewhere.

OR (or or or...) if someone knows of an existing module (yes, i checked CPAN
and perldoc -q inport, LPT, etc) or an exsiting way of doing the equivelant
of the C functions inport() and outport() in Perl, PLEASE let me know!

Thankyou all for your help!!

~ josiah

--
Josiah Bryan
jdb@wcoil.com
Tel: 937.316.6256





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

Date: Thu, 21 Sep 2000 09:16:36 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: File Parsing, Skipping lines
Message-Id: <3fkjssk6gq63aeht04gkpfg95kagvfoodf@4ax.com>

J. Stone wrote:

>If I know I need to move ahead a certain number of lines once I've
>found an item in my file, what is the best way to do this?

A fixed number? Call <> in scalar or void context that many times.

-- 
	Bart.


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

Date: 21 Sep 2000 09:36:06 GMT
From: abigail@foad.org (Abigail)
Subject: Re: File Parsing, Skipping lines
Message-Id: <slrn8sjlhu.5fq.abigail@alexandra.foad.org>

Bart Lateur (bart.lateur@skynet.be) wrote on MMDLXXVIII September
MCMXCIII in <URL:news:3fkjssk6gq63aeht04gkpfg95kagvfoodf@4ax.com>:
"" J. Stone wrote:
"" 
"" >If I know I need to move ahead a certain number of lines once I've
"" >found an item in my file, what is the best way to do this?
"" 
"" A fixed number? Call <> in scalar or void context that many times.


    {
       my @__ = ("") x $that_many_times;
       eval "<@__>" if local $" = ">;<";
    }


Abigail
-- 
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
#    A spider sitting
#    beside a river. A sitting
#    cow. A thrush flies.


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

Date: Thu, 21 Sep 2000 09:13:04 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Gratuitous incompatibilities (Was: Re: Range operator with "... /^$/")
Message-Id: <51kjss4d5mjke8hguu41jf4frgpnn6rcmk@4ax.com>

Christopher Biow wrote:

>Larry Rosler <lr@hpl.hp.com> wrote:
>
>>The Unix use of a single character to represent New Line was clever; the 
>>use of the character literally implementing Line Feed ("\12") instead of 
>>an otherwise unused control character led to confusion.  
>
>Perhaps LF was chosen for "safety" in that if a file was inadvertantly
>dumped "raw" to an impact printer, it would not result in a pileup of
>printing and burn through the paper and platen?

Eh? The default behaviour of LF is to scroll the paper. In addition, CR
moves the cursor (carriage) to the left edge.

>>Apple's choice of Carriage Return ("\15") for the same logical function 
>>compounded the confusion.
>
>*Not* safe in that respect!

Oh yes it is. in raw mode, CR never moves to the next line.

I always thought that superstition was part of the reason fro the
choice. CR is 13, which is a "special number". LF is 10, which is plain.
Apple wanted this special number, but Unix people were too superstitious
to use it.

Anyway, it is pretty much the same as the discussion of big-endian vs.
little endian number representation: none is superior. It's just a
choice.

-- 
	Bart.


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

Date: Thu, 21 Sep 2000 08:48:35 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: How to install perl in win98?
Message-Id: <aqijss0nj4pno93mlobe4o8npqm26l5925@4ax.com>

EE wrote:

>I've download the Perl-5.6.0 and window installer from activestate.com and
>install it,but how can i install the perl?

You need Microsoft's Windows Installer. See the third paragraph on this
page:

	http://www.activestate.com/Products/ActivePerl/Download.html

-- 
	Bart.


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

Date: Thu, 21 Sep 2000 06:11:41 GMT
From: Carfield Yim <carfield@my-deja.com>
Subject: How to use perl to read content of a gdbm file?
Message-Id: <8qc8ql$ojc$1@nnrp1.deja.com>

As title, I write the following simple code in order to read the
content of my gdbm file, but report cannot open the dbm file:

sub printDBM {
        dbmopen(%dbm, $_[0], undef) || die "cannot open $_[0] for
read\n";

        foreach $key (keys %dbm) { # step through all values
                print "$key\t%dbm{$key}\n";
        }

        dbmclose(%dbm);
}

I can sure that the path is correct, and everyone have read permission.

Besides, How can I see the error message of why I can't open the file
for read??


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 21 Sep 2000 06:56:47 GMT
From: Carfield Yim <carfield@my-deja.com>
Subject: How to use perl to read content of a gdbm file?
Message-Id: <8qcbf5$rq1$1@nnrp1.deja.com>

As title, I write the following simple code in order to read the
content of my gdbm file, but report cannot open the dbm file:

sub printDBM {
        dbmopen(%dbm, $_[0], undef) || die "cannot open $_[0] for
read\n";

        foreach $key (keys %dbm) { # step through all values
                print "$key\t%dbm{$key}\n";
        }

        dbmclose(%dbm);
}

I can sure that the path is correct, and everyone have read permission.

Besides, How can I see the error message of why I can't open the file
for read??


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 21 Sep 2000 07:14:47 GMT
From: Carfield Yim <carfield@my-deja.com>
Subject: How to use perl to read content of a gdbm file?
Message-Id: <8qccgk$suf$1@nnrp1.deja.com>

As title, I write the following simple code in order to read the
content of my gdbm file, but report cannot open the dbm file:

sub printDBM {
        dbmopen(%dbm, $_[0], undef) || die "cannot open $_[0] for
read\n";

        foreach $key (keys %dbm) { # step through all values
                print "$key\t%dbm{$key}\n";
        }

        dbmclose(%dbm);
}

I can sure that the path is correct, and everyone have read permission.

Besides, How can I see the error message of why I can't open the file
for read??


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 21 Sep 2000 07:19:00 GMT
From: Carfield Yim <carfield@my-deja.com>
Subject: How to use perl to read content of a gdbm file?
Message-Id: <8qccof$t8s$1@nnrp1.deja.com>

As title, I write the following simple code in order to read the
content of my gdbm file, but report cannot open the dbm file:

sub printDBM {
        dbmopen(%dbm, $_[0], undef) || die "cannot open $_[0] for
read\n";

        foreach $key (keys %dbm) { # step through all values
                print "$key\t%dbm{$key}\n";
        }

        dbmclose(%dbm);
}

I can sure that the path is correct, and everyone have read permission.

Besides, How can I see the error message of why I can't open the file
for read??


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 21 Sep 2000 08:53:32 GMT
From: "Josiah Bryan" <jdb@wcoil.com>
Subject: Re: How To? Setting External Subroutine as Method of Perl Module and passing arguments
Message-Id: <8qciac$i0v$0@206.230.71.38>

How about this, a simple symbol table hack that can overwrite any existing
error_handler in the module, thatway you can have error_handler() defined in
the module if you forget to set it from the calling script. Enjoy!


package main;
use MyModule;

*{'MyModule::error_handler'} = \&error_handler;

error_handler {
#blah
}

package MyModule;

sub Mysub {
    my $self = shift;
    if($error) {
        $self->error_handler($error);
}


Cheers!

~ josiah
<jdb@wcoilNOSPAM.com

RainCloud Studios <design@raincloud-studios.com> wrote in message
news:UVAx5.4129$Ao3.25493@news1.atl...
> For CGI-related scripts I will usually code a module with errors returned
to
> the calling script and if a failure is encountered, route the error to a
> custom HTML output routine. What I'd like to attempt, mainly just to
satisfy
> my sense of curiousity, is passing a subroutine to a module and then call
> that subroutine including passed arguments from -within- the module
whenever
> errors occur.
>
> Basically I'm looking to 'raise the error' from inside the module to an
> external subroutine in the main CGI Perl script. I know a few will raise
> eyebrows over the idea of not checking a return but humor me momentarily.
:)
> The implementation would work somewhat like:
>
> # in my calling script
> sub error_handler{
>   my $error = shift;
>   &print_header;
>   &print_custom_html_header;
>   print $error;
>   &print_custom_html_footer;
>   exit;
> }
>
> Now.. in the script I call my module.
>
> use THINGY::MYTHING;
> my $newthingy = MYTHING->new();
> $newthingy->error_handler(\&error_handler);
> $newthingy->dosomething();
>
> Ok.. if an error occurs in &dosomething I would now like to send the error
> message to error_handler from within the module, thus revealing an error
> page and exiting the script. I'm totally lost. The farthest I've travelled
> that even resembles this is working with anonymous subs in a hash
structure
> and nothing I've done there seems to relate. The one thing that really has
> my noodle cooked is how the arguments would get passed
once ->error_handler
> is set.
>
> Thanks for any input,
> CC's welcome as an alert ( I will respond on list),
>
> Charles R. Thompson
> RainCloud Studios
> design@raincloud-studios.com
>
>
>




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

Date: Thu, 21 Sep 2000 06:39:31 GMT
From: "Philip Garrett" <philipg@atl.mediaone.net>
Subject: Re: Interpolation on the fly
Message-Id: <D2iy5.1173$PW4.1076364@typhoon.southeast.rr.com>

Glyndwr <glynFOOdwr@FSCKdeleteEmeD.co.uk> wrote in message
news:lGay5.2275$Rk1.38673@news2-win.server.ntlworld.com...
> "Dave Sherohman" <esper@news.visi.com> wrote in message
> news:slrn8sidb1.npj.esper@pchan.dojo...
> > Took a little rearranging (I'm actually reading $fmt from a config file,
> so
> > adding the quotes and newline to it doesn't work out that well...), but
I
> > finally came up with
> >
> > eval "print \"$fmt\n\"";
>
> Something I do a lot I'd like some feedback on from people: I'd write that
> as
>
> eval qq[print "$frm\n"];
>
> because I find that more readable. Any reason not to do that?

Because the qq operator will interpolate $frm before it gets to eval.  Use q
instead.

hth,
p




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

Date: 21 Sep 2000 07:33:48 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Interpolation on the fly
Message-Id: <slrn8sjecj.5fq.abigail@alexandra.foad.org>



package deferred_interpolation;

use strict;

# $Id: deferred_interpolation.pm,v 1.1 2000/09/21 07:19:30 abigail Exp abigail $
#
# Using this pragma means that if you have a string using scalar
# interpolation, the interpolation is done when the string is *used*,
# not when the string is actually defined.
#
# This will not work with array interpolation.
#
# To achieve this result, strings will be overloaded, using 
# overload::constant. Strings will be represented as a blessed reference
# to an array, where the array contains *references* to the various
# string components. Since Perl passes implicite references as arguments
# to functions if it can, this just works out. The reference is blessed
# into a package that overloads concatenation and stringify. 
#
# $Log: deferred_interpolation.pm,v $
# Revision 1.1  2000/09/21 07:19:30  abigail
# Initial revision
#

use vars qw /$VERSION/;

($VERSION) = '$Revision: ' =~ /([\d.]+)/;

use overload '.'  => sub {
    # We can concatenate with pieces that are normal Perl strings, for
    # instance from single quoted strings. However, overloading single
    # quoted constants won't do, as for instance "foo@array" is just
    # a short hand for "foo" . join $" => @array.

    $_ [0] =  [\$_ [0]] unless ref $_ [0];
    $_ [1] =  [\$_ [1]] unless ref $_ [1];

    # At this point, both $_ [0] and $_ [1] are references to arrays
    # containing string pieces. It's simple to listify both of them,
    # and return an appropriate blessed reference to an array containing
    # both lists. However, this sub might be called with the arguments in
    # the "wrong" order; if so, $_ [2] is true. Hence, the inner voodoo.
    # Note that @_ [0, 1] = @_ [1, 0] if $_ [2] will not work.

    bless [map {@{$_ [$_ [2] ? 1 - $_ : $_]}} 0 => 1] => __PACKAGE__
};

use overload '""' => sub {
    # Dereference the pieces, and join them with nothing in between.

    join "" => map {$$_} @{$_ [0]}
};


sub import {
    # We only need to perform magic on double quoted strings, not
    # on single quoted strings, or tr///.
    # There isn't much point in overloading the RHS of s///, as that
    # will reinterpolate anyway, unless you tell Perl not to.

    overload::constant q => sub {
        $_ [2] eq "qq" ? bless [\$_ [1]] => __PACKAGE__ : $_ [1]
    }
}

sub unimport {
    overload::remove_constant q => 0;
}


1;

__END__

=pod

=head1 NAME

deferred_interpolation -- Delay interpolation of scalar till string is used.

=head1 SYNOPSIS

    use deferred_interpolation;
    my $name;
    my $str  = "My name is $name.";
       $name = "Abigail";
    print $str;                    # My name is Abigail.
       $name = "Larry Wall";
    print $str;                    # My name is Larry Wall.

    no deferred_interpolation;
       $name = "Edsger W. Dijkstra";
    my $str2 = "My name is not $name.";
       $name = "Donald E. Knuth";
    print $str2;                   # My name is not Edsger W. Dijkstra.

=head1 DESCRIPTION

Normally, Perl performs interpolation when a string is defined. But
sometimes it would be convenient to perform the interpolation when the
string is actually used, interpolating the current value of the variables.

This package will do that, but for interpolation of scalar variables only.
Arrays are interpolated when the string is defined.

=head1 BUGS

The following cases do not work; they will put something of the form
C<ARRAY(0x815bc88)> in your string.

=over 4

=item o

    my $name;
    my $str = "My name is $name.";
    foreach $name ("Abigail", "Larry Wall") {
        print $str
    }

=item o

    my $count = 5;
    my $str   = "I have ${\($count * 10)} marbles.\n";
    print $str;

Use

    my $str   = "I have @{[$count * 10]} marbles.\n";

instead. (This of course will be interpolated at when the string is defined,
not when it is used).

=item o

The name of the package is way too long.

=back

=head1 HISTORY

    $Log: deferred_interpolation.pm,v $
    Revision 1.1  2000/09/21 07:19:30  abigail
    Initial revision


=head1 THANKS

The author wishes to thank Dave Sherohman, who posted a question that lead
to this package I<news:slrn8sib1o.npj.esper@pchan.dojo>, and Damian Conway
for his talk about Object Orientism at YAPC 19100; without it, the author
would never have heard of overloaded constants.

=head1 AUTHOR

This package is written by Abigail, I<abigail@foad.org>.

=head1 COPYRIGHT and LICENSE

This program is copyright 2000 by Abigail.

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
 
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

=cut
-- 
perl -wle\$_=\<\<EOT\;y/\\n/\ /\;print\; -eJust -eanother -ePerl -eHacker -eEOT
#    A pair of woodpeckers
#    above a monastry. Ryokan.
#    Five carp swim.


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

Date: Thu, 21 Sep 2000 08:38:05 +0100
From: "Glyndwr" <glynFOOdwr@FSCKdeleteEmeD.co.uk>
Subject: Re: Interpolation on the fly
Message-Id: <ATiy5.186$6b2.1779@news6-win.server.ntlworld.com>

"Philip Garrett" <philipg@atl.mediaone.net> wrote in message
news:D2iy5.1173$PW4.1076364@typhoon.southeast.rr.com...
> Glyndwr <glynFOOdwr@FSCKdeleteEmeD.co.uk> wrote in message
> news:lGay5.2275$Rk1.38673@news2-win.server.ntlworld.com...
> > "Dave Sherohman" <esper@news.visi.com> wrote in message
> > news:slrn8sidb1.npj.esper@pchan.dojo...
> > > Took a little rearranging (I'm actually reading $fmt from a config
file,
> > so
> > > adding the quotes and newline to it doesn't work out that well...),
but
> I
> > > finally came up with
> > >
> > > eval "print \"$fmt\n\"";
> >
> > Something I do a lot I'd like some feedback on from people: I'd write
that
> > as
> >
> > eval qq[print "$frm\n"];
> >
> > because I find that more readable. Any reason not to do that?
>
> Because the qq operator will interpolate $frm before it gets to eval.  Use
q
> instead.

Oopsie. That was a typo, honest, I knew that ;o)

--
                                           -=G=-
print join " ",reverse split /\s+/,'hacker. Perl another Just',"\n";
Web: http://www.fscked.co.uk                             ICQ: 66545073




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

Date: Wed, 20 Sep 2000 23:07:13 +0100
From: Geoff Soper <g.soper@soundhouse.co.uk>
Subject: Re: Joining strings
Message-Id: <4a013224b1g.soper@soundhouse.co.uk>

In article <slrn8si919.1tk.tjla@thislove.dyndns.org>,
   Gwyn Judd <tjla@guvfybir.qlaqaf.bet> wrote:
> try:

> open FILE, ">$location" . 'file' or die "Could not open the file: $!";

> or

> open FILE, ">${location}file" or die "Arrgh: $!";

> Again note the checking for an error.

I actually had '|| die ' error checking but didn't quote it for the sake
of simplicity! Thanks for your suggestions.

-- 
Geoff Soper
g.soper@soundhouse.co.uk
Take a look at the Soundhouse page http://www.soundhouse.co.uk/


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

Date: Wed, 20 Sep 2000 23:11:57 +0100
From: Geoff Soper <g.soper@soundhouse.co.uk>
Subject: Re: Joining strings
Message-Id: <4a013293d4g.soper@soundhouse.co.uk>

In article <MPG.1432c3406758f13498ada3@nntp.hpl.hp.com>,
   Larry Rosler <lr@hpl.hp.com> wrote:
> Perl would tell you why not, if you tested for failure of the operation 
> and printed a diagnostic that included $!.  The reason doesn't have to 
> do with string concatenation.  Your way works fine, and there are many 
> other ways too.

I actually stripped the error reporting out for the sake of simplicity
while quoting! 

> The curly brackets separate the symbol $location from the desired 
> suffix.  Many would leave the trailing '/' off of $location, and use it 
> as a separator:

>          ... ">$location/file" ...

I don't quite understand this, I leave the last '/' off when setting the
variable up? So is the '/' reserved and results in the end of a string
name? And if it's reserved how does it come to still put itself between
the path and name as I require?

Thanks for your suggestions and help, I'll go and work out what actually
is wrong instead of looking at the part I was unsure of.

Cheers

-- 
Geoff Soper
g.soper@soundhouse.co.uk
Take a look at the Soundhouse page http://www.soundhouse.co.uk/


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

Date: Thu, 21 Sep 2000 08:04:49 +0100
From: Alex Turner <alex.turner@enformatica.com>
Subject: NT non blocking socket
Message-Id: <39C9B311.3795C6F1@enformatica.com>

Anyone know how to get tcp sockets non-blocking on NT?

Thanks

AJ



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

Date: Thu, 21 Sep 2000 09:02:18 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: perl URL download from a site that needs a cookie
Message-Id: <79jjss07rnvf02sq0vri88rk0c63oq0upk@4ax.com>

jbalding@hotmail.com wrote:

>On one site,
>however, you have to initially go through a Javascript login page to
>get to the data. On subsequent logins it reads information stored in a
>cookie to validate my login.
>
>Does anyone have any idea how I can get at this data offline using
>perl?

I assume you're talking about sending the cookie using Perl? My first
thought is to check out LWP. There is a HTTP::Cookies module there.
Access it from within LWP::UserAgent.

	$ua->cookie_jar([$cookies]) 
	     Get/set the HTTP::Cookies object to use. The default is to
 	     have no cookie_jar, i.e. never automatically add "Cookie"
	     headers to the requests.

-- 
	Bart.


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

Date: Thu, 21 Sep 2000 08:06:42 +0100
From: Alex Turner <alex.turner@enformatica.com>
Subject: Re: Perl vs. Java or C++
Message-Id: <39C9B381.3B7DD92A@enformatica.com>

Indead, as you learn more languages, you will see the similarities between
then and develop an understanding which is language independent.

AJ

"Michael A. Meffie III" wrote:

> rathmore@tierceron.com wrote:
>
> (snip)
> > My question is, should I continue to learn Perl? Is the demand for Perl
> > programmers high? Higher than Java or C++?
>
> (snip)
> > If you have an opinion on this and wouldn't mind sharing, I'd love to
> > read what everyone thinks.
>
> IMHO, Would you ask a carpenter to choose between learning how to use a
> hammer,
> a level, and a saw? These are the tools of the trade. As a professional
> programmer you should be able to know which tool is useful for the task
> at hand.
>
> Mike --



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

Date: Thu, 21 Sep 2000 00:59:37 -0400
From: "Lou Moran" <lmoran@wtsg.com>
Subject: print, chop, \n grrr...
Message-Id: <ssj5dvd50upl1f@news.supernews.com>

--on the road and using outlook express sorry if this comes out all odd
looking or HTMLed

--I was working with ORAs Learning Perl for Win 32 and I was doing an
exercise.

--The exercise was get a user input for a word/phrase and get a user input
for a number and then get the word/phrase to print as many times as the
number.  No problem.


--so I thought, while on the plane, why not make it pretty?

code snippit: with -w and strict on
--for our purposes the word is Hello, the number is 3--
--$ is the prompt

print $phrase x $number;

produces:
HelloHelloHello$

for prettiness I tried

print "$phrase " x $number "\n";
chop $phrase;

hoping for
Hello Hello Hello
$
no good

so then I did

print "$phrase " x $number;
chop $phrase;
print "!\n";

which produced
Hello Hello Hello !
$

close but I wanted
Hello Hello Hello!

--So the questions are, what's up with the newline not working after the
$number, how should that look? and why doesn't my chop work?

Thank you.




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

Date: Thu, 21 Sep 2000 05:32:07 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: print, chop, \n grrr...
Message-Id: <slrn8sj7al.5td.tjla@thislove.dyndns.org>

I was shocked! How could Lou Moran <lmoran@wtsg.com>
say such a terrible thing:
>--on the road and using outlook express sorry if this comes out all odd
>looking or HTMLed

Looks okay here

>--The exercise was get a user input for a word/phrase and get a user input
>for a number and then get the word/phrase to print as many times as the
>number.  No problem.
>
>--so I thought, while on the plane, why not make it pretty?
>
>code snippit: with -w and strict on
>--for our purposes the word is Hello, the number is 3--
>--$ is the prompt
>
>print $phrase x $number;
>
>produces:
>HelloHelloHello$
>
>for prettiness I tried
>
>print "$phrase " x $number "\n";

That should be:

 print "$phrase " x $number, "\n";

Note that print expects a list of arguments.

>chop $phrase;

This has no effect on the print since it has already happened by the
time the chop happens.

>so then I did
>
>print "$phrase " x $number;
>chop $phrase;
>print "!\n";
>
>which produced
>Hello Hello Hello !
>$
>
>close but I wanted
>Hello Hello Hello!

You want:

$phrase = "$phrase " x $number;
chop $phrase;
print $phrase, "!\n";

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
I think your opinions are reasonable, except for the one about my mental
instability.
-Psychology Professor, Farifield University


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

Date: Thu, 21 Sep 2000 01:14:10 -0500
From: "Andrew N. McGuire " <anmcguire@ce.mediaone.net>
Subject: Re: print, chop, \n grrr...
Message-Id: <Pine.LNX.4.21.0009210112270.5777-100000@hawk.ce.mediaone.net>

On Thu, 21 Sep 2000, Gwyn Judd quoth:

GJ> I was shocked! How could Lou Moran <lmoran@wtsg.com>
GJ> say such a terrible thing:

[ snip ]

GJ> >close but I wanted
GJ> >Hello Hello Hello!
GJ> 
GJ> You want:
GJ> 
GJ> $phrase = "$phrase " x $number;
GJ> chop $phrase;
GJ> print $phrase, "!\n";

Or even:

print "$phrase " x $number, "\b!\n"; # :-)
     
anm
-- 
<(@)> ; $/ = q;;; for $" ( map $_ && chr() => split m~[\D+ <(@)>
<(@)> ]~ => <DATA> ) { print "@{ [ '' => '' ] }" } __END__ <(@)>
<(@)>   74 117 115 116 32 97 110 111 116 104 101 114 32    <(@)>
<(@)>      80 101 114 108 32 72 97 99 107 101 114 10       <(@)>



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

Date: Thu, 21 Sep 2000 11:02:20 +0200
From: Joost <nospam.joost@travelplan.com>
Subject: Problem with Perlscript IO::socket in ASP on IIS4
Message-Id: <39C9CE9C.3D2DBAC@travelplan.com>

Hi there,

I'm using a Perlscript in an ASP-page to connect to an other server
using the IO::socket module. The connection is OK, I get an answer from
that server  just like it should be. But here's the problem: our server
generates socket-errors from the first time I ran the ASP-page with the
Perlscript and within some time, the server crashes.  Is someone
familiar with this problem?

Thanks in advance!

Joost.



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

Date: Thu, 21 Sep 2000 08:48:59 +0100
From: Andy Flisher <andrew.flisher@onyx.net>
Subject: Re: Pure perl encrypt/decryption?
Message-Id: <MPG.1433cdcac8c32d9198968f@nntp.onyx.net>

In article <39c93403.3210$120@news.op.net>, mjd@plover.com says...
> In article <MPG.14317ae9c5de7dc3989687@nntp.onyx.net>,
> Andy Flisher  <andrew.flisher@onyx.net> wrote:
> 
> Perhaps I'm mistaken, but I thought that Blowfish was a block cipher,
> which means that yes, there *is* a guarantee that you're gonna get 8
> chars back, because that's the whole point.

Yeah, it is, my bad on this one.  Because of the implementation I was 
using I was only outputting to console whilst playing with anything large 
than 8 chars.  The console output I was getting was just garbles ascii 
output, I'm assuming that some of the 'real' characters were getting mis-
interpreted by the console and hence not appearing as 8 char blocks.

When I output to a flat file or DB I could see that the 'real' output was 
in fact in 8 Char Blocks.

Trust goes to prove that you shouldn't believe everything you can see!
-- 
Andy Flisher

'All postings are a reflection of my state of mind,
and not necessarily of any worthwhile opinion'

news@flish.co.uk    http://www.flish.co.uk


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

Date: Thu, 21 Sep 2000 09:05:36 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Pure perl encrypt/decryption?
Message-Id: <epjjsssqj3hsb4fen895aivqjafpq5kmn8@4ax.com>

Cameron Dorey wrote:

>What would be the problem with you putting a module in your personal
>space, if the ISP doesn't want to put it in the default path?

If you don't have telnet access to your site, you can forget about
installing modules that need compilation. Same thing if your ISP doesn't
provide access to a C compiler.

-- 
	Bart.


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

Date: Thu, 21 Sep 2000 08:52:23 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: reading from a file
Message-Id: <s1jjsskt64kurm0vpnd530dmdclje9tu77@4ax.com>

Powlow wrote:

>it wasn't a newline character.
>i used s/\s+$// to remove the trailing space which funnily enough
>didn't work with s/ //g or something similar.
>drove me nuts.

Check out what it was:

	print ord chop $aetit;

-- 
	Bart.


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

Date: Thu, 21 Sep 2000 08:03:48 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Shortest code for Fibonacci?
Message-Id: <h3fjssgkju8dvqkpm78je4qr829nrtkki0@4ax.com>

Gwyn Judd wrote:

>How do you take a log in constant time? Of *any* real number. Not of
>some subset where you can cheat and do a table lookup?

You *can* cheat, because for floating point numbers, your number is
stored in pretty much ideal format for it!

For positive numbers, it is:

	(any n > 0 and within range) = (mantissa) * 2 ** (exponent)

where exponent is a small signed integer number, and mantissa is a
number between 1 (inclusive) and 2 (exclusive). Then:

	log2(n) = (exponent) + log2(mantissa)

For log2(mantissa), it is between 0 (incl) and 1 (excl). You can cheat
calculating it using a table. That result still needs refinement, for
example with polynomial approximation, I think.

Anyway, multiply this result with ln(2), which is a constant (abount
0.69), and you get ln(n).

-- 
	Bart.


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

Date: Thu, 21 Sep 2000 00:05:39 -0400 (EDT)
From: blatnoi@webtv.net (=?ISO-8859-1?Q?BigB=90=90=99?=)
Subject: Sitemanager script
Message-Id: <7472-39C98913-8@storefull-617.iap.bryant.webtv.net>

 am looking for a sitemanager script that can work on
prohosting.com they do not have a sitemanager of thier own.
I would want it to have a beamer-uploader and an unzipper - if you have
one, I can use it. I have one made by a friend but it doesn't work
prohosting.com
thanx



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

Date: Thu, 21 Sep 2000 08:45:38 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: storing HoH in database
Message-Id: <mcijsso1h1jva8e5et7edhke4br7pfvcdi@4ax.com>

How would you store hashes of hashes in a database, in particular on MS
SQL server?

I want to store records in a database, but the record fields are not
restricted. The records can best be thought of as just ordinary hashes,
with pretty arbitrary keys.

I can't just put these records in a table.

I would think of storing each field in a three column table: the record
ID, the field name, and the field value. So there would be two row
identifiers instead of just one.

Lookup should be quite fast, too.

Any practical ideas?

-- 
	Bart.


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

Date: Thu, 21 Sep 2000 11:26:12 +0200
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: storing HoH in database
Message-Id: <1ehb3qx.agb9equ96y68N%tony@svanstrom.com>

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

> How would you store hashes of hashes in a database, in particular on MS
> SQL server?
> 
> I want to store records in a database, but the record fields are not
> restricted. The records can best be thought of as just ordinary hashes,
> with pretty arbitrary keys.
> 
> I can't just put these records in a table.
> 
> I would think of storing each field in a three column table: the record
> ID, the field name, and the field value. So there would be two row
> identifiers instead of just one.
> 
> Lookup should be quite fast, too.
> 
> Any practical ideas?

The quick and simple way would be to just use tie.


     /Tony
-- 
     /\___/\ Who would you like to read your messages today? /\___/\
     \_@ @_/  Protect your privacy:  <http://www.pgpi.com/>  \_@ @_/
 --oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
   on the verge of frenzy - i think my mask of sanity is about to slip
 ---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
    \O/   \O/  ©99-00 <http://www.svanstrom.com/?ref=news>  \O/   \O/


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

Date: 21 Sep 2000 08:41:24 GMT
From: "Josiah Bryan" <jdb@wcoil.com>
Subject: Threads are broken in ActiveState Perl v5.6.
Message-Id: <8qchjk$gu1$0@206.230.71.38>

I have this test script:

use Thread;
$a = new Thread \&sub1;
$b = new Thread \&sub2;

sub sub1 {
print "in thread 1\n";
}

sub sub1 {
print "in thread 2\n";
}
__END__

And it immediatly prints the error message (when run):

"No threads in this perl at threads.test line 2." (no quotes)

Any clues/hints/pointers/etc? It obviously says it is threads-enabled,
(see output of perl -v  and perl -V, below), and it is ActiveState build
613.
It is very troubling. Latest release of perl and latest release of perl from
AS,
and threads STILL dont work! Argggggggggg. Any suggestions?

~ josiah

PS:

Below is perl -v and perl -V:

[win98]$ perl -V:

Summary of my perl5 (revision 5 version 6 subversion 0) configuration:
  Platform:
    osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread
    uname=''
    config_args='undef'
    hint=recommended, useposix=true, d_sigaction=undef
    usethreads=undef use5005threads=undef useithreads=define
usemultiplicity=define
    useperlio=undef d_sfio=undef uselargefiles=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef
  Compiler:
    cc='cl', optimize='-O1 -MD -DNDEBUG', gccversion=
    cppflags='-DWIN32'
    ccflags
='-O1 -MD -DNDEBUG -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT  -DPERL_
IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DPERL_MSVCRT_READFIX'
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=4
    alignbytes=8, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='link', ldflags
'-nologo -nodefaultlib -release  -libpath:"C:\Perl\lib\CORE"  -machine:x86'
    libpth="C:\Perl\lib\CORE"
    libs=  oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib  netapi32.lib
uuid.lib wsock32.lib mpr.lib winmm.lib  version.lib odbc32.lib odbccp32.lib
msvcrt.lib
    libc=msvcrt.lib, so=dll, useshrplib=yes, libperl=perl56.lib
  Dynamic Linking:
    dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ',
ddlflags='-dll -nologo -nodefaultlib -release  -libpath:"C:\Perl\lib\CORE"  
-machine:x86'


Characteristics of this binary (from libperl):
  Compile-time options: MULTIPLICITY USE_ITHREADS PERL_IMPLICIT_CONTEXT
PERL_IMPLICIT_SYS
  Locally applied patches:
   ActivePerl Build 613
  Built under MSWin32
  Compiled at Mar 24 2000 12:36:25
  @INC:
    C:/Perl/lib
    C:/Perl/site/lib
    .


[win98]$ perl -v

This is perl, v5.6.0 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)

Copyright 1987-2000, Larry Wall

Binary build 613 provided by ActiveState Tool Corp.
http://www.ActiveState.com
Built 12:36:25 Mar 24 2000

Perl may be copied only under the terms of either the Artistic License or
the
GNU General Public License, which may be found in the Perl 5.0 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'.  If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.







--
Josiah Bryan
jdb@wcoil.com
Tel: 937.316.6256





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

Date: Thu, 21 Sep 2000 11:14:53 +0200
From: "udoline" <udo.kuehne@inatec.com>
Subject: Unrecognized character \327
Message-Id: <8qcjqb$f8ahj$2@ID-25523.news.cis.dfn.de>

hi ,

what's wrong in my code

(i test my own filter more info www.cpan.org  modules : Filter-1.18)

Unrecognized character \327 at test.pe line 2.

thankX
--
udoline




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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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


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