[23972] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6173 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Feb 21 14:05:33 2004

Date: Sat, 21 Feb 2004 11: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           Sat, 21 Feb 2004     Volume: 10 Number: 6173

Today's topics:
        Can Perl do this task??? (at)FinancialDataCorp.com (Bob Mariotti)
    Re: Can Perl do this task??? <usenet@morrow.me.uk>
    Re: Can Perl do this task??? <toylet_at_mail.hongkong.com>
        Checking HTML, following links and such <spam@gurka.se>
    Re: Checking HTML, following links and such <usenet@morrow.me.uk>
    Re: Checking HTML, following links and such <spam@gurka.se>
        how add/update/delete data in MySQL database here? <gp@nospm.hr>
        How to let browsers be done when parent is done and not (Zhidian Du)
    Re: Let browser say "done" immediately after parent fin (David Efflandt)
        Looking for a way to increase CPU usage (A. Lewenberg)
    Re: Looking for a way to increase CPU usage <founder@pege.org>
    Re: Looking for a way to increase CPU usage <jwillmore@remove.adelphia.net>
    Re: Looking for a way to increase CPU usage (David Efflandt)
    Re: perl fileio <matthew.garrish@sympatico.ca>
    Re: perl fileio <toylet_at_mail.hongkong.com>
    Re: perl fileio <jwillmore@remove.adelphia.net>
    Re: perl fileio <toylet_at_mail.hongkong.com>
    Re: perl fileio <matthew.garrish@sympatico.ca>
    Re: PERL/MySQL tutorial <matthew.garrish@sympatico.ca>
    Re: PERL/MySQL tutorial <gp@nospm.hr>
    Re: PERL/MySQL tutorial <toylet_at_mail.hongkong.com>
    Re: PERL/MySQL tutorial <bobx@linuxmail.org>
    Re: PERL/MySQL tutorial <matthew.garrish@sympatico.ca>
    Re: PERL/MySQL tutorial <bobx@linuxmail.org>
    Re: PERL/MySQL tutorial <gp@nospm.hr>
    Re: very strange conditional problem (J. Romano)
    Re: very strange conditional problem (J. Romano)
    Re: very strange conditional problem (Chris Charley)
    Re: very strange conditional problem <newz@xoftware.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 21 Feb 2004 16:08:52 GMT
From: R.Mariotti(at)FinancialDataCorp.com (Bob Mariotti)
Subject: Can Perl do this task???
Message-Id: <40377ef4.78171306@news.cshore.com>

Unix system:  I have a compiled application that can only use STDIO
but I now need it to talk to a remote server using TCP on a particular
socket.

I've tried some hardware type interfaces in between but its difficult
if not impossible to control the port assignments.

I was thinking that I could create a perl program and via a pipe
connect it to my compiled application and the perl program could use a
module like Sockets::IO to connect to and pass the IO through both
ways.   Sometimes the traffic is incoming and sometimes its outgoing.

Am I crazy or would this be possible and viable?    Any other
suggestions also appreciated.

Thanks



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

Date: Sat, 21 Feb 2004 16:17:00 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Can Perl do this task???
Message-Id: <c1809s$qu0$3@wisteria.csv.warwick.ac.uk>


R.Mariotti(at)FinancialDataCorp.com (Bob Mariotti) wrote:
> Unix system:  I have a compiled application that can only use STDIO

ITYM stdin/stdout?

> but I now need it to talk to a remote server using TCP on a particular
> socket.
> 
> I was thinking that I could create a perl program and via a pipe
> connect it to my compiled application and the perl program could use a
> module like Sockets::IO to connect to and pass the IO through both
> ways.   Sometimes the traffic is incoming and sometimes its outgoing.
> 
> Am I crazy or would this be possible and viable?    Any other
> suggestions also appreciated.

This is perfectly possible, indeed relatively trivial... unless you want
to go for maximum performance.

A simpler way of doing it is with netcat or socat.

Ben

-- 
Musica Dei donum optimi, trahit homines, trahit deos.    |
Musica truces molit animos, tristesque mentes erigit.    |   ben@morrow.me.uk
Musica vel ipsas arbores et horridas movet feras.        |


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

Date: Sun, 22 Feb 2004 00:18:30 +0800
From: toylet <toylet_at_mail.hongkong.com>
Subject: Re: Can Perl do this task???
Message-Id: <403784cc$1_1@rain.i-cable.com>

> Unix system:  I have a compiled application that can only use STDIO
> I was thinking that I could create a perl program and via a pipe
> connect it to my compiled application and the perl program could use a
> module like Sockets::IO to connect to and pass the IO through both
> ways.   Sometimes the traffic is incoming and sometimes its outgoing.

I think it's doable. What's really holding you from doing a test?

-- 
   .~.    Might, Courage, Vision. In Linux We Trust.
  / v \   http://www.linux-sxs.org
/( _ )\  Linux 2.4.22-xfs
   ^ ^    12:16am up 1 day 36 min load average: 1.00 1.00 1.00


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

Date: Sat, 21 Feb 2004 19:40:14 +0100
From: "Joti" <spam@gurka.se>
Subject: Checking HTML, following links and such
Message-Id: <c188nk$1ffdf5$1@ID-224346.news.uni-berlin.de>

For a rather long time, I've tried to find something for viewing the HTML of
a page, and then go to different pages or follow different links depending
on the HTML.

Is Perl the right language for doing his, and how do I do it?




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

Date: Sat, 21 Feb 2004 18:47:16 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Checking HTML, following links and such
Message-Id: <c1893k$mb$1@wisteria.csv.warwick.ac.uk>


"Joti" <spam@gurka.se> wrote:
> For a rather long time, I've tried to find something for viewing the HTML of
> a page, and then go to different pages or follow different links depending
> on the HTML.
> 
> Is Perl the right language for doing his, and how do I do it?

Try WWW::Mechanize.

Ben

-- 
"The Earth is degenerating these days. Bribery and corruption abound.
Children no longer mind their parents, every man wants to write a book,
and it is evident that the end of the world is fast approaching."
     -Assyrian stone tablet, c.2800 BC                         ben@morrow.me.uk


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

Date: Sat, 21 Feb 2004 19:52:13 +0100
From: "Joti" <spam@gurka.se>
Subject: Re: Checking HTML, following links and such
Message-Id: <c189eu$1fiqsi$1@ID-224346.news.uni-berlin.de>


"Ben Morrow" <usenet@morrow.me.uk> skrev i meddelandet
news:c1893k$mb$1@wisteria.csv.warwick.ac.uk...
>
> "Joti" <spam@gurka.se> wrote:
> > For a rather long time, I've tried to find something for viewing the
HTML of
> > a page, and then go to different pages or follow different links
depending
> > on the HTML.
> >
> > Is Perl the right language for doing his, and how do I do it?
>
> Try WWW::Mechanize.
>
> Ben
>
> --
> "The Earth is degenerating these days. Bribery and corruption abound.
> Children no longer mind their parents, every man wants to write a book,
> and it is evident that the end of the world is fast approaching."
>      -Assyrian stone tablet, c.2800 BC
ben@morrow.me.uk

I'm sorry, but i don't really know that much about perl, only the basic
stuff. Not about what ever WWW::Mechanize is. I've made a google search but
I still don't seem to understand. Could someone explain?




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

Date: Sat, 21 Feb 2004 18:48:46 +0100
From: "PHP2" <gp@nospm.hr>
Subject: how add/update/delete data in MySQL database here?
Message-Id: <c185kj$m85$1@ls219.htnet.hr>

how add/update/delete data in MySQL database here?



CREATE TABLE IF NOT EXISTS example
(
item VARCHAR(255) NULL,
category VARCHAR(255) NULL,
picture LONGBLOB NULL,
model VARCHAR(255) NULL,
serial_number VARCHAR(255) NULL,
information TEXT NULL,
date_purchased DATE NULL,
depreciation DOUBLE NULL,
assigned_display DOUBLE NULL,
depreciation_life DOUBLE NULL,
remaining_life DOUBLE NULL,
cost DOUBLE NULL,
book_value DOUBLE NULL

) TYPE=MyISAM;



any help?






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

Date: 21 Feb 2004 11:01:17 -0800
From: zdu@cs.nmsu.edu (Zhidian Du)
Subject: How to let browsers be done when parent is done and not wait for childrn's finishing in CGI
Message-Id: <e4c69a32.0402211101.1dbae435@posting.google.com>

I am writing a CGI program and find that the browsers always wait for
all the processes to be done, it will be done.
 
What I want to do is to let browsers say "done" on its status bar when
parent is done, which is very short and do not let it say
"transferring data...." since childrn take very long time.

How to do it.

Thanks.

Z. Du


FORK: {  
  
  if ( $pid = fork ) {
    print "You will receive email shortly.\n";
    print $query->end_html();
    exit 0;
  }
  elsif ( defined $pid ) {	#main part
    
     #time in child taken is very long
     # and send email to clients
  }    
    
}


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

Date: Sat, 21 Feb 2004 17:41:17 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Let browser say "done" immediately after parent finish and do not wait child.
Message-Id: <slrnc3f61t.936.efflandt@typhoon.xnet.com>

On 20 Feb 2004 20:58:29 -0800, Zhidian Du <zdu@cs.nmsu.edu> wrote:
> I am writing a CGI program.  
> 
> Why browsers always wait (saying "transferring data from..." from the
> status bar) until both parent and chilld finish and say "done".
> 
> How can I let browser say "done" immediately after parent finish.
> 
> 
> I use a query->end_html() in there and it doesn't work.

Look for 'daemonize' in 'perldoc perlipc'.  You have to fork and 
disassociate the child from the parent to not hold up the parent.

-- 
David Efflandt - All spam ignored  http://www.de-srv.com/


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

Date: 21 Feb 2004 09:28:51 -0800
From: adam@macrotex.net (A. Lewenberg)
Subject: Looking for a way to increase CPU usage
Message-Id: <6bd7331b.0402210928.18f37ac1@posting.google.com>

I am looking for a perl code fragment that, given a number n will take
roughly n seconds of CPU time to complete. Note well that I do not
care how much _real_ time it takes: I want it to take n seconds of CPU
time to finish. Even if the CPU time it takes is within 50% of n that
would be OK.

I realize I could just do some experiments with tight loops to find
some code that would do what I want, but that would probably only work
on my current machine. I would like the code to work on different
platforms and hardware configurations.

Has anyone done this sort of thing before? 

Thanks.


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

Date: Sat, 21 Feb 2004 18:37:53 +0100
From: =?iso-8859-1?Q?Roland_M=F6sl?= <founder@pege.org>
Subject: Re: Looking for a way to increase CPU usage
Message-Id: <4037977e$0$13188$91cee783@newsreader02.highway.telekom.at>

> I am looking for a perl code fragment that, given a number n will take
> roughly n seconds of CPU time to complete. Note well that I do not
> care how much _real_ time it takes: I want it to take n seconds of CPU
> time to finish. Even if the CPU time it takes is within 50% of n that
> would be OK.

This is a sensless waste of energy.

The CPU uses more power than for a simple wait statement.

Also it's noise terror for the user.

The fan of my notebook usual does not work.
A complete silent notebook.

Only after maybe half miunte of full CPU usage,
the fan starts to cool.

So is, what You want a very bad energy wasting
and noise creating programming style


-- 
Roland Mösl
http://www.pege.org Clear targets for a confused civilization
http://web-design-suite.com Web Design starts at the search engine



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

Date: Sat, 21 Feb 2004 12:51:15 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Looking for a way to increase CPU usage
Message-Id: <pan.2004.02.21.17.51.12.443648@remove.adelphia.net>

On Sat, 21 Feb 2004 09:28:51 -0800, A. Lewenberg wrote:

> I am looking for a perl code fragment that, given a number n will take
> roughly n seconds of CPU time to complete. Note well that I do not
> care how much _real_ time it takes: I want it to take n seconds of CPU
> time to finish. Even if the CPU time it takes is within 50% of n that
> would be OK.

Are you looking to limit the time the script runs total, or actual
processing time?

If the former, you could use 'alarm'.  The alarm function will allow you
to limit the amount of time the script runs.

perldoc -f alarm for more info, plus perldoc perlipc

I, personally, am not sure if you can limit the amount of processor the
script can "chew" on through Perl.  You can, with some shells, set limits
on what a user can (not) do (ulimit and limit come to mind).  However,
it's not a 100% solution (because the user can alter the soft limits in
some cases).

HTH

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
Fortune's Real-Life Courtroom Quote #52:  Q:  What is your name? 
A:  Ernestine McDowell. Q:  And what is your marital status? A:  
Fair. 


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

Date: Sat, 21 Feb 2004 18:17:02 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Looking for a way to increase CPU usage
Message-Id: <slrnc3f84u.936.efflandt@typhoon.xnet.com>

On 21 Feb 2004 09:28:51 -0800, A. Lewenberg <adam@macrotex.net> wrote:
> I am looking for a perl code fragment that, given a number n will take
> roughly n seconds of CPU time to complete. Note well that I do not
> care how much _real_ time it takes: I want it to take n seconds of CPU
> time to finish. Even if the CPU time it takes is within 50% of n that
> would be OK.

If all you want to do is pause, you would use:  sleep $n;

Example if you want to do something during that time:

#!/usr/bin/perl -w
my $n = 3;
my $end = time -1 + $n;
$| = 1; # unbuffered output for test dots
print "start " . localtime();
while (1) {
    last if (time > $end);
    print ".";  # or do something useful
}
print scalar localtime() . " done\n";

-- 
David Efflandt - All spam ignored  http://www.de-srv.com/


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

Date: Sat, 21 Feb 2004 11:46:12 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: perl fileio
Message-Id: <kXLZb.11580$w65.884942@news20.bellglobal.com>


"toylet" <toylet_at_mail.hongkong.com> wrote in message
news:40377fe5_2@rain.i-cable.com...
> >> In many examples I found from the web, they just $buffer=<INFILE>. What
> >> would happen if INFILE is a big one? Would it hang the server?
> > What server?
> > You don't need a server to run Perl programs.
>
> you do. The server could be a localhost, which could be Windows, Linux.
> I should have used the word "machine" or "operating system".
>

You don't (even cgi apps in Perl don't require a server for testing,
although it can make life simpler). It's a polite way of telling you you're
getting off-topic. One you never said what server you're using, and two
there's little point in asking in a Perl newsgroup what the limitations of
your server/OS are.

Matt




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

Date: Sun, 22 Feb 2004 01:21:17 +0800
From: toylet <toylet_at_mail.hongkong.com>
Subject: Re: perl fileio
Message-Id: <40379383$1_1@rain.i-cable.com>

> You don't (even cgi apps in Perl don't require a server for testing,
> although it can make life simpler). It's a polite way of telling you you're
> getting off-topic. One you never said what server you're using, and two
> there's little point in asking in a Perl newsgroup what the limitations of
> your server/OS are.

That depends on how you use the word server. Anyway, I don't want to 
expand thhis sub-thread, pls.

I was worrying about perl's memory management related to 
$buffer=<INFILE>, which quite on-topic I beleive.


-- 
   .~.    Might, Courage, Vision. In Linux We Trust.
  / v \   http://www.linux-sxs.org
/( _ )\  Linux 2.4.22-xfs
   ^ ^    1:18am up 1 day 1:38 load average: 1.00 1.01 1.03


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

Date: Sat, 21 Feb 2004 12:28:02 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: perl fileio
Message-Id: <pan.2004.02.21.17.27.59.417753@remove.adelphia.net>

On Sat, 21 Feb 2004 23:57:34 +0800, toylet wrote:

>>> In many examples I found from the web, they just $buffer=<INFILE>. What 
>>> would happen if INFILE is a big one? Would it hang the server? 
>> What server?
>> You don't need a server to run Perl programs.
> 
> you do. The server could be a localhost, which could be Windows, Linux. 
> I should have used the word "machine" or "operating system".

You're right, you need to use another term :-)

Linux != server && Windows != server

Linux == OS && Windows == OS

Think about it :-)

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
For some reason, this fortune reminds everyone of Marvin
Zelkowitz. 



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

Date: Sun, 22 Feb 2004 01:35:51 +0800
From: toylet <toylet_at_mail.hongkong.com>
Subject: Re: perl fileio
Message-Id: <403796ed$1_1@rain.i-cable.com>

> Linux != server && Windows != server

I rather make it:

Linux = (server|client)
Windows = (server|client)

> Linux == OS && Windows == OS
> 
> Think about it :-)

I agree.

-- 
   .~.    Might, Courage, Vision. In Linux We Trust.
  / v \   http://www.linux-sxs.org
/( _ )\  Linux 2.4.22-xfs
   ^ ^    1:34am up 1 day 1:54 load average: 0.97 0.92 0.95


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

Date: Sat, 21 Feb 2004 12:59:23 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: perl fileio
Message-Id: <W%MZb.11610$w65.894255@news20.bellglobal.com>


"toylet" <toylet_at_mail.hongkong.com> wrote in message
news:403796ed$1_1@rain.i-cable.com...
> > Linux != server && Windows != server
>
> I rather make it:
>
> Linux = (server|client)
> Windows = (server|client)
>

And that's where you're confusing people. You just threw out the word server
without explaining what you meant. My impression was that you were talking
about IIS or Apache. For future reference, use statements like "my Linux
box, which is running as a file server..." then no one needs to guess what
you're talking about.

Matt




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

Date: Sat, 21 Feb 2004 11:39:38 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: PERL/MySQL tutorial
Message-Id: <bRLZb.11578$w65.884362@news20.bellglobal.com>


"toylet" <toylet_at_mail.hongkong.com> wrote in message
news:40377883$1_1@rain.i-cable.com...
> >> See http://dbi.perl.org/
> > http://www.mysql.com/doc/en/
> > http://www.perldoc.com/
>
> Is there a good search string that could help one to find more live
> examples of using the DBI::Mysql interface? Most examples I found are
> merely scratching the surface.
>

There are a several excellent books by Paul Dubois on the subject:

http://www.mysql.com/portal/books/mysql/index.html

Matt




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

Date: Sat, 21 Feb 2004 18:26:47 +0100
From: "PHP2" <gp@nospm.hr>
Subject: Re: PERL/MySQL tutorial
Message-Id: <c184bb$l42$1@ls219.htnet.hr>

all URLs are standard Help pages.. but facts that on market realy have not
examples of some private person.. other programming languages have simialr
tutorials from private persons..


"PHP2" <gp@nospm.hr> wrote in message news:c17en7$lqc$1@ls219.htnet.hr...
> I can not find too much good PERL/MySQL tutorials... Do you know someone
> about good PERL/MySQL tutorials on the web..?
>
>




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

Date: Sun, 22 Feb 2004 01:46:28 +0800
From: toylet <toylet_at_mail.hongkong.com>
Subject: Re: PERL/MySQL tutorial
Message-Id: <4037996a$1_1@rain.i-cable.com>

>> Is there a good search string that could help one to find more live
>> examples of using the DBI::Mysql interface? Most examples I found are
>> merely scratching the surface.
> There are a several excellent books by Paul Dubois on the subject:
> 
> http://www.mysql.com/portal/books/mysql/index.html
> 
> Matt
> 
> 
Note that he wants perl+mysql, not php+mysql :)

Btw, i was talking about the scarcity of examples in the web searcheable 
by google.com. Is perl+mysql not a hot topic after all?

-- 
   .~.    Might, Courage, Vision. In Linux We Trust.
  / v \   http://www.linux-sxs.org
/( _ )\  Linux 2.4.22-xfs
   ^ ^    1:44am up 1 day 2:04 load average: 1.00 0.99 0.96


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

Date: Sat, 21 Feb 2004 13:25:57 -0500
From: Robert <bobx@linuxmail.org>
Subject: Re: PERL/MySQL tutorial
Message-Id: <pumdnYl3RsQpP6rdRVn-hw@adelphia.com>

PHP2 wrote:

> I can not find too much good PERL/MySQL tutorials... Do you know someone
> about good PERL/MySQL tutorials on the web..?
> 
> 
http://www.linuxplanet.com/linuxplanet/tutorials/1046/1/

http://www.perlscriptsjavascripts.com/tutorials/mysql/

http://www.devshed.com/c/b/MySQL/

http://www.perl.com/pub/a/2003/10/23/databases.html

http://www.perl.com/pub/a/1999/10/DBI.html

The great thing about Perl is the DBI. You can actually look at articles 
that explain how Perl connects and uses pretty much ANY database and it 
should be trivial to tweak that knowledge for MySQL.

Book:  Programming the Perl DBI by Descartes & Bunce


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

Date: Sat, 21 Feb 2004 13:15:18 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: PERL/MySQL tutorial
Message-Id: <SeNZb.11620$w65.896394@news20.bellglobal.com>


"toylet" <toylet_at_mail.hongkong.com> wrote in message
news:4037996a$1_1@rain.i-cable.com...
> >> Is there a good search string that could help one to find more live
> >> examples of using the DBI::Mysql interface? Most examples I found are
> >> merely scratching the surface.
> > There are a several excellent books by Paul Dubois on the subject:
> >
> > http://www.mysql.com/portal/books/mysql/index.html
> >
> > Matt
> >
> >
> Note that he wants perl+mysql, not php+mysql :)
>
> Btw, i was talking about the scarcity of examples in the web searcheable
> by google.com. Is perl+mysql not a hot topic after all?
>

That was just a starting point. You can look up his other books for
yourself:

http://www.kitebird.com/mysql-perl/

There's also not a whole lot to say about Perl and MySQL. His books are a
good starting point if you have limited exposure to Perl and/or MySQL, but
the technologies are distinct of each other. If you know SQL, you should be
able to use the Perl DBI and drivers to query your databases. If you know
MySQL, you should have an idea of what tasks you could automate with a
scripting language like Perl. The advantage of the Perl DBI is that it hides
the complexity of connecting to different databases in the drivers, so all
you really need to know is some SQL. So whether it's Perl and
(MySQL|Oracle|MSSQL|Postgresql) it doesn't make a huge difference to your
programs.

If you're just interested in how to use Perl to interact with a database,
drop the idea that you need to find information on MySQL for now and go
straight to "Programming the Perl DBI". Once you've mastered that part of
the equation you can read the MySQL documentation to find out what the
pecularities of that database system are.

Matt




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

Date: Sat, 21 Feb 2004 13:32:32 -0500
From: Robert <bobx@linuxmail.org>
Subject: Re: PERL/MySQL tutorial
Message-Id: <pumdnYt3RsSjOardRVn-hw@adelphia.com>

*ONE* of the great things. ;-)


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

Date: Sat, 21 Feb 2004 20:05:18 +0100
From: "PHP2" <gp@nospm.hr>
Subject: Re: PERL/MySQL tutorial
Message-Id: <c18a42$rm5$1@ls219.htnet.hr>

yes! this realy be helpfull!

"Robert" <bobx@linuxmail.org> wrote in message
news:pumdnYt3RsSjOardRVn-hw@adelphia.com...
> *ONE* of the great things. ;-)




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

Date: 21 Feb 2004 08:14:52 -0800
From: jl_post@hotmail.com (J. Romano)
Subject: Re: very strange conditional problem
Message-Id: <b893f5d4.0402210814.67656506@posting.google.com>

Kodeguru <newz@xoftware.org> wrote in message news:<2SGZb.27067$ac.4342902@news4.srv.hcvlny.cv.net>...
>
>        # this line prints $equip_row->[16] is (some@email.address)\n
>        # which is right
>        print "\$equip_row->[16] is ($equip_row->[16])\n";
> 
>        if ($equip_row->[16] != undef){ # But then this test fails
> 
>          # and this line doesn't print at all
>          print "$equip_row->[16] is not undef, so...\n";
>
> #####------######
> 
> Now if I change the line where the conditional is to
> 
>      if ($equip_row->[16] =~ /\S+/) {
> 
> It works. Both debug lines print like they should and the emails get sent.
> 
> Anyone else have any ideas ?

   I have an idea, even though I do not know the exact reason why your
code is not working as you'd expect.

   My thought is that your Perl interpreter doesn't like comparing a
scalar to undef.  Therefore, I suggest that, instead of comparing a
scalar to see if it doesn't equal undef, try seeing if it is defined
by using the "defined" keyword.  Try changing the condition:

   if ($equip_row->[16] != undef)

to this one:

   if (defined($equip_row->[16]))

   See if that works.

   Happy Perling!

   -- Jean-Luc


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

Date: 21 Feb 2004 08:55:00 -0800
From: jl_post@hotmail.com (J. Romano)
Subject: Re: very strange conditional problem
Message-Id: <b893f5d4.0402210855.54a285f5@posting.google.com>

Kodeguru <newz@xoftware.org> wrote in message news:<2SGZb.27067$ac.4342902@news4.srv.hcvlny.cv.net>...
> ** I also posted this in comp.lang.perl **
> 
>        # this line prints $equip_row->[16] is (some@email.address)\n
>        # which is right
>        print "\$equip_row->[16] is ($equip_row->[16])\n";
> 
>        if ($equip_row->[16] != undef){ # But then this test fails
> 
> #####------######
> 
> Now if I change the line where the conditional is to
> 
>      if ($equip_row->[16] =~ /\S+/) {
> 
> It works. Both debug lines print like they should and the emails get sent.
> 
> The code is working now, because I left it as a regex test, but this is 
> the craziest thing I've ever seen. I looked at it for hours, and I don't 
> think I'm missing anything stupid.
> 
> Anyone else have any ideas ?

   Okay, I think the answer just came to me.  The reason the condition

      if ($equip_row->[16] != undef)

always fails is because you are using the != operator (instead of
"ne") to make a comparison, which will always compare numerical
values.  As a result, $equip_row->[16] evaluates to zero (since it is
just text with no digits), and so does undef.  Then the condition is
basically equivalent to:

      if (0 != 0)

which, of course, will always fail.  You should change that condition
to be:

      if (defined($equip_row->[16]))

or just:

      if ($equip_row->[16])

since an undefined value will always evaluate to false.

   Hope this helps!

   -- Jean-Luc Romano


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

Date: 21 Feb 2004 09:09:05 -0800
From: charley@pulsenet.com (Chris Charley)
Subject: Re: very strange conditional problem
Message-Id: <4f7ed6d.0402210909.c254f5d@posting.google.com>

Kodeguru <newz@xoftware.org> wrote in message news:<2SGZb.27067$ac.4342902@news4.srv.hcvlny.cv.net>...
> ** I also posted this in comp.lang.perl **


>        if ($equip_row->[16] != undef){ # But then this test fails

Should be: if (defined $equip_row->[16])

HTH,
Chris


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

Date: Sat, 21 Feb 2004 18:38:23 GMT
From: Kodeguru <newz@xoftware.org>
Subject: Re: very strange conditional problem
Message-Id: <zANZb.29928$ac.5725555@news4.srv.hcvlny.cv.net>


Thank you all,


	I did have warnings turned on, but it just didn't seem to help. The 
warning I got didn't seem to explain the problem, and it is just a 
"warning". I'm sorry to have wasted all of your man minutes.


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

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


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