[17353] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4775 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 31 14:10:40 2000

Date: Tue, 31 Oct 2000 11:10:20 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <973019419-v9-i4775@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 31 Oct 2000     Volume: 9 Number: 4775

Today's topics:
        howto fork() an object northward@my-deja.com
    Re: I am learning Perl. Help, please. <bart.lateur@skynet.be>
    Re: LWP::UserAgent & loading images? joekind@my-deja.com
        Net::SMTP and subject? <ruedas@geophysik.uni-frankfurt.de>
    Re: Net::SMTP and subject? nobull@mail.com
    Re: Net::SMTP and subject? rathmore@tierceron.com
        New Perl Sites mysangam@my-deja.com
    Re: New Perl Sites <elaine@chaos.wustl.edu>
    Re: Newbie question about hashes <cak@putzl.com>
    Re: Newbie question about hashes <cak@putzl.com>
        Newbie..... <vertical.reality@ntlworld.com>
    Re: Newbie..... <ek@internet-designs.no>
        Non-ASCII characters and Net::LDAP <nospam.newton@gmx.li>
        ODBC - Newbie having problems (P&C)
        oops <celliot@tartarus.uwa.edu.au>
    Re: OT: Re: Is there a more perlish way to write this? (Tom Christiansen)
    Re: OT: Re: Is there a more perlish way to write this? (Anno Siegel)
    Re: OT: Re: Is there a more perlish way to write this? <ren.maddox@tivoli.com>
    Re: OT: Re: Is there a more perlish way to write this? (Richard J. Rauenzahn)
    Re: Passing data to a script(from a form) gopringle@my-deja.com
    Re: Perl and Outlook craber@my-deja.com
    Re: Perl CGI (Keith Calvert Ivey)
    Re: Perl CGI <fty@hickory.engr.utk.edu>
        pop: strange results and errors mark.c.hamlin@bt.com
        Problem Passing Test With Msql-Mysql-modules-1.2215 <npasich@sd.cts.com>
    Re: pseudo-parallel command execution northward@my-deja.com
    Re: Q on returning hashes from subroutines <pavel@gingerall.cz>
    Re: Query (Learning perl) (Tom Christiansen)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 31 Oct 2000 18:33:58 GMT
From: northward@my-deja.com
Subject: howto fork() an object
Message-Id: <8tn3am$5ce$1@nnrp1.deja.com>

Hi everybody,

there are lot's of postings on howto use Perl's fork() command,
but I think a got a new question:

Has anyone ever tried to fork a Perl object (meaning an instance of a
class)? I'm currently writing a program using OOP style and Perl's
lack of true threads is a bit of a problem.

My idea was to create a base class with some "create_thread()" method
like this:

---- cut ---------

sub create_thread {
	...
	$pid = fork();
	if ($pid == 0) {
		&thread_run();
		exit 0;
	}
	elsif ($pid > 0) {
		$SIG{'CHLD'} = ...
	}
}

sub thread_run {
	...
	# whatever
}

---- cut ----------------

and overriding the "thread_run()" method in derived classes...

Unfortunately all my tries have let too enormous consumption of memory,
the main process waiting for the forked one to exit or freak errors :-(

any ideas ?

thanxs for your help,
tok


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


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

Date: Tue, 31 Oct 2000 14:40:26 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: I am learning Perl. Help, please.
Message-Id: <vbmtvs4qum0dnmffulf1b4e87tua0svpva@4ax.com>

zhong9999@my-deja.com wrote:

>Subject: I am learning Perl. Help, please.

>1). If I want to hide my perl scripts, 
>so nobody can look at my scripts.

This makes me wonder what you could possibly find so marvelous about
your own scripts that you really want to prevent others from stealing
them from you.

-- 
	Bart.


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

Date: Tue, 31 Oct 2000 15:18:28 GMT
From: joekind@my-deja.com
Subject: Re: LWP::UserAgent & loading images?
Message-Id: <8tmnrs$q8v$1@nnrp1.deja.com>

Can anyone help me?

In article <8tkjr0$36t$1@nnrp1.deja.com>,
  joekind@my-deja.com wrote:
> Hi, I have a script that connects to a few sites and just extracts
> certain text.  I was wondering if there was a way when using
> LWP::UserAgent to connect to the sites and make sure that it does not
> load any images in order to speed my script up?
> Do I have to add something like:
> $response->header('Accept' => 'text/html');
>
> Here is my code:
> my $ua = new LWP::UserAgent;
> $ua->timeout ($FORM{'timeout'});
> $ua->agent("AgentName/0.1 " . $ua->agent);
> my $request = new HTTP::Request 'GET', $search;
> my $response = $ua->request ($request);
> $response_body = $response->content();
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>


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


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

Date: Tue, 31 Oct 2000 16:39:52 +0100
From: Thomas Ruedas <ruedas@geophysik.uni-frankfurt.de>
Subject: Net::SMTP and subject?
Message-Id: <39FEE7C8.86E95E35@geophysik.uni-frankfurt.de>

Hello,
is there a possibility to specify a subject line in the mail header when
using Net::SMTP?
-- 
Sign the Linux Driver petition:
http://www.libralinux.com/petition.english.html
------------------------------------------------------------------------
Thomas Ruedas
Institute of Meteorology and Geophysics, J.W.Goethe University Frankfurt
e-mail: ruedas@geophysik.uni-frankfurt.de
http://www.geophysik.uni-frankfurt.de/~ruedas/
------------------------------------------------------------------------


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

Date: 31 Oct 2000 17:43:44 +0000
From: nobull@mail.com
Subject: Re: Net::SMTP and subject?
Message-Id: <u9wveosy7j.fsf@wcl-l.bham.ac.uk>

Thomas Ruedas <ruedas@geophysik.uni-frankfurt.de> writes:

> is there a possibility to specify a subject line in the mail header when
> using Net::SMTP?

Yes, just do it.  Net::SMTP doesn't have any special handling for
headers.

BTW: This question has been asked in the last week.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Tue, 31 Oct 2000 18:14:20 GMT
From: rathmore@tierceron.com
Subject: Re: Net::SMTP and subject?
Message-Id: <8tn25j$45t$1@nnrp1.deja.com>


> is there a possibility to specify a subject line in the mail header
when
> using Net::SMTP?

It might look something like this:

use Net::SMTP;

   $smtp = Net::SMTP->new($smtp_server);

   $smtp->mail($ENV{USER});
   $smtp->to($send_to);

   $smtp->data();
   $smtp->datasend("To: $send_to_name\n");
   $smtp->datasend("From: $from\n");
   $smtp->datasend("Subject: $subject\n");
   $smtp->datasend("\n");
   $smtp->datasend($body);
   $smtp->dataend();

   $smtp->quit;

Something very similar to this was in the Perl Cookbook by O'Reilly,
and also in the docs that comes with Net::SMTP.

Rathmore


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


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

Date: Tue, 31 Oct 2000 15:27:39 GMT
From: mysangam@my-deja.com
Subject: New Perl Sites
Message-Id: <8tmod1$qoo$1@nnrp1.deja.com>

Hi,
 Anyone keeping the records of the new perl sites
by time..as when they are opened?
such as Perlmonks.org or  Perldoc.com and other
useful sites.?



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


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

Date: Tue, 31 Oct 2000 16:47:23 GMT
From: "Elaine Ashton" <elaine@chaos.wustl.edu>
Subject: Re: New Perl Sites
Message-Id: <vICL5.13100$AM5.246158@news1.nokia.com>

<mysangam@my-deja.com> wrote in message
news:8tmod1$qoo$1@nnrp1.deja.com...
>  Anyone keeping the records of the new perl sites
> by time..as when they are opened?

yes. http://history.perl.org/

e.




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

Date: Tue, 31 Oct 2000 10:54:38 -0800
From: Chris Kantarjiev <cak@putzl.com>
To: nobull@mail.com
Subject: Re: Newbie question about hashes
Message-Id: <39FF156E.1CCF8310@putzl.com>

nobull@mail.com wrote:
> 
> Chris Kantarjiev <cak@putzl.com> writes:
> 
> > I'm trying to use hashes to keep track of session keys across multiple
> > socket connections (among other things). Even though I think I'm
> > creating several entries in the hash, the only key that's defined at the
> > end is the last one I put in.
> 
> >     %sessionKey = ($s, 0);
> 
> This line is executed inside your loop and throws away any previous
> content of %sessionKey.
> 
> --
>      \\   ( )
>   .  _\\__[oo
>  .__/  \\ /\@
>  .  l___\\
>   # ll  l\\
>  ###LL  LL\\

Doh! Thank you so much (and to nobull@mail.com) for pointing this out...


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

Date: Tue, 31 Oct 2000 10:59:33 -0800
From: Chris Kantarjiev <cak@putzl.com>
Subject: Re: Newbie question about hashes
Message-Id: <39FF1695.7ED54382@putzl.com>

So what's the "right" way to declare/initialize these hashes? Just do it
outside the subroutines? (One of these days I'm going to dig in and
learn how to great such things as an object...)


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

Date: Tue, 31 Oct 2000 17:31:17 -0000
From: "vertical.reality" <vertical.reality@ntlworld.com>
Subject: Newbie.....
Message-Id: <KoDL5.73427$sE.256783@news6-win.server.ntlworld.com>

I have downloaded activeperl
I have PWS (4.0 I think)
I am running Win 98
I have written a fair few html pages that call cgi scripts.
How can I view the result of the script through my browser.
How should I call the script........
How should I configure PWS......or should I not ???

Help

Tom




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

Date: Tue, 31 Oct 2000 19:29:55 +0100
From: Erland Kjensli <ek@internet-designs.no>
Subject: Re: Newbie.....
Message-Id: <39FF0FA3.BAD44F78@internet-designs.no>

"vertical.reality" wrote:
> 
> I have downloaded activeperl
> I have PWS (4.0 I think)
> I am running Win 98
> I have written a fair few html pages that call cgi scripts.
> How can I view the result of the script through my browser.
> How should I call the script........
> How should I configure PWS......or should I not ???


I also downloaded Activeperl. I installed it. I downloaded "Xitami web server"
from http://www.xitami.com . I installed it (really easy). Your CGI-BIN
directory will then most likely be located at c:\xitami\cgi-bin or something
like that. The HTML pages that reference the scripts will be located somewhere
under "c:\xitami\webpages". Then you reference the scripts from the HTML files
with "../cgi-bin/your_script.cgi". In your scripts you will have to reference
PERL with something like "#!e:\perl\bin\perl.exe" depending on where you
installed perl. Be sure to access the HTML files in your browser with the local
IP-adress (most likely 127.0.0.1) or it won't work. The IP-adress is the pointer
to c:\xitami\webpages so if you create a folder under there you can access those
through "127.0.0.1/folder_name".

Understand? (I wouldn't have, with that description)

-- 
Mvh
Erland Kjensli


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

Date: Tue, 31 Oct 2000 15:10:11 +0100
From: "Philip 'Yes, that's my address' Newton" <nospam.newton@gmx.li>
Subject: Non-ASCII characters and Net::LDAP
Message-Id: <mfktvs42jarovgq1v074mnh2hmqvgms0fo@4ax.com>

How can I get German characters such as ä ö ü into LDAP using the
module Net::LDAP (from the ActiveState packet perl-ldap 0.17 -- *not*
PerLDAP!).

What happens when I try to insert a string containing a non-ASCII
character is that the string is truncated at that point. For example,
if I try to store "Grüße", I get back "Gr".

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
If you're not part of the solution, you're part of the precipitate


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

Date: Tue, 31 Oct 2000 17:06:36 GMT
From: mailloop@localhost.com (P&C)
Subject: ODBC - Newbie having problems
Message-Id: <39fefc80.454486136@netnews.voicenet.com>

I have installed an odbc connection under the System tab. No userid
nor password has been set.

I have installed the odbc.pm packages as instructed for use with the
ActiveState versions of Perl for Win32. I login as Administrator,
switch to the appropriate directory and run the test.pl script that
came with the odbc package and specify my dsn.  The test works
fine and reports no errors.

Next, I have a file called odbc_lib.pl which contains some high level
calls, this .pl file gets included in my normal perl scripts.  The
primary functions called are:
&initialize($dsn);
&execute_sql($statement);
&finish_odbc($dsn);

The initialize call does the following:
sub initialize {
    $DSN=$_[0];
    $dB = new Win32::ODBC($DSN) || die "Cannot open datasource: ($DSN)
";
    if ($dB eq "undef")
   {
        win32::ODBC::DumpError();
    }
}

Again, I have several other odbc connections defined
this same way using this same code but with different DSN's which are
working fine.

Now the problem, if I go to my URL and type in the test.pl which came
with the ODBC package

----------------------  T E S T   Error Report: ---------------------
	Error Report:
The following were errors:
Test 3a = new(): [-1024] [] "[Microsoft][ODBC Microsoft Access Driver]
Could not use '(unknown)'; file already in use."

Also, any attempts to call my &initialize($dsn); function just returns
a blank html page.  I never get the die message nor any other messages
and the database never gets updated.

What do I do next, where do I go from here?

Thanks,

Phil
p c   a t   n t a d m i n   d o t   c o m


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

Date: Tue, 31 Oct 2000 23:56:39 +0800
From: "Cam" <celliot@tartarus.uwa.edu.au>
Subject: oops
Message-Id: <39feec1a$0$25584@echo-01.iinet.net.au>

Please ignore last post...

Its rather late here and I cant think..

--

cheers
cam
-------------------------------
Cam <celliot@tartarus.uwa.edu.au> wrote in message
news:39fee8f5$0$25553@echo-01.iinet.net.au...
| Is there a way of converting to hex without printing?
| ie take a variable and convert it to hex
|
| I have looked through the perl books I have and can only find conversion
| when printing using sprintf "$lx", $number;
|
| Does anyone know any other way?
|
|
| --
|
| cheers
| cam
|
|
|




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

Date: 31 Oct 2000 07:40:09 -0700
From: tchrist@perl.com (Tom Christiansen)
Subject: Re: OT: Re: Is there a more perlish way to write this?
Message-Id: <39fed9c9@cs.colorado.edu>

In article <8tmi3h$guu$1@lublin.zrz.tu-berlin.de>,
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>  if ( 30 <= tr/a// < 40 ) { ...

I just want to know what the return value of the expression

    OP1 RELOP OP2

would now become.  For example:

    VAR = OP1 RELOP OP2;
    VAR = OP1 RELOP1 OP2 RELOP2 OP3;

The first is currently well-defined, and the second is not
due to the non-associativity of the relops.

--tom


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

Date: 31 Oct 2000 15:51:16 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: OT: Re: Is there a more perlish way to write this?
Message-Id: <8tmppk$h87$1@lublin.zrz.tu-berlin.de>

Tom Christiansen <tchrist@perl.com> wrote in comp.lang.perl.misc:
>In article <8tmi3h$guu$1@lublin.zrz.tu-berlin.de>,
>Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>>  if ( 30 <= tr/a// < 40 ) { ...
>
>I just want to know what the return value of the expression
>
>    OP1 RELOP OP2
>
>would now become.  For example:
>
>    VAR = OP1 RELOP OP2;
>    VAR = OP1 RELOP1 OP2 RELOP2 OP3;
>
>The first is currently well-defined, and the second is not
>due to the non-associativity of the relops.

The $x <= $y < $z construct not easily described in terms of binary
operators and associativity.  Instead, RELOP1 ought to be viewed as
a ternary (or n-ary) operator of which RELOP2 (and further ones) are
a part, similar to the ternary ?: operator.  Whether logical short-
circuiting makes sense with this construct may be debatable, but a
strategy of evaluating the operands left to right until the result
is fixed seems reasonable.

If we want it it another question.  Mathematicians love it, and I was
shocked to learn that most computer languages don't grok it.  But that
was 25+ years ago, and I recovered.  Now I rather think that the very
ambiguity I pointed out makes it a questionable addition.  If it looks
like a series of binary operators, it *is* a series of binary operators.
This has been true in Perl, and it should probably remain true.

Anno


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

Date: 31 Oct 2000 10:18:59 -0600
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: OT: Re: Is there a more perlish way to write this?
Message-Id: <m3lmv5c7bg.fsf@dhcp11-177.support.tivoli.com>

tchrist@perl.com (Tom Christiansen) writes:

> In article <8tmi3h$guu$1@lublin.zrz.tu-berlin.de>,
> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> >  if ( 30 <= tr/a// < 40 ) { ...
> 
> I just want to know what the return value of the expression

I was wondering that myself.

>     OP1 RELOP OP2
> 
> would now become.  For example:
> 
>     VAR = OP1 RELOP OP2;
>     VAR = OP1 RELOP1 OP2 RELOP2 OP3;
> 
> The first is currently well-defined, and the second is not
> due to the non-associativity of the relops.

I say make the whole thing a special boolean construct that is itself
non-associative and is defined to return a true or false value -- the
same as the current RELOPs.  And I assume that it shouldn't be limited
to just two RELOPs.  Surely you would want to be able to do:

if ( 10 < $x < $y < 20 ) { ... }

etc.

-- 
Ren Maddox
ren@tivoli.com


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

Date: 31 Oct 2000 18:37:14 GMT
From: nospam@hairball.cup.hp.com (Richard J. Rauenzahn)
Subject: Re: OT: Re: Is there a more perlish way to write this?
Message-Id: <973017433.586717@hpvablab.cup.hp.com>

Ren Maddox <ren.maddox@tivoli.com> writes:
>
>I say make the whole thing a special boolean construct that is itself
>non-associative and is defined to return a true or false value -- the
>same as the current RELOPs.  And I assume that it shouldn't be limited
>to just two RELOPs.  Surely you would want to be able to do:
>
>if ( 10 < $x < $y < 20 ) { ... }

Has anyone been talking about short circuiting behavior yet?

sub foo() {
   return ++$count;
}

if(foo() > foo() > foo() > foo()) { }

How many times is foo called?  Is the answer '2' what most people
consider DWIM?

Rich
-- 
Rich Rauenzahn ----------+xrrauenza@cup.hp.comx+ Hewlett-Packard Company
Technical Consultant     | I speak for me,     |   19055 Pruneridge Ave. 
Development Alliances Lab|            *not* HP |                MS 46TU2
ESPD / E-Serv. Partner Division +--------------+---- Cupertino, CA 95014


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

Date: Tue, 31 Oct 2000 18:18:24 GMT
From: gopringle@my-deja.com
Subject: Re: Passing data to a script(from a form)
Message-Id: <8tn2d5$4b4$1@nnrp1.deja.com>

Hello Ed.

Thanks for replying.

I'm new to perl and somethings are not making sense yet.
The book that I was reading didn't talk about parsing the data
before passing it to the form or maybe it just omited that part.

What I'm having trouble understanding is how I can pass the argument
with no problems using the script under DOS but when I try to pass
it with the form it won't cooperate.

How do i go about making a subroutine that will take care of that?


Thanks,

G


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


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

Date: Tue, 31 Oct 2000 15:57:24 GMT
From: craber@my-deja.com
Subject: Re: Perl and Outlook
Message-Id: <8tmq4u$sev$1@nnrp1.deja.com>

Sigvald,

Thanks for the post. Works pretty good. Couple of points and q's:

1. I found that on my machine (Win 2k and Outlook 2000) I had to
use 'Outlook.Application' instead of 'Outlook.Application.8'. Is this
expected?

2. Under  win2k I get a dialog warning that a program is trying to send
mail from my system and may be a virus. I have to manually click a Yes
button for it to continue. As I want to use this sort of script from a
WEB application, I need to disable this security check. Does anyone
know how to enable mail from perl in this fashion while still leaving
that protection on for other possibly nefarious programs?

Thanks again,

-Chris.
Get the mobile internet in the palm of your hand at
http://www.avantgo.com/

craber@avantgo.com
cpraber@yahoo.com

In article <39E1AA87.86AC682F@siemens.no>,
  Sigvald Refsum <sigvald.refsum@siemens.no> wrote:
> This is a multi-part message in MIME format.
> --------------87FA89849BA7C8461994FE8E
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
>
> This may solve half your problem, as it sends a mail using outlook,
> the second half I simply don't know. The server we use at Siemens
> is an Exchange server, and I havent a clue to how it is accessed.
>
>     Best regards.
>     Sigvald
>
> PS
> The attached sample code is ment as an example and the code style
> is perhaps not optimal.
> DS
>
> vivi16@my-deja.com wrote:
>
> > In a Perl file I want to send the results of a form to the user via
E-
> > mail.  Is it possible to use MS Outlook as the mail program?  And
does
> > the program have to reside on the server where the Perl program is?
> >
> > I recall reading in this discussion group (though can't find it now)
> > someone saying that this might be possible (using Outlook and not
> > having it reside on the local server).
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
>
> --------------87FA89849BA7C8461994FE8E
> Content-Type: application/x-perl;
>  name="outlookSend.pl"
> Content-Transfer-Encoding: 8bit
> Content-Disposition: inline;
>  filename="outlookSend.pl"
>
> use Win32::OLE qw(in with);
>
> my $OutLook = Win32::OLE->new('Outlook.Application.8')
>    or die "Couldn't connect to Outlook";
>
> my $NewMail;
> # Create Mail object
> $NewMail = $OutLook->CreateItem(0);
>
> # Address Mail Object, can be repeated for several recipients
> $NewMail->Recipients->Add('sigvald');
>
> # CC Address Mail Object, can be repeated for several recipients
> $NewMail->Recipients->Add('sigvald');
> $NewMail->Recipients->Item('sigvald')->{Type} = 2;
>
> # Resolve addresses
> $NewMail->Recipients->ResolveAll();
>
> # Categories string
> $NewMail->{Categories} ="PVCS operation";
>
> # Voting option string
> $NewMail->{VotingOptions} ="Pizza;Salat;China";
>
> # Originator Delivery Report Requested
> $NewMail->{OriginatorDeliveryReportRequested} = 1;
>
> # Subject string
> $NewMail->{Subject} ="hei";
>
> # Body
> $NewMail->{Body} = "kåre heisan\n";
>
> #Attachments
> $NewMail->Attachments->Add('H:\C_wrk\parser\outlookSend.pl');
>
> # Print
> # $NewMail->PrintOut();
>
> # Reminder
> my $hour   = (16 * 3600)*(1/86400);
> my $minute = (20 * 60)*(1/86400);
>
> $NewMail->{FlagDueBy} = 36538+$hour+$minute;
> $NewMail->{FlagRequest} = 'Review Tue 13.01.00 16:20';
>
> # Away it goes
> $NewMail->Send;
>
> # Quit
> $OutLook->Close();
>
> --------------87FA89849BA7C8461994FE8E--
>
>


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


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

Date: Tue, 31 Oct 2000 14:03:28 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Perl CGI
Message-Id: <39fed07d.41409512@news.newsguy.com>

dVoon <dvoon@my-deja.com> wrote:

>         my $text = param('t');
>         $text = ($text =~ /\w+/)? $text: ''; # default to empty string.
>
>The last line above generate "Use of uninitialized variable..." message
>in /apache/logs/error.log file. I believe it's a warning message because
>of the -w option. Is there a way to code it in such a way so that it
>doesn't generate the warning/error message?

         $text = (defined $text and $text =~ /\w/) ? $text : '';

(Note that the + wasn't doing anything, unless you're using $&
later -- in which case you should probably be capturing.)

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

Date: 31 Oct 2000 18:02:58 GMT
From: Jay Flaherty <fty@hickory.engr.utk.edu>
Subject: Re: Perl CGI
Message-Id: <8tn1gi$flh$1@penn.dii.utk.edu>

Young Chi-Yeung Fan <yf32@cornell.edu> wrote:
> I have these lines at the beginning of my Perl CGI scripts:
> #!/usr/bin/perl -w
> use CGI::Carp qw(fatalsToBrowser);
> Is there anything else I can put in there to help me debug easier? I
> think I saw a post about that last week, but I'm having trouble finding
> it.

you can debug from the command line by inserting -debug in the use CGI
line. i.e. use CGI qw(-debug);
-- 
**********************************************************************  
Jay Flaherty                                               fty@utk.edu
"Once in awhile you get shown the light, in the strangest of places if
you look at it right" - R. Hunter
**********************************************************************



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

Date: Tue, 31 Oct 2000 18:04:39 +0000
From: mark.c.hamlin@bt.com
Subject: pop: strange results and errors
Message-Id: <39FF09B7.8FE350FC@bt.com>

I have an array called @rowRefs which is a list of references to
anonymous arrays.  

I'm having a bit of trouble with pop.  I've learnt the hard way that it
only shrinks the array if you use pop in an assignment.  The problem now
is it seems to be zappin the hole array.  What I see now just doesn't
make sense, If I skip the story and just give you the impossible bit
hopefully someone can explain the mystery that is causing the following
test result:

I run the program with a debug statement to tell me the size of the
array.  It works.  

Next I test this with a pop function on the array.  I find that it zapps
the array.  The strange thing is the debug info telling me the array
size, as it appears to zap the array before the pop statement.

I then think about scope, the code is part of a function and the array
is declared with a my.  I comment it out but the results are even
stranger:

No scope defined:
EXE1 LAST INDEX / SIZE: 0 / 1
POPED:
EXE2 LAST INDEX / SIZE: -1 / 1

Scope defined: with my in same function
EXE1 LAST INDEX /SIZE: -1 / 0
POP:
EXE2 LAST INDEX /SIZE: -1 / 0

Scope defined: with my in calling script
(not a very logical test I know)
EXE1 LAST INDEX: 0 / 1
POP
EXE2 LAST INDEX: -1 / 1

Whenever the array size was reduced the poped item was a reference to a
hash, it should hold references to lists.

I take the pop statement out and all is fine, as long as the scope is
specified in the function.  I think this might be the key, there are big
clues pointing to scope.

I know I'm doing something fundamentally silly!!!!

Many thanks for any tips.

Mark Hamlin


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

Date: Tue, 31 Oct 2000 10:07:59 -0800
From: Nick Pasich <npasich@sd.cts.com>
Subject: Problem Passing Test With Msql-Mysql-modules-1.2215
Message-Id: <39FF0A7F.B7B05613@sd.cts.com>

 
  I've  successfully compiled, tested and installed DBI-1.14, 
  Data-ShowTable-3.3 and Msql-Mysql-modules-1.2215 on 2 out
  of 3 Linux systems.

  The problem arises when running "make test" on
Msql-Mysql-modules-1.2215.
  I'm using MySql 3.22.32 and Perl v5.6.0.

  I get the following error message:
  
********************************************************************************
********************************************************************************


make[1]: Entering directory
`/zSRC/MYSQL/PERL/Msql-Mysql-modules-1.2215/mysql'
make[1]: Leaving directory
`/zSRC/MYSQL/PERL/Msql-Mysql-modules-1.2215/mysql'
make[1]: Entering directory
`/zSRC/MYSQL/PERL/Msql-Mysql-modules-1.2215/mysql'
PERL_DL_NONLAZY=1 /usr/local/bin/perl -I../blib/arch -I../blib/lib
-I/usr/local/lib/perl5/5.6.0/i586-linux -I/usr/local/lib/perl5/5.6.0 -e
'use Test::Harness qw(&runtests $verbose); $verbose=0; runtests @ARGV;'
t/*.t
t/00base............ok
t/10dsnlist.........dubious
	Test returned status 0 (wstat 11, 0xb)
t/20createdrop......dubious
	Test returned status 0 (wstat 11, 0xb)
t/30insertfetch.....dubious
	Test returned status 0 (wstat 11, 0xb)
t/40bindparam.......dubious
	Test returned status 0 (wstat 11, 0xb)
t/40blobs...........dubious
	Test returned status 0 (wstat 11, 0xb)
t/40listfields......dubious
	Test returned status 0 (wstat 11, 0xb)
t/40nulls...........dubious
	Test returned status 0 (wstat 11, 0xb)
t/40numrows.........dubious
	Test returned status 0 (wstat 11, 0xb)
t/50chopblanks......dubious
	Test returned status 0 (wstat 11, 0xb)
t/50commit..........dubious
	Test returned status 0 (wstat 11, 0xb)
t/60leaks...........skipped test on this platform
t/ak-dbd............dubious
	Test returned status 0 (wstat 11, 0xb)
DIED. FAILED tests 1-90
	Failed 90/90 tests, 0.00% okay
t/dbdadmin..........dubious
	Test returned status 0 (wstat 11, 0xb)
DIED. FAILED tests 1-20
	Failed 20/20 tests, 0.00% okay
Failed Test  Status Wstat Total Fail  Failed  List of failed
-------------------------------------------------------------------------------
t/10dsnlist.t     0    11    ??   ??       %  ??
t/20createdrop.   0    11    ??   ??       %  ??
t/30insertfetch   0    11    ??   ??       %  ??
t/40bindparam.t   0    11    ??   ??       %  ??
t/40blobs.t       0    11    ??   ??       %  ??
t/40listfields.   0    11    ??   ??       %  ??
t/40nulls.t       0    11    ??   ??       %  ??
t/40numrows.t     0    11    ??   ??       %  ??
t/50chopblanks.   0    11    ??   ??       %  ??
t/50commit.t      0    11    ??   ??       %  ??
t/ak-dbd.t        0    11    90   90 100.00%  1-90
t/dbdadmin.t      0    11    20   20 100.00%  1-20
1 test skipped.
Failed 12/14 test scripts, 14.29% okay. 110/115 subtests failed, 4.35%
okay.
make[1]: *** [test_dynamic] Error 255
make[1]: Leaving directory
`/zSRC/MYSQL/PERL/Msql-Mysql-modules-1.2215/mysql'
make: *** [test] Error 2

********************************************************************************
********************************************************************************

         Any help would be GREATLY appreciated............

                -----( Nick Pasich )-----


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

Date: Tue, 31 Oct 2000 18:15:54 GMT
From: northward@my-deja.com
Subject: Re: pseudo-parallel command execution
Message-Id: <8tn28g$48h$1@nnrp1.deja.com>

In article <8snrav$orh$1@nnrp1.deja.com>,
  inphektid@my-deja.com wrote:
 ...
> i'm wondering if there is anyway to start
> multiple commands without having to wait for
them
> to return before starting the next... right now
> i'm investigating some way to do this using FORK
> and EXEC rather than SYSTEM, but i'm quite
unsure
> as to if i'm headed down the right path.
>
> any sort of help would be GREATLY appreciated...
>
> thanks
----------------
Try something like this:

system( "<any cmd> &")

it's not really a good solution, but works...

enjoy,
tok


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


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

Date: Tue, 31 Oct 2000 11:03:51 +0100
From: Pavel Hlavnicka <pavel@gingerall.cz>
Subject: Re: Q on returning hashes from subroutines
Message-Id: <39FE9907.6010007@gingerall.cz>

Perl function never returns hash. Just array or scalar.

Parameter of 'keys' MUIST be a hash. So you need define aux. variable to =

convert array to hash.

You may avoid this step if you return HASHREF from the function and=20
'typecast' it in foreach:

sub mappings {
	return $self->{mappings};
}

foreach (keys %{mappings()}) { ...};

HTH

J=FCrgen Lind wrote:

> Hi,
>=20
> I have the following situation in my program:
>=20
> package A;
>=20
> use strict;
> use warnings;
>=20
> sub new{
> ...
>   my %mappings;
>   $self->{mappings} =3D \%mappings;
> ...
> }
>=20
> sub mappings{
> =20
>   my $self =3D shift;
>   return %{$self->{mappings}};
> }
>=20
> Now, when I try:
>=20
> ...
> my $shortcut;
>=20
> foreach $shortcut (sort keys $map->mappings()){
>    print "$shortcut =3D> $h{$shortcut}{description}\n";
>   }
>=20
> I get the following error message:
>=20
> Type of arg 1 to keys must be hash (not subroutine entry) at ...
>=20
> wheras
>=20
> my %h =3D $map->mappings();
> my $shortcut;
>=20
> foreach $shortcut  (sort keys %h){
>    print "$shortcut =3D> $h{$shortcut}{description}\n";
>   }
> =20
>=20
> works fine... I was trying to figure out how to reformulate the first=20
> solution in order
> to avoid the temporary variable but I couldn't find out how to do it...=

> Any help for me out there?
>=20
> regards
>=20
> J=FCrgen


--=20
Pavel Hlavnicka
Ginger Alliance Ltd.
Prague; Czech Republic



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

Date: 31 Oct 2000 07:19:04 -0700
From: tchrist@perl.com (Tom Christiansen)
Subject: Re: Query (Learning perl)
Message-Id: <39fed4d8@cs.colorado.edu>

In article <39ffcc8f.148378458@news.ispchannel.com>,
Al <apgraham@ispchannel.com---> wrote:
:>I have to delete a string from a file which appears at the end of that
:>file ..... can anyone help me out how to do it.
:>
:>for example :- In a file "abc.xyz" last line contains the string
:>"AAAAAA" .I have to delete that line, I am not able to do it in Perl.
:>Please help me out.

:Wouldn't "pop" work for this?
:
:open (OLDFILE, abc.xyz);
:@array = <OLDFILE>;
:close OLDFILE;
:
:pop @array;
:
:open (NEWFILE, ">abs.xyz");
:print NEWFILE @array;
:close NEWFILE;
:
:
:Gurus, please explain the problem with this. Or just say "shut up, Al,
:and learn to read." if I'm totally mistaken about pop.

Why ever would you read the whole file into memory?  That's exceedingly
wasteful.   Do it a line at a time.  

This is a trivial one-liner, guys.

    perl -i.orig -ne 'print unless eof' abc.xyz

or, with a consistency check

    perl -i.orig -ne 'print unless eof && /AAAAAA/' abc.xyz

--tom


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

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


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