[23947] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6148 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 17 18:05:43 2004

Date: Tue, 17 Feb 2004 15:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 17 Feb 2004     Volume: 10 Number: 6148

Today's topics:
        Bewildered:  "my" variable drops out of scope (John Doe)
    Re: Bewildered:  "my" variable drops out of scope <ittyspam@yahoo.com>
    Re: Bewildered:  "my" variable drops out of scope <uri@stemsystems.com>
    Re: Bewildered:  "my" variable drops out of scope <tassilo.parseval@rwth-aachen.de>
    Re: CGi parameters lost <tadmc@augustmail.com>
    Re: CGi parameters lost <nospam@bigpond.com>
    Re: configure, WIN32 <tmohr@s.netic.de>
    Re: do not reload <No_4@dsl.pipex.com>
    Re: Example of web application done right? <ceo@nospan.on.net>
    Re: Example of web application done right? <gnari@simnet.is>
    Re: generate a list of file extensions? <bik.mido@tiscalinet.it>
        Mail::Bulkmail - multipart breaks when doing mail merge (Patrick)
    Re: more stripping <hillmw@ram.lmtas.lmco.com>
    Re: OPEN( , Get , or slurping problem <noreply@gunnar.cc>
    Re: OPEN( , Get , or slurping problem <bik.mido@tiscalinet.it>
    Re: OPEN( , Get , or slurping problem <bik.mido@tiscalinet.it>
    Re: Perl memory allocation <nospam-abuse@ilyaz.org>
    Re: Problem with Perl/Tk <usenet@morrow.me.uk>
    Re: RDBMS to hold Perl objects? <bobx@linuxmail.org>
    Re: RDBMS to hold Perl objects? <ceo@nospan.on.net>
    Re: RDBMS to hold Perl objects? <ceo@nospan.on.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 17 Feb 2004 11:09:57 -0800
From: workingstiff19@hotmail.com (John Doe)
Subject: Bewildered:  "my" variable drops out of scope
Message-Id: <440d3e16.0402171109.5a7c1052@posting.google.com>

I'm stumped!  Debugger indicates that the value of $timestamp changes
from something to '' on the 2nd "if" line below.  If the "my
$timestamp" declaration is moved up out of the while loop so that
$timestamp is global, it works.  Why?

Re-read that section of the best book on Perl [1] and read perlsub on
"my."
####################################################################
#  For each line in the error log:
#
while (<ERRORLOG>) {
    chomp;
    my $timestamp;  #  IS THIS SCOPE NOT FOR THE ENTIRE WHILE LOOP?
    #
    # Trap the last timestamp line before the error:
    #
    if (/Mon|Tue|Wed|Thu|Fri|Sat|Sun/) {
       $timestamp = "$`$&$'"; # IT GETS SET HERE OK.
    }
    if (/fail|bad|oops/) {  #  ...BUT HERE IT BECOMES '' (null)!!
           print "$timestamp: ";  #  THIS PRINTS NOTHING!
           print "$`$&$'";  
    }
}    # end of while loop
####################################################################
FYI, my version of Perl is:
$ perl -version

This is perl, v5.8.1 built for i386-linux-thread-multi

------------------
[1] That would be "Learning Perl" by Schwartz & Phoenix


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

Date: Tue, 17 Feb 2004 14:29:00 -0500
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Bewildered:  "my" variable drops out of scope
Message-Id: <20040217141812.J23965@dishwasher.cs.rpi.edu>

On Tue, 17 Feb 2004, John Doe wrote:

> I'm stumped!  Debugger indicates that the value of $timestamp changes
> from something to '' on the 2nd "if" line below.  If the "my
> $timestamp" declaration is moved up out of the while loop so that
> $timestamp is global, it works.  Why?
>
> Re-read that section of the best book on Perl [1] and read perlsub on
> "my."
> ####################################################################
> #  For each line in the error log:
> #
> while (<ERRORLOG>) {
>     chomp;
>     my $timestamp;  #  IS THIS SCOPE NOT FOR THE ENTIRE WHILE LOOP?
>     #
>     # Trap the last timestamp line before the error:
>     #
>     if (/Mon|Tue|Wed|Thu|Fri|Sat|Sun/) {
>        $timestamp = "$`$&$'"; # IT GETS SET HERE OK.
>     }
>     if (/fail|bad|oops/) {  #  ...BUT HERE IT BECOMES '' (null)!!
>            print "$timestamp: ";  #  THIS PRINTS NOTHING!
>            print "$`$&$'";
>     }
> }    # end of while loop
> ####################################################################


$timestamp's scope is not "for the entire while loop" as you said.  It is
actually for one iteration of the loop.  At the end of each iteration,
$timestamp goes out of scope.  When the next iteration begins, a new
$timestamp is redeclared, having the undefined value.  That's why you're
seeing different values for $timestamp within the two if statements -
you're looking at different iterations.

On a side note, why are you using the performance-hitting $`, $&, and $'
variables?  Especially when you're just squishing them back together to
reform whatever was in $_ to begin with...

Paul Lalli


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

Date: Tue, 17 Feb 2004 19:32:24 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Bewildered:  "my" variable drops out of scope
Message-Id: <x7ptcdy01k.fsf@mail.sysarch.com>

>>>>> "JD" == John Doe <workingstiff19@hotmail.com> writes:

  JD> while (<ERRORLOG>) {
  JD>     chomp;
  JD>     my $timestamp;  #  IS THIS SCOPE NOT FOR THE ENTIRE WHILE LOOP?
  JD>     #
  JD>     # Trap the last timestamp line before the error:
  JD>     #
  JD>     if (/Mon|Tue|Wed|Thu|Fri|Sat|Sun/) {
  JD>        $timestamp = "$`$&$'"; # IT GETS SET HERE OK.

don't use $& as it will slow down other regexes in your code. this has
been fixed i think for very recent perls but it is still not good style
IMO.


  JD>     }
  JD>     if (/fail|bad|oops/) {  #  ...BUT HERE IT BECOMES '' (null)!!

are you sure it is passing that regex AND the previous one for each line
you process?

  JD>            print "$timestamp: ";  #  THIS PRINTS NOTHING!

it isn't out of scope for if that were true you would get a compile time
error (i assume strict is enabled since you are using my).

  JD>            print "$`$&$'";  

no need for 2 prints there, one longer string is fine.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: 17 Feb 2004 20:00:10 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Bewildered:  "my" variable drops out of scope
Message-Id: <c0trsa$p1a$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Uri Guttman:

> don't use $& as it will slow down other regexes in your code. this has
> been fixed i think for very recent perls but it is still not good style
> IMO.

As far as I know its bad effects have just been softened a little (but
I am not even sure that this has happened). bleadperl's perlvar.pod
still gives the old suggestion not to use it.

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


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

Date: Tue, 17 Feb 2004 16:13:10 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: CGi parameters lost
Message-Id: <slrnc354fm.4m3.tadmc@magna.augustmail.com>

Damu Zhang <damu@wharton.upenn.edu> wrote:

> We are having a CGI issue, 


Then you are in the wrong newsgroup.

We discuss Perl here in the Perl newsgroup.

They discuss CGI over in the CGI newsgroup:

      comp.infosystems.www.authoring.cgi


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


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

Date: 17 Feb 2004 22:53:42 GMT
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: CGi parameters lost
Message-Id: <c0u61l$1bpe0r$1@ID-202028.news.uni-berlin.de>

Damu Zhang wrote:

> We are having a CGI issue, our clients send parameters via form POST, but
> sporadically the values turn be to empty, and it happened all of sunden
> since early last week. Anyone has the same issue?

Yes, it happens to me every Monday.

gtoomey


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

Date: Tue, 17 Feb 2004 22:50:38 +0100
From: Torsten Mohr <tmohr@s.netic.de>
Subject: Re: configure, WIN32
Message-Id: <c0u2be$6a5$1@schleim.qwe.de>

Hi,

> README.win32 (you *have* read it?) says you need to use dmake and the
> makefile in win32/. Looking at it, you should (maybe) be able to get a
> static build by unpacking the extensions you need under ext/ and then
> changing the definition of STATIC_EXT in makefile.mk to include them
> all. DYNAMIC_EXT should be empty.

thanks for that hint.  Yes, i have read README.win32, but i skipped
makefile.mk as it didn't work with nmake.  I'll get dmake and try...


Best regards,
Torsten.



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

Date: Tue, 17 Feb 2004 19:58:09 +0000
From: Big and Blue <No_4@dsl.pipex.com>
To: Bill Smith <wksmith@optonline.net>
Subject: Re: do not reload
Message-Id: <40327251.3020309@dsl.pipex.com>

Bill Smith wrote:
 >
> I have had this problem and I think I understand it.]

    But it is not a Perl problem - it is an HTTP one.

> When your user selects his browser's "BACK" button, the browser usually
> displays a local copy of the previous page rather than requesting an
> update from the server.  You probably cannot change this behavior.

    The browser does not usually display a local copy.  It depends on how 
the browser is configured.  It may be set to check on each loading, check 
once per session, always assumethe cache entry is valid, etc..  This 
setting *is* client depending and you can't affect it.

>  I have worked around the problem by providing a button (usually called
> "PREV") which does what you intend.  I turned out that it was often
> useful to have both options available.

    It would be interesting to know what this button did that was so 
different to the user clicking on "Back".

    This really is all to do with the HTTP protocol.  The best thing to do 
is probably something like:

a) Send an Expires header.  Although look up HTTP1.0 vs. HTTP1.1 
differences here, and various things you may also wish to set for proxying 
and caches.

b) Handle IfModifiedSince headers (of course, you will have to decide 
whether the content would have changed since the time the client sends). 
(The relevant reply if no change is needed is just to send back the 
relevant HTTP status, but I can't remember what that is at the moment.)

-- 
      -*-    Just because I've written it here doesn't    -*-
      -*-    mean that you should, or I do, believe it.   -*-



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

Date: Tue, 17 Feb 2004 20:24:12 GMT
From: Chris <ceo@nospan.on.net>
Subject: Re: Example of web application done right?
Message-Id: <MLuYb.36950$zQ4.24153@newssvr33.news.prodigy.com>

thumb_42@yahoo.com wrote:
> Simon McCaughey <simonmcc@nortelnetworks.com> wrote:
> 
>><thumb_42@yahoo.com> wrote in message
>>news:iySXb.43206$_44.39503@attbi_s52...
>>
>><snip>
>>
>>>As far as the web front.. I would really not recommend perl for this
>>
>>What would you recommend? and what did you use?
> 
> 
> We used perl, and regretted it for the web interface.

What exactly does that mean?  If by this you mean that you used 'print' 
statements to your HTTPD output stream (eg. print qq{<table border=0 
cellpadding=0 cellspacing=0>}) then, yes, I would agree with you.  On 
that count NO language that outputs to an HTTPD stdout stream gets along 
very well,  Perl "here" documents are an improvement and better most 
languages, but still aren't the answer in large-scale web applications.

If by "we used Perl" you mean you used something like HTML::Template or 
Template Toolkit, then I am surprised at your statement.  IMO, 
HTML::Template coupled with Perl, separates the logic from the 
presentation about as well as anything and provides much flexibilty and 
power.  I much prefer this technique to PHP.  It sounds like you didn't 
use a templating solution.

I'm not trying to sound bigoted because this is c.l.p.m.  I'm *in* 
c.l.p.m because I've *been* bigoted *by* Perl.  (I hope you see the 
difference).  I've used a lot of so called "web solutions" out there -- 
ASP, PHP, JSP, CF, Ruby, even .NET etc. -- and I keep coming back to 
Perl.  It rocks them all AFAIC.

> 
> I might go with java servlets if I were to do it again, or try and find a
> way to get PHP to do it. mod_perl wasn't very stable IMO.
> 

I'm very surprised at this statement as well; mod_perl is "the bomb" -- 
it's rock solid.  mod_perl on an Apache server can do ANYTHING.  I'm not 
trying to cast a shadow on you or the resources you had available to 
you, but I can't help but express surprise at some of your statements, 
because entirely the opposite has been true for me.

Give me Perl/mod_perl, Apache, MySQL, and HTML::Template and I'll put 
together a multi-tiered, multi-server, load-balanced web solution that 
would better anything (probably faster) put together by Java, PHP or 
JSP.  My opinion, but I'll bet many here would second it.

> 
>>Did you manage without session data? or how did you handle this problem?
> 
> 
> No.. the sessions were a constant struggle.

The most pain-free solution I have come up with for "sessions" in a 
load-balancing situation is to take this data to the back-end or add 
this as a separate tier as well.  The extra time and resources taken for 
lookups is worth the pain it removes esp. if your back-end solution is 
tuned properly.

I'm hoping soon to see the Berkeley XML DB put through it's paces in 
just such a scenario.  For session coupling as as well as backend object 
persistence.

Chris
-----
Chris Olive
chris -at- --spammer-speed-bump-- technologEase -dot- com
http://www.technologEase.com
(pronounced "technologies")


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

Date: Tue, 17 Feb 2004 22:33:45 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: Example of web application done right?
Message-Id: <c0u4qj$rnl$1@news.simnet.is>

"Chris" <ceo@nospan.on.net> wrote in message
news:MLuYb.36950$zQ4.24153@newssvr33.news.prodigy.com...
> thumb_42@yahoo.com wrote:
> > Simon McCaughey <simonmcc@nortelnetworks.com> wrote:
> >
> > I might go with java servlets if I were to do it again, or try and find
a
> > way to get PHP to do it. mod_perl wasn't very stable IMO.
> >
>
> I'm very surprised at this statement as well; mod_perl is "the bomb" --
> it's rock solid.

I agree. mod_perl is pretty stable.
unless you do not use strict. then all bets are off.

gnari






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

Date: Tue, 17 Feb 2004 23:13:29 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: generate a list of file extensions?
Message-Id: <0e0530db5aeojgmo0jhfuqi1hrv4ur2siu@4ax.com>

On Tue, 17 Feb 2004 06:31:09 -0800,
"davido@codethought.nospamforme.com" <me@privacy.net> wrote:

>>Sorry to say this, but it may be that Perl is not strictly necessary
>>for this task, and neither convenient.
>
>Actually, yes it is.  This code must run in Win32, Linux and Tru64.
>The suggestion you made, while excellent, leaves Win32 in the cold.

Well, it was just an aside... as an aside to the aside, since cygwin
is not an option as you clearly state in another post, maybe it is
worth to point out that there do exist "native" ports of *nix
utilities to win32 platforms. I have UNXUTILS/UNXUPDATES.

Said this, if it has to be in perl, then you already got good answers,
but just as a reminder, File::Find & hashes are your (good) friends!

It can still be a (sort of fat) one-liner:


C:\TEMP>perl -lMFile::Find -e "find sub { return unless -f and
s/.*\.//; $a{$_}++ }, shift; print for sort keys %a" stuff\tmp2
GIF
JPG
MPG
PPT
bz2
css
gif
gz
htm
html
ion
jpeg
jpg
js
log
mp3
mpg
pdf
txt
zip


[Note that the script is all on one line: returns are artifacts both
of the DOS console and of my newsreader]

But for anything even slightly more complex, please do yourself a
favour and write a proper warnings- and strict-enabled script...


Michele
-- 
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
  "perl bug File::Basename and Perl's nature"


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

Date: 17 Feb 2004 12:04:05 -0800
From: ptully@avatartechnology.com (Patrick)
Subject: Mail::Bulkmail - multipart breaks when doing mail merge
Message-Id: <657d2e10.0402171204.51429e42@posting.google.com>

Hi, I've been using Mail::Bulkmail for a while now but never had to do
both a mail merge and mutlipart togeather.  I recently wrote a program
that SHOULD send a multipart email and do a mail merge.  Both of these
work fine separately, however, when i do a mailmerge, multipart breaks
and sends the message like it was text.  I even checked the header to
the sent email and indeed it does have content-type: text/plain.  I'm
using Mail::Bulkmail v3.12 (latest) Here is my code:

    my $server = Mail::Bulkmail::Server->new('Smtp' => "localhost",
                                             'Domain' => "localhost",
                                             "Port" => 25
                                             ) || die
Mail::Bulkmail::Server->error();

    $server->max_connection_attempts(2);
    $server->Tries(5);
    $server->connect()||die "Couldn't connect";

my $message = ("MIME-Version: 1.0\n".
               "Content-type: multipart/alternative; boundary =
$BOUNDARY\n\n".
               "--$BOUNDARY\n".
               "Content-type: text/plain; charset=ISO-8859-1\n\n".
               "$message_text\n\n".
               "--$BOUNDARY\n".
               "Content-type: text/html; charset=ISO-8859-1\n".
               "Content-Transfer-Encoding:
7bit\n\n$message_html\n\n");

    my $bulk = Mail::Bulkmail::Dynamic->new(
                                            "LIST"          => \@data,
                                            "From"          => $from,
                                            "ReplyTo"       =>
$replyto,
                                            "Subject"       =>
$subject,
                                            "headers_from_message" =>
1,
                                            "Message"       =>
$message,
                                            "merge_keys"    =>
\@merge_keys,
                                            "servers"       =>
[$server],
                                            ) || die
Mail::Bulkmail->error();

This does the mailmerge just fine, however it sends the message as
plain text?!?!

When i comment out the line merge_keys and replace LIST with:
         "LIST" =>['my@emailaddress.com']

in the bulk objectIt sends the multipart message just fine (of course,
i no longer have a mail merge).  How do i do both of these things to
work togeather?  Am i doing something wrong?   Please let me know


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

Date: Tue, 17 Feb 2004 15:11:19 -0600
From: Michael Hill <hillmw@ram.lmtas.lmco.com>
To: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: more stripping
Message-Id: <40328377.A58C87A0@ram.lmtas.lmco.com>



> > The input looks like:
> >
> >   <path fill="none" stroke="#000000" d="M0.437,185.49l87-156"/>
> >   <path fill="none" stroke="#000000" d="M87.437,29.49l140-29"/>
> >   <path fill="none" stroke="#000000" d="M227.437,0.49l39,118"/>
> >   <path fill="none" stroke="#000000" d="M266.437,118.49l-104,160"/>
> >   <path fill="none" stroke="#000000" d="M159.437,276.49l-32-101"/>
> >   <path fill="none" stroke="#000000" d="M127.437,175.49l-127,10"/>
> >
>
> I don't understand why you're doing any of this.  Why are you taking so
> much effort to remove the stuff you don't want, instead of just taking
> what you *do* want?
>

Good Point !

>
> foreach $line (@pairs) {
>         ($x, $y) = $line =~ /M(\d+\.\d+),(\d+\.\d{2})/;
>         push @arr, [$x, $y];
> }
>
> Now @arr is populated the way you claim to want it.

I am just getting

x:    0.437     y:    185.49

It just storing the first occurrence.

Mike



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

Date: Tue, 17 Feb 2004 22:01:05 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: OPEN( , Get , or slurping problem
Message-Id: <c0u03g$1c7lhe$1@ID-184292.news.uni-berlin.de>

Ben Morrow wrote:
> Gunnar Hjalmarsson wrote:
>>Michele Dondi wrote:
>>>But then, if he *really* wants to open() the downloaded HTML, he
>>>could do that "in memory":
>>>
>>>  # untested
>>>  open my $file, '<', \$site or die $!;
>>>  do_something while <$file>;
>>
>>Well, I tested, and it just made my script hang.
> 
> Yesss... $site has no newlines in.

Yes, in my suggestion it has. :)

I figured out that the reason for my problems was that I run my test 
script in taint mode. Untainting $site:

     $site = $1 if $site =~ /(.*)/s;

does not make a difference, and I don't get any meaningful error 
message. (Only "Premature end of script headers".)

But when running the script without tainting enabled, it worked fine.

Anybody who has experienced this odd behaviour due to taint mode?

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



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

Date: Tue, 17 Feb 2004 23:13:30 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: OPEN( , Get , or slurping problem
Message-Id: <e82530tuuvl1lno6tln5kijc0f1iemhgqf@4ax.com>

On Tue, 17 Feb 2004 13:08:46 +0100, Gunnar Hjalmarsson
<noreply@gunnar.cc> wrote:

>>   # untested
>>   open my $file, '<', \$site or die $!;
>>   do_something while <$file>;
>
>Well, I tested, and it just made my script hang.

I assumed that $site contains the downloaded page as a string (as of
the snippet I *quoted* in my post):

  my $site = get 'http://www.webbuyeruk.co.uk/links.htm';

Since I'm offline now:


  #!/usr/bin/perl
  
  use strict;
  use warnings;
  
  my $site=<<"END";
  <html>
  very minimal HTML indeed!
  </html>
  END
    
  open my $fh, '<', \$site or die 
   $!;
  /!$/ and print while <$fh>;
  
  __END__


Michele
-- 
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
  "perl bug File::Basename and Perl's nature"


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

Date: Tue, 17 Feb 2004 23:13:31 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: OPEN( , Get , or slurping problem
Message-Id: <ru2530t6vrgo2ki6sl3ddjh24q10uqog0i@4ax.com>

On Tue, 17 Feb 2004 12:40:41 +0000 (UTC), Ben Morrow
<usenet@morrow.me.uk> wrote:

>> Well, I tested, and it just made my script hang.
>
>Yesss... $site has no newlines in. Michele meant something more like
                ^^^^^^^^^^^^^^^^^^

Hmmm, It shouldn't make a difference: see the following (tested),

  #!/usr/bin/perl -l
  
  use strict;
  use warnings;
  
  open my $fh, '<', \('foo') or die $!;
  print <$fh>;
  
  __END__


>my $html = get $site;

But... hey! For once I *think* I paid attention: go back to my post, I
wasn't referring to the OP's script (and hence $site), I quoted some
code where my $site is your $html. (Please forgive me for the pun!)


Michele
-- 
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
  "perl bug File::Basename and Perl's nature"


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

Date: Tue, 17 Feb 2004 21:27:47 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Perl memory allocation
Message-Id: <c0u10j$10g1$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
Bernard El-Hagin 
<bernard.el-haginDODGE_THIS@lido-tech.net>], who wrote in article <slrnc33t04.10c.bernard.el-haginDODGE_THIS@gdndev25.lido-tech>:
> > $var = undef; ??? What is this?

> > undef $var; That is!!! :)))

> Same thing.

Absolutely not (unless you mean v5.002 or so, do not remember exactly
when I fixed this):

>perl -MDevel::Peek -wle "$a='asdf';$a=undef; Dump $a"
SV = PV(0x40c64) at 0x5885c
  REFCNT = 1
  FLAGS = ()
  PV = 0x47c48 "asdf"\0
  CUR = 4
  LEN = 5

>perl -MDevel::Peek -wle "$a='asdf';undef $a; Dump $a"
SV = PV(0x40c64) at 0x5885c
  REFCNT = 1
  FLAGS = ()
  PV = 0

Hope this helps,
Ilya


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

Date: Tue, 17 Feb 2004 20:59:40 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Problem with Perl/Tk
Message-Id: <c0tvbs$k11$1@wisteria.csv.warwick.ac.uk>


Orion93 <orion93@club-internet.fr> wrote:
> From the script below I try to make an interface in Perl/Tk to be able to 
> choose the repertory directly. The initial script count lines for all pl 
> files in one directory.
>  
> Initial Script:
> #!/usr/bin/perl
> sub recupPages
> {

SORT OUT YOUR INDENTING.

> my $nomFic = shift;
> my $result = shift;
> 
> # Récupération des lignes du fichier
> open(F,$nomFic);
> open(SORTIE,">> $result");

There's no point opening this file anew every time: open it once, and
pass a filehandle in.

> $i = 0;
> while(<F>)
> {
> $i ++;
> }
> print SORTIE " $nomFic $i\n";
> 
> close F;
> close SORTIE;}
> 
> my $emplacement = "e:\\Dossier_travail\\stat\\";
> my $ficResultat = "e:\\result.txt";
> recupPages($_, $ficResultat) for glob 'e:\\Dossier_travail\\stat\\*.pl';
>
> Current script:
>  
> #!/usr/bin/perl
> use strict;
> use warnings;
> use Tk;
> use diagnostics;
> 
> my $main = MainWindow -> new;
> $main -> title("Test 1");
> $main -> Label(-text=>"Chemin:")->pack();
> $main -> Entry()->pack(-padx=>5);

The original script had two parameters: $emplacement and $ficResultat.
This box has only one text entry: which of the two parameters is it
supposed to set?

> $main->Button(-text=>'Ok',-command=>\my $recupPages)->pack(-side=>'left', 
                                     ^^^^^^^^^^^^^^^^
Might I ask what you *thought* that would do? You can't just make shit
up and expect the computer to understand. The -command option takes a
reference to a sub: what you have there is a reference to a scalar
variable.

I would suggest that you probably want to leave the sub recupPages as it
is (well, except for fixing the indentation, using lexical FHs and not
reopening the file every time :), and write a new sub (to be given as
the -command parameter) that extracts the required data from the form,
does the glob and calls recupPages on the results.

> expand=>1);
> $main->Button(-text=>"Fermer",-command=>sub {exit;})->pack(-side=>'right', 
> expand=>1);
> MainLoop();
> 
> sub recupPages
> {
> # my $rep= my $resupPages->get();
> my $result = shift;
> # Récupération des lignes du fichier
> open (F,"$recupPages");

What are you thinking here? I just don't understand. What value were you
expecting to be in the variable $recupPages?

> open (SORTIE,">> my $result");
> my $i = 0;
> while(<F>)
> {
> $i ++;
> }
> print SORTIE " my $recupPages $i\n";
> close F;
> close SORTIE;
> }

> #my $emplacement = @rep;
> my $ficResultat = "e:\\result.txt";
> recupPages($_, $ficResultat) for glob '$nomFic\*.pl';

Again: when did you think this code would be executed? It seems fairly
clear now that you want it to execute when the OK button is pressed; but
for that to happen it would have to be in or called from the sub you
passed as the -command parameter to that button.

Ben

-- 
               We do not stop playing because we grow old; 
                  we grow old because we stop playing.
                            ben@morrow.me.uk


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

Date: Tue, 17 Feb 2004 17:02:14 -0500
From: Robert <bobx@linuxmail.org>
Subject: Re: RDBMS to hold Perl objects?
Message-Id: <WeGdncrLh9X6Eq_dRVn-hg@adelphia.com>

thumb_42@yahoo.com wrote:
> Aaron Sherman <ajs@ajs.com> wrote:
> 
>>Robert <bobx@linuxmail.org> wrote in message news:<EPGdnc6NrZvyeb_d4p2dnA@adelphia.com>...
>>
>>>Randal L. Schwartz wrote:
>>>
>>>>If you want a free RDBMS, there's plenty.  I recommend DBD::SQLite as
>>>>a serverless solution, or DBD::Pg and PostgreSQL as a proper database.
>>>>Stay away from MySQL for new installations, no point in it anymore.
>>>>
>>>
>>>Simply wrong! Now once PG goes native on Windows THEN I see no point. 
>>>Until then MySQL it is. Firebird is looking really good as well. ;-)
>>
>>Using google groups, so please understand I would have set a
>>followup-to if I could :-(
>>
>>MySQL is the easiest database to maintain that I've ever used. It fits
>>in with the UNIX Tao quite nicely and manages tables the way a UNIX
>>admin would expect.
> 
> 
> I'd have to agree with Randall Schwartz on this one. (well, kind of anyhow..)
> 
> Postgresql is better as a "proper database". Supports transactions, and as
> far as I know, always did. MySQL - maybe it does, maybe it doesn't, you have
> to check to be sure.
> 
> Transactional support is essential for any serious work.

I would say that there are a whole bunch of sites currently on the 
Internet that would disagree with you.

> MySQL is nice when you have data that is almost always read-only, until it
> ships with transaction support enabled by default, AND mysql with
> transaction support is most common, I don't trust it. (maybe it's changed
> some since I last truly explored it)
> 
> I'd much perfer mysql for an addressbook, but even a recipe collection could
> be riddled with issues, since the ingredients might be relational you could
> end up with missing parts. If the application has no real support for adding
> recipes, (Ie: it's added once or on occasion from a mirror or something, and
> you just need a web query interface then MySQL might be an ideal choice)
> 
> Of course, mysql IS more common than postgresql. :-(
> 
> Jamie

It IS more common and it does better as a x-plaform solution. Postgresql 
is working on that. By that time though Firebird 1.5 will be out and I 
will be using it. It is a *proper* database and x-platform to boot.

Robert


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

Date: Tue, 17 Feb 2004 22:50:03 GMT
From: Chris <ceo@nospan.on.net>
Subject: Re: RDBMS to hold Perl objects?
Message-Id: <vUwYb.36972$qk5.27462@newssvr33.news.prodigy.com>

Randal L. Schwartz wrote:

> Stay away from MySQL for new installations, no point in it anymore.

Because why?  I'm really curious as to your reason for stating this like 
you did without at all implying that I disagree (since you mention 
PostgreSQL).

Chris
-----
Chris Olive
chris -at- --spammer-speed-bump-- technologEase -dot- com
http://www.technologEase.com
(pronounced "technologies")


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

Date: Tue, 17 Feb 2004 22:55:22 GMT
From: Chris <ceo@nospan.on.net>
Subject: Re: RDBMS to hold Perl objects?
Message-Id: <uZwYb.36973$2i5.2510@newssvr33.news.prodigy.com>

Robert wrote:
> Randal L. Schwartz wrote:
> 
>> If you want a free RDBMS, there's plenty.  I recommend DBD::SQLite as
>> a serverless solution, or DBD::Pg and PostgreSQL as a proper database.
>> Stay away from MySQL for new installations, no point in it anymore.
>>
> Simply wrong! Now once PG goes native on Windows THEN I see no point. 
> Until then MySQL it is. Firebird is looking really good as well. ;-)
> 
> Of course he didn't say a platform so the whole argument is a moot one.

Maybe it would be prudent to ask Randal why he said what he said rather 
than responding like this.  Surely he has a good reason for saying so. 
It's not like Randal's some clueless newbie Perl poster...  Since I've 
already asked him, maybe you would enjoy considering his reason(s) when 
he responds.

I'm not sure how Firebird validates the existance of MySQL...?

Chris
-----
Chris Olive
chris -at- --spammer-speed-chump-- technologEase -dot- com
http://www.technologEase.com
(pronounced "technologies")


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

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


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 6148
***************************************


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