[12366] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5966 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 11 20:07:20 1999

Date: Fri, 11 Jun 99 17:00:25 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 11 Jun 1999     Volume: 8 Number: 5966

Today's topics:
    Re: comparing substrings of array values <rootbeer@redcat.com>
    Re: defined() and my variables <cmertz@my-deja.com>
    Re: defined() and my variables <uri@sysarch.com>
    Re: dimensions of a jpg file <cassell@mail.cor.epa.gov>
        Disokaying files in a Browser <Reggy@Cistron.nl>
    Re: File upload/download Web app. <emschwar@rmi.net>
    Re: File upload/download Web app. <cassell@mail.cor.epa.gov>
    Re: Formmail with Credit Card Validation problems elklabone@my-deja.com
    Re: Formmail with Credit Card Validation problems <webmaster@chatbase.com>
    Re: Formmail with Credit Card Validation problems <webmaster@chatbase.com>
    Re: HELP:Hash mapping of subroutines with params kgentes@gentek.net
    Re: how do i refresh frames from perl? <webmaster@chatbase.com>
    Re: How to diagnose/fix internal errors? <rootbeer@redcat.com>
    Re: How to write search engine like yahoo? (Benjamin Franz)
    Re: if (my $a=1) { } print $a; Why do i get undef an no <janning@vygen.de>
    Re: if (my $a=1) { } print $a; Why do i get undef an no <uri@sysarch.com>
    Re: if (my $a=1) { } print $a; Why do i get undef an no (Larry Rosler)
        Large String handling <brekevel@worldonline.nl>
        MacPerl and sending records to filemaker: apple events? (Rory C-L)
    Re: mod_perl require problem <rootbeer@redcat.com>
        Multicast support on perl <amotaib@nymex.com>
    Re: NT Perl - .plx work, .pl don't <rootbeer@redcat.com>
    Re: Perl class and constructor <cassell@mail.cor.epa.gov>
    Re: Perl LWP mod on Win98 <rootbeer@redcat.com>
        Perl Script - HELP! <bill@svn.net>
    Re: problems with specific words in text field <webmaster@chatbase.com>
    Re: Silly Question: Define "Wrapper" <uri@sysarch.com>
    Re: Where is sendmail on NT using Perl <divirgil@hotmail.com>
    Re: Which .gz file to download for Net::Cmd.pm ? <cassell@mail.cor.epa.gov>
        write the output of eval to a string? <info@java.seite.net>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Fri, 11 Jun 1999 16:57:32 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: comparing substrings of array values
Message-Id: <Pine.GSO.4.02A.9906111649220.6999-100000@user2.teleport.com>

On Fri, 11 Jun 1999 bernd1615@my-deja.com wrote:

> I have an array of string values and
> I want to compare a substring of these strings.

I don't know what you mean by that. From looking at your (quite confusing)
code, I think you're wanting to know how many different strings are found
in your array. For that, use a hash. If that's not it, please try asking
again. If English is not your native language, feel free to ask in a
language you're better at. Good luck!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 11 Jun 1999 20:50:23 GMT
From: Craig Mertz <cmertz@my-deja.com>
Subject: Re: defined() and my variables
Message-Id: <7jrsqb$pma$1@nnrp1.deja.com>

In article <gdkqj7.s07.ln@magna.metronet.com>,
  tadmc@metronet.com (Tad McClellan) wrote:
> cmertz@my-deja.com wrote:
> : Following is a little code that outlines a
> : problem I'm encountering. The problem is that
> : defined() is responding differently to blank
>   ^^^^^^^
> : input to a function based on whether or not any
> : valid input was ever passed to the function.
>
> : I expected %h to go completely out of scope when
> : func() returns.
>
>    You should adjust your expectations to coincide with the
>    documented behavior of functions that you use.
>
>       perldoc -f defined
>
>    reveals:
>
> ---------------------
> On the other hand, use
> of C<defined()> upon aggregates (hashes and arrays) is not guaranteed
to
> produce intuitive results, and should probably be avoided.
>
> ..
>
> Currently, using C<defined()> on an entire array or hash reports
whether
> memory for that aggregate has ever been allocated.  So an array you
set
> to the empty list appears undefined initially, and one that once was
full
> and that you then set to the empty list still appears defined.  You
> should instead use a simple test for size:
>
>     if (@an_array) { print "has array elements\n" }
>     if (%a_hash)   { print "has hash members\n"   }
>
> ..
>
> This counterintuitive behavior of C<defined()> on aggregates may be
> changed, fixed, or broken in a future release of Perl.
> ---------------------
>
> --
>     Tad McClellan                          SGML Consulting
>     tadmc@metronet.com                     Perl programming
>     Fort Worth, Texas
>

So is there no good way to consistently tell the difference between an
empty hash/array and undefined hash/array (given this "feature")?

Thanks


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


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

Date: 11 Jun 1999 18:22:00 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: defined() and my variables
Message-Id: <x7vhcuidiv.fsf@home.sysarch.com>

>>>>> "CM" == Craig Mertz <cmertz@my-deja.com> writes:


  CM> So is there no good way to consistently tell the difference between an
  CM> empty hash/array and undefined hash/array (given this "feature")?

there is generally no need to. empty hashes and arrays are tested in a
scalar context and that works fine and is correct and proper. this is
not a really good reason to test an aggregate for defined. this has been
discussed here and on p5p where some advocate making defined on an
aggregate a syntax error. unfortunately there are popular modules
(cgi.pm among them) that use it that way. they have to be fixed for the
change to work so it may never happen. in any case DON'T use defined on
aggregates.

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


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

Date: Fri, 11 Jun 1999 15:42:13 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: dimensions of a jpg file
Message-Id: <376190C5.5EA157D8@mail.cor.epa.gov>

Jonathan Stowe wrote:
> 
> [big snip of everyone else]
> It looks like you have failed to install Image::Size correctly - You need

I agree on that one.

> to have the directory c:\perl\lib\site\image containing the files from
> the distribution - I am pretty certain there is no PPD file for easy
> installation from Activestate and I am also pretty sure there are no
> XS componenents to worry about.

But this is in the ActiveState repository.  He only has to type:

   ppm install Image-Size

to get it and its associated parts.
 
> > [more snips]
> > screen settings.  If the user has 1024 x 768 or 800 x 600, or whatever the
> > case may be...
> 
> None of this can be done in a CGI program - if you need to find out more
> you might want to ask in some group in the comp.infosystems.www.* hierarchy.

It sounds to me like he's trying to do the wrong thing in his
layout.  Pixels instead of percents, perhaps.  The GUIs like
Front Page conveniently conceal the fact the HTML is *not*
page layout [in the FrameMaker sense].  Oh well...

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Sat, 12 Jun 1999 00:16:07 +0200
From: "Reggy van Meurs" <Reggy@Cistron.nl>
Subject: Disokaying files in a Browser
Message-Id: <7js1m7$n3q$1@enterprise.cistron.nl>

Hello pls help.

I want to display a log file, with a browser.

The log file is on a location at the http server.

How can i do that ??





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

Date: 11 Jun 1999 16:34:56 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: File upload/download Web app.
Message-Id: <xkfn1y6mkmn.fsf@valdemar.col.hp.com>

Jonathan Stowe <gellyfish@gellyfish.com> writes:
> OK the job's yours - you can start on Monday:  I suppose it would only be
> fair to mention that the last person who took it on is in Broadmoor now.

Wow, really?  Cool!  Last I heard, rooms there were upwards of
$200/night!  OTOH, there is the Tavern, and the Golden Bee.  I think they 
took down the Maxfield Parrish that was hanging in the lobby, though.

-=Eric "oh wait, wrong Broadmoor"


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

Date: Fri, 11 Jun 1999 15:35:23 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: File upload/download Web app.
Message-Id: <37618F2B.5DB74189@mail.cor.epa.gov>

Jonathan Stowe wrote:
> [snip]
> 
> OK the job's yours - you can start on Monday:  I suppose it would only be
> fair to mention that the last person who took it on is in Broadmoor now.

I was hoping they were in Arkham.  It's much easier to bust 
out of, and we can use the help.  :-)

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Fri, 11 Jun 1999 21:25:56 GMT
From: elklabone@my-deja.com
Subject: Re: Formmail with Credit Card Validation problems
Message-Id: <7jruso$qia$1@nnrp1.deja.com>

Both scripts are shareware widely available on about every script
archive on the net...

As for reducing the script to 40 lines, if I knew how to do that I'd
probably be smart enough to fix the script!

Thanks for the help.

In article <xkfogimk2rv.fsf@valdemar.col.hp.com>,
  Eric The Read <emschwar@rmi.net> wrote:
> elklabone@my-deja.com writes:
> <snip>
>
> > # Copyright 1996 Dave Paris (aka Spider)  All
> > Rights Reserved.               #
> > #
>
> <snip>
>
> > # Obtain permission before redistributing this
> > software over the Internet or #
> > # in any other medium.
>
> Call it a hunch, but I bet you didn't get permission to redistribute
this
> software on USENET.  I'm certainly not about to go tattle, but if
anybody
> was so inclined, they'd be able to get you in a bunch o' trouble.
>
> Besides, why did you have to post a 1316-line program?  You should be
> able to reduce it to a 40-line example that illustrates your problem
> quite well.  If you can't, then you probably don't understand the
problem
> well enough anyway.
>
> -=Eric
>


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


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

Date: Fri, 11 Jun 1999 16:44:29 -0700
From: TRG Software : Tim Greer <webmaster@chatbase.com>
Subject: Re: Formmail with Credit Card Validation problems
Message-Id: <37619F5D.87CE250C@chatbase.com>

elklabone@my-deja.com wrote:
> 
> I'm trying to combine formmail.cgi with a script
> that does simple credit
> card validation.  It won't work if the card# is
> valid - formmail hangs and
> won't send mail.  I'm sure this is simple to a
> lot of you guys, but I'm
> pretty new at this.  I would greatly appreciate
> any help.  I've attached the
> script.  Please respond to
> elklabone@terraworld.net

<SNIP ridiculously huge bad code>

#1: When you post asking for help with a script, just post the relevant
parts, not the entire code. Anyone that is able to tell you what's wrong
with the code (assuming you provide the relevant and needed parts and
explain your problem in the appropriate manner), will know what the rest
of it is doing.

#2: This NG isn't a place to post code and say it doesn't work and ask
for help. That is annoying and a waste of bandwidth to start. This NG is
more specifically geared towards help on coding then anything else, but
there are other relevant issues.. But posting someone's code and asking
for someone here to help you get it running, is NOT the purpose of this
NG.

#3: I didn't look very closely at the codes, but I saw enough to know
it's bad code. It's bad enough to make use of Matt's scripts, but to
further go and just paste it into another, is just a completely bad
idea.

I'm sorry that I can't offer help, because I'd have to know some info
about your system to start off with. For all I know, you just have the
wrong path to sendmail, or more likely, you've pasted the other code to
send the email after the end of the prior code, so it exits before it
continues. This is just such a bad idea, I can't even comment about it
anymore then I have. Please don't do this, it's not a good idea in any
way, it's bad code, it's a bad way to go about your task. The best way
to go about it, is to learn how it works and do it yourself, or so you
can make the needed changes to existing scripts to better them, fix
their bugs, or just know they are a waste of time. It may seem nice that
it works, until it breaks and screwed something up.

May I suggest that you go to the sites that you downloaded the scripts
from and read their help sections? They are specifically geared towards
helping people install the very scripts in question. If you are having a
problem that has to do with Perl (other then the program just being
coded in Perl), then feel free to ask after you've done the proper
research.

Good luck.
-- 
Regards,
Tim Greer: chatmaster@chatbase.com / software@linkworm.com
Chat Base: http://www.chatbase.com | 250,000+ hits daily Worldwide!
TRG Software: http://www.linkworm.com | CGI scripting in Perl/C, & more.
Unix/NT/Novell Administration, Security, Web Design, ASP, SQL, & more.
Freelance Programming & Consulting, Musician, Martial Arts, Sciences.


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

Date: Fri, 11 Jun 1999 16:53:08 -0700
From: TRG Software : Tim Greer <webmaster@chatbase.com>
Subject: Re: Formmail with Credit Card Validation problems
Message-Id: <3761A164.1A968B52@chatbase.com>

Just to make myself clear, as I don't think this paragraph came out to
sound as I intended, then I said:
 
> #2: This NG isn't a place to post code and say it doesn't work and ask
> for help.

I had specifically meant it as in regards to people taking an entire
script that someone else coded, having no idea what it does, how it
works, etc. and are just here to ask for help in getting it working.
Just because it's coded in Perl, doesn't mean that it's a Perl issue.
You need to consider other issues, of which may be a problem with your
OS and you're calling a Unix command on an NT server, or it's the wrong
permissions, or you have paths wrong, or any other many number of
reasons. Worse yet, taking code from one program, and pasting it
directly into another rarely works, and it's always a bad idea. Please
don't make your problem worse, figure out how it works and what it's
doing and why, and then attempt to fix it, add to it, or delete it and
write your own. Matt's scripts and many other others have URL's
specifically for help on running, installing and configuring the
scripts, so please use them and go there first... Then get Learning Perl
by O'Reilly and learn how Perl functions, and then more onto Programming
Perl by O'Reilly if you're still interested in it. Within a few weeks
you should be writing better code then Matt does, and you'll be much
more happier knowing you can make any changes, fix any problems, and
create custom programs yourself and not have to wait and hope someone
answers with help.
-- 
Regards,
Tim Greer: chatmaster@chatbase.com / software@linkworm.com
Chat Base: http://www.chatbase.com | 250,000+ hits daily Worldwide!
TRG Software: http://www.linkworm.com | CGI scripting in Perl/C, & more.
Unix/NT/Novell Administration, Security, Web Design, ASP, SQL, & more.
Freelance Programming & Consulting, Musician, Martial Arts, Sciences.


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

Date: Fri, 11 Jun 1999 22:18:23 GMT
From: kgentes@gentek.net
Subject: Re: HELP:Hash mapping of subroutines with params
Message-Id: <7js1v8$rij$1@nnrp1.deja.com>

I figured out what I was doing wrong.. it was a
cockpit error... I was actually getting errors,
but thought it was because I was using Perl to
do something it couldn't do (pass params through
subroutines invoked from hash references).  The
errors were not because Perl doesn't support this,
but rather because I was using the wrong variable
as the associative hash index.  It was my fault.

btw, I posted the from a dejanews web connection,
knowing that I couldn't test further from where I
was at the time.  In response a few people berated
me for note trying it myself. Actually, I had been
trying it myself.  I just couldn't at the time of
the post.  Why would anyone post to the group if
they had not already tried something first hand?

Kim Gentes



In article <7jk4ml$27g$1@nnrp1.deja.com>,
  kgentes@gentek.net wrote:
> Hey there..
>  Is this ok?
>
> ==============================================================
> if ($States{$page}) {
>    $States{$page}->($myvariable, $yourvariable); # call the subroutine
> } else {
>    no_such_page();
> }
> Sent via Deja.com http://www.deja.com/


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


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

Date: Fri, 11 Jun 1999 17:03:59 -0700
From: TRG Software : Tim Greer <webmaster@chatbase.com>
Subject: Re: how do i refresh frames from perl?
Message-Id: <3761A3EF.A0215E7F@chatbase.com>

Bastiaan S van den Berg wrote:
<SNIP>

> have you ever tried posting something there?
> i need to confirm my posting , so i did
> 
> now , at least 30mins ago , it's still not posted!!!
> am i going crazy , or is that newsgroup badly moderated??
> 
<SNIP>

Actually, I have to defend that statement. :-)

I didn't use to have any problems posting in the CGI NG until recently,
and then it was less posts showing up, and now none of my posts show up.
So, I figure either I've somehow stepped on the toes of the wrong
person, or there's a serious problem with it.

Either way, it makes it rather difficult to post answers to help people,
and I've probably posted a good 100 answers in the last month, and maybe
two showed up. Maybe it's just me, so you can try to put "passme" in a
line all by itself in your message body and hope for the best, even
though it doesn't work for me... I tried to search dejanews and even
tried 3 different news readers, and still, no traces of my posts.. and
that's the NG I usually offered the most help in too. :-/
-- 
Regards,
Tim Greer: chatmaster@chatbase.com / software@linkworm.com
Chat Base: http://www.chatbase.com | 250,000+ hits daily Worldwide!
TRG Software: http://www.linkworm.com | CGI scripting in Perl/C, & more.
Unix/NT/Novell Administration, Security, Web Design, ASP, SQL, & more.
Freelance Programming & Consulting, Musician, Martial Arts, Sciences.


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

Date: Fri, 11 Jun 1999 15:58:29 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: How to diagnose/fix internal errors?
Message-Id: <Pine.GSO.4.02A.9906111552130.6999-100000@user2.teleport.com>

On 9 Jun 1999, Diego Zamboni wrote:

> Attempt to free unreferenced scalar during global destruction.
> Segmentation fault (core dumped)

> Could it be something in my program?

Not in any Perl parts of your program; no valid Perl code should dump
core. (Except for that one function which always does!)

> Something in Linux? Something in the Linux port of Perl?

It could be a bug in your library routines or it could be that your perl
binary is miscompiled. More likely, it's a bug in some XS code you're
using in a module, I suspect.

You should probably try (again) to make a small example which reliably
replicates the problem. Then you may need to submit it to the authors of
any modules whose XSUBs you're using, and perhaps eventually to the Perl
development team. 

Good luck!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 11 Jun 1999 22:02:40 GMT
From: snowhare@long-lake.nihongo.org (Benjamin Franz)
Subject: Re: How to write search engine like yahoo?
Message-Id: <4If83.339$dL1.3596@typhoon-sf.snfc21.pbi.net>

In article <3760F433.61FE4F77@netvigator.com>,
wilson  <wilson33@hongkong.com> wrote:
>
>Hi, I live in taiwan. I want to write a chinese search engine like
>yahoo.
>Is Perl as a first choice? Has any web site to teach people how to write
>a search engine? Thank you for helping.

Do you mean a search engine or a directory? Yahoo is primarily a directory,
with a search engine tacked on. If all you want is directory functionality,
you could try my BookMarker script (written in Perl), available at
<URL:http://www.nihongo.org/snowhare/utilities/bookmarker/> as a starting
point to see how such a thing can be put together.

If you are looking for a free ranging search engine (like Alta Vista
or Exite), there is no publically available tool for that in Perl
AFAIK. You *can* do it (See <URL:http://www.vietgate.net/> for an
example of such a Perl based search engine) - but it is non-trivial.

-- 
Benjamin Franz


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

Date: Fri, 11 Jun 1999 23:59:17 +0200
From: Janning Vygen <janning@vygen.de>
To: Craig Ciquera <craig@mathworks.com>
Subject: Re: if (my $a=1) { } print $a; Why do i get undef an not "1" ??
Message-Id: <376186B5.F735D730@vygen.de>

i know this!
But it doesnt fit to the definition of the my() function in the camel
book!
and why does it behave different if i say

$a++ if (my $a=getValue());
print $a;

i thought that "if () {}" and <statement> if (); are equivalent.

Craig Ciquera wrote:
> 
> In this case $a's scope is only applicable to the if block.  Try this:
> 
> my $a;
> 
> if ($a==1) {  } print $a;
> 
> or
> 
> my $a;
> if ($a = getValue()) {} print $a;
> 
> Craig
> 
> Janning Vygen wrote:
> 
> > i want to assign $a the value of 1.
> > its just an example. In a real world script 1 would be the return value
> > of a function like
> > if (my $a=getValue()) { } print $a;
> > i just want to know why i cant see my $a after the if statement
> >
> > greetings, janning
> >
> > mikecard@my-deja.com wrote:
> > >
> > > Janning Vygen <janning@vygen.de> wrote:
> > > > if (my $a=1) {
> > >
> > > if you want to check to see if $a is equal to 1 you need to write if
> > > $a==1  when you say if $a = 1 i believe you are assigning $a the value
> > > of 1.
> > >
> > > mike cardeiro
> > >
> > > Sent via Deja.com http://www.deja.com/
> > > Share what you know. Learn what you don't.


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

Date: 11 Jun 1999 18:26:15 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: if (my $a=1) { } print $a; Why do i get undef an not "1" ??
Message-Id: <x7so7yidbs.fsf@home.sysarch.com>

>>>>> "JV" == Janning Vygen <janning@vygen.de> writes:

  JV> i know this!
  JV> But it doesnt fit to the definition of the my() function in the camel
  JV> book!
  JV> and why does it behave different if i say

  JV> $a++ if (my $a=getValue());
  JV> print $a;

  JV> i thought that "if () {}" and <statement> if (); are equivalent.

they are equivilent logically but not with regard to scope. the latter
modifies a simple statement and so no scoping is changed and changes to
$a are seen in the statement and afterwards. the former create a new
block and the my $a is scoped to that block including the conditional.
so any changes to $a are not see after the block closes.

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


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

Date: Fri, 11 Jun 1999 16:07:46 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: if (my $a=1) { } print $a; Why do i get undef an not "1" ??
Message-Id: <MPG.11cb369e74f1d0b989bc6@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <x7so7yidbs.fsf@home.sysarch.com> on 11 Jun 1999 18:26:15 -
0400, Uri Guttman <uri@sysarch.com> says...
> >>>>> "JV" == Janning Vygen <janning@vygen.de> writes:
> 
>   JV> i know this!
>   JV> But it doesnt fit to the definition of the my() function in the camel
>   JV> book!
>   JV> and why does it behave different if i say
> 
>   JV> $a++ if (my $a=getValue());
>   JV> print $a;
> 
>   JV> i thought that "if () {}" and <statement> if (); are equivalent.
> 
> they are equivilent logically but not with regard to scope. the latter
> modifies a simple statement and so no scoping is changed and changes to
> $a are seen in the statement and afterwards. the former create a new
              ^^^^^^^^^^^^^^^^  not so -- see below
> block and the my $a is scoped to that block including the conditional.
> so any changes to $a are not see after the block closes.

It's not that simple.  Rewriting Janning's snippet to avoid the funcion 
call:

#!/usr/local/bin/perl -w
use strict;

$_ = 2;
$a++ if (my $a = $_);
print "$a $main::a\n";
__END__

Output:

2 1

$a is declared and defined in line 5, but not yet usable in line 5.

>From perlsub:

The declared variable is not introduced (is not visible) until after the 
current statement. Thus, 

    my $x = $x;

can be used to initialize the new $x with the value of the old $x, and 
the expression 

    my $x = 123 and $x == 123

is false unless the old $x happened to have the value 123.

 ...

I don't understand why 'use strict;' allowed those two uses of $main::a 
without a declaration, though.  That seems like a botch.  This is all 
rather muddled, I fear. 

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


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

Date: Fri, 11 Jun 1999 23:52:57 +0200
From: "F. Brekeveld" <brekevel@worldonline.nl>
Subject: Large String handling
Message-Id: <37618538.D0EAC25E@worldonline.nl>

Hi,

I have a very large string with repeated parts, actually it is a HTML
page, and I want to split it into lines
how to do that ?

The page looks like:

<TR><TD    .........></TD></TR><TR><TD>......</TD></TR>

I want everything between the <TR><TD> and </TD></TR> on a separate line
for further processing


Thanks,

Feite Brekeveld



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

Date: Fri, 11 Jun 1999 23:32:28 +0100
From: 'x'campbell-lange@easynet.co.uk (Rory C-L)
Subject: MacPerl and sending records to filemaker: apple events?
Message-Id: <'x'campbell-lange-1106992332280001@campbell-lange.easynet.co.uk>

Title:Perl ouput to Filemaker

Apologies if this seems to be too much of an os specific posting

I have a Perl script that selects paragraphs containing search words in a
number of documents and outputs these to a set of text files.

Instead of 
   print OUT ....
   
I'd like to push the paragraphs into a Filemaker database.

I have an applescript (running fine on OS8.5 and filemaker 4 via a
keystroke assigned to it in OSA menu - available free from Leonard
Rosenthal's site <www.lazerware.com>) that tells filemaker to make a new
record and insert text into subject and paragraph fields. This is of the
type:

   tell app "Filemaker"
      create new record with data {"subject","paragraph"}
   end tell
   
although the script actually works be setting the subject from a line
input into a dialog box, and the paragraph is taken from the clipboard.

I was hoping to do something like this from Perl:
   
   foreach $subject (sort(keys%search)) {
      MacPerl::DoAppleScript(<<END_SCRIPT);
      tell application "Filemaker"
         create new record with data {"$subject","$search{$subject}"}
         end tell
      END_SCRIPT 
   }
   
This doesn't work. In fact I haven't had much success doing anything more
complicated that "choose folder with prompt xyz" or display dialog "OK"!
when calling Applescript from MacPerl. I'd be grateful for some advice. 

Also (apologies for all the questions), is there a way to precompile an
applescript into MacPerl? I imagine that this would significantly speed up
the script I'm attempting above.

Should I be calling MacPerl from Applescript in the first place?
   (as in Chris' pod example:
           tell application "MacPerl"
          return ,
            "Days until the year 2000: " & (Do Script "
          use Time::Local;
          $d1 = timelocal(0,0,0,1,0,100);
          $d2 = ($d1 - time()) / 60 / 60 / 24;
          MacPerl::Reply(int($d2))
          ")
        end tell
       )
       
Then again, should I be using Apple Events?

The Filemaker Apple Event guide describes the following for creating a new
anything:
   
   Send:
   Event ID          'crel', kAECreateElement
   Class ID & Constant 'core' kAECoreSuit
   Parameters:
   keyAEData         'data'   (Data for new element)
   keyAEInsertHere      'insh'   (location of element)
   keyAEObjectClass  'kobc'   (Element class to create)
   keyAEPropData     'prdt'   (the initial data for the element's properties???)

   Reply:
   keyAEResult       '----'   (The object specifier for the new event)
   
   Chris also suggests in his pod tutorial suggests one get hold of
aete.converter. Where can I get this? 
   I have to admit that I got lost pretty early on in the AE tutorial.

Thanks for any responses

-- 
Rory Campbell-Lange
The Campbell-Lange Workshop
Remove the 'x' to reply

-- 
please remove the 'x' to reply


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

Date: Fri, 11 Jun 1999 16:36:28 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: mod_perl require problem
Message-Id: <Pine.GSO.4.02A.9906111630500.6999-100000@user2.teleport.com>

On Fri, 11 Jun 1999, Jason Eggleston wrote:

> I have written a mod_perl cgi script that "require()"s another script.
> Unfortunately, the functions in the script are not always available.

How do you mean? Is someone editing the script while you're using it? 

> BEGIN { require '/home/httpd/html/stdinc.pl'; }

If that require is failing, you should read the helpful error message
which perl is giving you.

> local $| = 1;

I'm not sure why you're using local here.

Good luck with it!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 11 Jun 1999 18:29:46 -0400
From: "Abdel Motaib" <amotaib@nymex.com>
Subject: Multicast support on perl
Message-Id: <ydg83.202$_S1.6327@client.news.psi.net>

Is there a module for multicast, which would allow you to join multicast
groups and create multicast sockets.

Thanks




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

Date: Fri, 11 Jun 1999 16:59:54 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: NT Perl - .plx work, .pl don't
Message-Id: <Pine.GSO.4.02A.9906111658190.6999-100000@user2.teleport.com>

On Fri, 11 Jun 1999, Ron Jones wrote:

>   Perl scripts named .plx work just fine when served from the web
> server, but scripts named .pl are tyring to be downloaded instead of
> executed.

If you need an extension for your Perl programs, you should use only .plx,
really, since .pl is for Perl Library files. But if you're asking how to
configure your webserver to do things differently, see the docs, FAQs, and
newsgroups about webserers. Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 11 Jun 1999 15:47:18 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Perl class and constructor
Message-Id: <376191F6.B06EFD05@mail.cor.epa.gov>

Ala Qumsieh wrote:
> [snipperoonie]
>
> Of course you can do this. But this defeats the whole idea of
> object-oriented programming. Unlike a real OO language (like C++),
> Perl doesn't have private and public data. You can go ahead and access

I disagree.  Perl is a real OO language if you want it.  Just
because it does things differently [i.e. better] than C++ doesn't
make it non-OO.  But maybe we should ask one of the real OO
gurus around here.

Just MHO, of course...
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Fri, 11 Jun 1999 16:29:53 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Perl LWP mod on Win98
Message-Id: <Pine.GSO.4.02A.9906111627280.6999-100000@user2.teleport.com>

On Fri, 11 Jun 1999 steeperhill@my-deja.com wrote:

> # $page = get($URL);
> 
> @page = split(/\n/,$page);

Perhaps having warnings turned on and using 'use strict' would have been
helpful to you here.

> $start= 0;
> foreach $line (@page){
>       print "$line\n"
>   }

Why not just print $page? I don't see why you're splitting it on newlines
if you're just going to print it with newlines anyway. Unless you don't
want trailing newlines at the end of the document? 

When you're having trouble with a CGI program in Perl, you should first
look at the please-don't-be-offended-by-the-name Idiot's Guide to solving
such problems. It's available on CPAN.

   http://www.perl.com/CPAN/
   http://www.perl.org/CPAN/
   http://www.perl.org/CPAN/doc/FAQs/cgi/idiots-guide.html
   http://www.perl.org/CPAN/doc/manual/html/pod/

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 11 Jun 1999 22:27:27 GMT
From: Bill Pitz <bill@svn.net>
Subject: Perl Script - HELP!
Message-Id: <37618d0e.0@news1.svn.net>

Ok, I'm a bit confused on this one.  It's probably a pretty stupid
mistake, but forgive me on that - I'm a Perl newbie.

I have attempted to write a Perl program to grep for a string ("IDENTIFIED")
out of a logfile that contains many lines without the string "IDENTIFIED"
I don't care about those lines, so I don't want them included in the
result.  It then attempts to hack down the line to just a name, which
it apparently does just fine.  The next function of the script is to
count how many times a person with that name has visited, and say
"$user was here $number times."  

First, here are a couple of lines from the logfile I'm looking in:
Thu 06/03/99 07:42:26 HEARTBEAT
Thu 06/03/99 07:43:26 HEARTBEAT
Thu 06/03/99 07:44:26 HEARTBEAT
Thu 06/03/99 07:44:29    212.16.133.43:1663     -1 CONNECTED
Thu 06/03/99 07:44:29    212.16.133.43:1663     -1 ENTER 54197 50
Thu 06/03/99 07:44:29    212.16.133.43:1663     -1 IDENTIFIED 'Verygoodgirl' 0

So in this case, I want only the last line... and then I want to chop it down
to just "'Verygoodgirl'" (The 's are important in the output because they
distinguish between a registered user and an unregistered user.)

And now, here is the script. (If anyone also has any suggestions on how to
make it more efficient, correct, etc. I would greatly appreciate it as I am
just starting to get a grasp of Perl)

----snip----
while (<>) {
        if (/IDENTIFIED/) {
                $identify = "$_";
                @idarray = split(/'/,$identify);
                @idstrings = "$idarray[-2]\n";
                chomp @idstrings;
                print @idstrings;
        foreach $visitor(@idstrings) {
                foreach $visitorx(@idstrings) {
                $count{$visitorx} = $count{visitorx} + 1;
                }
                foreach $visitor(keys %count) {
                print "$visitor was here $count{$visitor} times.\<br>\ \n";
                }
        }
}
}
----snip----

And then when I run the script, this is the output I get:

$ ./logrep.pl world.log
VerygoodgirlVerygoodgirl was here 1 times.<br> 
BossVerygoodgirl was here 1 times.<br> 
Boss was here 1 times.<br> 
AshleyVerygoodgirl was here 1 times.<br> 
Ashley was here 1 times.<br> 
Boss was here 1 times.<br> 

What happens (case in point, first and second lines of output) is that it's
taking each name, merging it somehow with another name, and then creating
too many results.  There are only 3 actual people who visited: Verygoodgirl,
Boss, and Ashley.

This really has me puzzled.

Thanks in advance for any help...

Bill


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

Date: Fri, 11 Jun 1999 16:56:47 -0700
From: TRG Software : Tim Greer <webmaster@chatbase.com>
Subject: Re: problems with specific words in text field
Message-Id: <3761A23F.895D5000@chatbase.com>

Arie wrote:
> 
> I have got some forms that are generated
> dynamically by perl, and for the most part
> they work great.  One problem I am having,
> however, is when the user enters the
> word "action" in the text fields.  For some
> reason the script handles it oddly.
> Everything after, and including, the
> word "action" is eliminated when it is
> written to the database.  Is there any way
> around this problem?  It would be of great
> help if we could actually allow the user to
> enter the word "action"  If you need me to
> post the script just let me know

Provide some of your code (only the relevant parts though, please) and
maybe someone can offer some help. Right off, and by your post, I can't
make a guess as to why, but if you post the code I bet I can tell you
within a few seconds.
-- 
Regards,
Tim Greer: chatmaster@chatbase.com / software@linkworm.com
Chat Base: http://www.chatbase.com | 250,000+ hits daily Worldwide!
TRG Software: http://www.linkworm.com | CGI scripting in Perl/C, & more.
Unix/NT/Novell Administration, Security, Web Design, ASP, SQL, & more.
Freelance Programming & Consulting, Musician, Martial Arts, Sciences.


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

Date: 11 Jun 1999 18:13:34 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Silly Question: Define "Wrapper"
Message-Id: <x7yahqidwx.fsf@home.sysarch.com>

>>>>> "SE" == Sped Erstad <serstad@my-deja.com> writes:

  SE> This may or may not show my ignorance, but can someone give me a good
  SE> definition of the term "wrapper" -- I'm pretty sure that I'm using it
  SE> correctly, but would like some confirmation:

  SE> I'm pretty much gathering that it's just a function (or routine,
  SE> whatever) whose main purpose is to call another fucntion -- usually with
  SE> some more restrictions so as to "protect" that function a little bit.
  SE> Kind of like a function with a little "value-addedness" to it.

pretty much on target. though value added may not be what is being
done. there are many uses for 'wrappers' so it is tough to pin the term
down. almost any sub or program that wraps another is a wrapper
(circular, i know). they can provide extra features, a different api,
side effects, security, default values, etc. consider most x widget
toolkits are really a wrapper on the x core.

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


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

Date: Fri, 11 Jun 1999 21:06:11 GMT
From: diVirgil <divirgil@hotmail.com>
Subject: Re: Where is sendmail on NT using Perl
Message-Id: <7jrtns$q2c$1@nnrp1.deja.com>

I had the same problem

I believe u can find a Windows NT version of sendmail @:
www.winfiles.com
but I don't know....
b/c I solved my problem by using some random SMTP mail server someone
set-up in our building...  ;)
if u find an SMTP server...
use the LWP or libwww mod.

--
thanx4playing
http://www.toad.net/~divirgil


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


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

Date: Fri, 11 Jun 1999 15:32:31 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Which .gz file to download for Net::Cmd.pm ?
Message-Id: <37618E7F.C5B6AFFC@mail.cor.epa.gov>

I R A Aggie wrote:
> 
> On Fri, 11 Jun 1999 19:21:05 GMT, dwang999@my-deja.com
> <dwang999@my-deja.com>, in <7jrniq$nnd$1@nnrp1.deja.com> wrote:
> 
> + I try to download the Net::Cmd.pm from CPAN but could not find which
> + .tar.gz file to download. Any help is appreciated.
> 
> I was about to guess[*]. But I realized that I could be lazy and accurate.
> If you don't have the CPAN module installed, get it. Install it. Use
> it.

Or you could be even lazier, like me.  Examining his page
source shows:

   X-Http-User-Agent: Mozilla/4.5 [en] (WinNT; I)

So we probably ought to be directing him to ActiveState's
ppm package repository.

> % perl -MCPAN -e shell
> 
> cpan shell -- CPAN exploration and modules installation (v1.50)
> ReadLine support enabled
> 
> cpan> i /Net::Cmd/
> [blahblahblah]
>     CPAN_VERSION 2.12
>     CPAN_FILE    GBARR/libnet-1.0606.tar.gz
> [blahblahblah]
> 
> Answer: it's in libnet...
> 
> James
> 
> [*] libnet was my guess...

so he can go to his command prompt and type:

   ppm install libnet

and go on to others things...

BTW, why am I proud to be so darn lazy?

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Sat, 12 Jun 1999 01:30:18 +0200
From: Christoph Bergmann <info@java.seite.net>
Subject: write the output of eval to a string?
Message-Id: <37619C0A.7628@java.seite.net>

hi...


i have a tricky problem and can't figure out a nice solution:

i've got a string containing perl code, which makes some output with
"print". i want to "eval" this code and write the output NOT to STDOUT
but to another string.


for example:

$x='$z=5; print "Hi ho..."; print $z*7; (..and much more code..)';

eval $x;

$y=(..the output of eval $x..???);


1. first idea was to set STDOUT to a file handle:

open(TMPFILE, ">blah.tmp"); $oldselect=select(TMPFILE);
eval $x;
close TMPFILE; select($oldselect);

open(FILE, "bla.tmp");
undef $/; $y=<FILE>;
close FILE; unlink "blah.tmp";

--> but i don't like this solution, because i think its a needless,
clumsy detour using a file when its already all in memory.


2. second idea is a pipe:

pipe EVALIN, EVALOUT; $oldselect=select(EVALOUT); $|=1;
eval $x;
read EVALIN, $y, 100000;
close EVALOUT; close EVALIN; select($oldselect);

this works fine unless the output of "eval" isn't longer than the buffer
of the pipe! (512 Bytes on my system) The program stops infinitely if it
is longer because "eval" can't write in the buffer and waits for someone
to empty it - what will never happen, because it would happen AFTER the
"eval"...

--> the question is: is it possible to increase the size of the buffer
of the pipe? if so, it would be possible to set it to, lets say, 100000
and it would be a practicable solution (with the risk that the output
COULD be greater than 100000 and then the program hangs)


3. i can't use "fork" and stuff because (unfortunately) it should run
under windows as well...


4. the best thing would be if i could open a file handle which writes
directly to a string...

--> is there a possibility to do this??? (if not, why not?? i think this
would be a very useful feature... larry? ;-) 


5. last and least i thought about substituting every "print" in
something like "$y.=sprintf" - but this is useless if there are more
arguments to "print" than one or something like "%s" in the string

--> is there a possibility to simulate the equivalent to "sprintf" -->
"sprint" ?



i really hope somebody can help because i spent some hours on this
problem and i can't believe there is a good solution (would be the first
time that perl wouldn't offer the answer...  ;-)



best regards,

christoph bergmann



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

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


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". 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". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 5966
**************************************

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