[16156] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3568 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 10 16:48:03 2000

Date: Mon, 10 Jul 2000 13:47:51 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <963262071-v9-i3568@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 10 Jul 2000     Volume: 9 Number: 3568

Today's topics:
        help with MySQL connection... <raphaelp@nr1webresource.com>
    Re: help with MySQL connection... <care227@attglobal.net>
    Re: help with MySQL connection... <raphaelp@nr1webresource.com>
    Re: help with MySQL connection... <care227@attglobal.net>
    Re: help with MySQL connection... <raphaelp@nr1webresource.com>
    Re: help with MySQL connection... <care227@attglobal.net>
    Re: help with MySQL connection... <gellyfish@gellyfish.com>
    Re: help with MySQL connection... <care227@attglobal.net>
    Re: help with MySQL connection... <palincss@his.com>
    Re: help with MySQL connection... <raphaelp@nr1webresource.com>
    Re: help with MySQL connection... (Bart Lateur)
        Help with SMTP <senatorpalpatineNOseSPAM@dereth.net.invalid>
    Re: Help with SMTP <care227@attglobal.net>
    Re: Help with SMTP <senatorpalpatineNOseSPAM@dereth.net.invalid>
    Re: Help with SMTP (jason)
        HELP!  DB on the web <jheide@sprint.ca>
    Re: HELP!  DB on the web (Neil Kandalgaonkar)
    Re: HELP!  DB on the web <Jonathan.L.Ericson@jpl.nasa.gov>
        HELP! inserting a line into numerous files <davidgordon@mail.com>
    Re: HELP! inserting a line into numerous files (Malcolm Dew-Jones)
    Re: HELP! inserting a line into numerous files (Tad McClellan)
        HELP!!! BEGIN block is driving me nuts! <ed@nospam.com>
    Re: HELP!!! BEGIN block is driving me nuts! (Peter McMorran)
        HELP!!!!!!!!!! <nikitta@ica.net>
    Re: HELP!!!!!!!!!! <vioon@hotmil.com>
    Re: HELP!!!!!!!!!! (Mark Badolato)
        Hidden junk in my strings? srhadden@my-deja.com
    Re: Hidden junk in my strings? (Tad McClellan)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 7 Jul 2000 19:32:23 +0200
From: "Raphael Pirker" <raphaelp@nr1webresource.com>
Subject: help with MySQL connection...
Message-Id: <8k54m7$7ce$15$1@news.t-online.com>

Hi folks,

I have a trouble: My host will only install mysql.pm on their server. Can I
query a database with that module? I want to do the following:

I have the value $user_name. I want to do a search on a specific table:

   SELECT * FROM user WHERE user_name='$user_name'";

Then I want to fetch that row ("user_name" column has a unique value in each
row, so there are no duplicates!) and read it into a array so I can access
it somehow like that:

   $web_url        = $myrow["web_url"]

Could anyone please help me out with this? I do have the CPAN.ORG
instructions, but they are somehow undetailed and unclear and I don't
understand them... If possible, could anyone please provide a sample-code?

Thanks in advance,

Raphael




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

Date: Fri, 07 Jul 2000 14:32:13 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: help with MySQL connection...
Message-Id: <3966222D.DBBA33DC@attglobal.net>

Raphael Pirker wrote:
> 
> Could anyone please help me out with this? I do have the CPAN.ORG
> instructions, but they are somehow undetailed and unclear and I don't
> understand them... If possible, could anyone please provide a sample-code?
> 

I gave you sample code for your last request, and indicated that it is 
far better for you to post _your_ code and let folks help you with that.

(I just posted it, so you probably haven't read it yet, so I've spoiled
the surprise...)

Lets try it that way this time.  Try to come up with something.  It's
perfectly OK if it doesn't work, and you'll learn alot more just by
trying.


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

Date: Fri, 7 Jul 2000 21:47:31 +0200
From: "Raphael Pirker" <raphaelp@nr1webresource.com>
Subject: Re: help with MySQL connection...
Message-Id: <8k5ce6$uqu$17$1@news.t-online.com>

> Lets try it that way this time.  Try to come up with something.  It's
> perfectly OK if it doesn't work, and you'll learn alot more just by
> trying.

Ok, no problem. I just don't think that the code I have currently doesn't
really help (I suck at Perl! :-)

$host = "localhost";
$datbase = "db15389b";
$user = "us15389b";
$password = "HARRY1";

use Mysql;

$dbh = Mysql->connect($host, $database, $user, $password);

What I thought could work is something like that:

$sql_statement = "SELECT * FROM user WHERE user_name='$user_name'";
$sth = $dbh->query($sql_statement);

But now there would be the problem of reading the results into a hash...
(and I'm not even sure if the above code works!)




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

Date: Fri, 07 Jul 2000 16:25:46 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: help with MySQL connection...
Message-Id: <39663CCA.4636CC80@attglobal.net>

Raphael Pirker wrote:
> 
> Ok, no problem. I just don't think that the code I have currently doesn't
> really help (I suck at Perl! :-) 

Me too =)

> 
> use Mysql;

So they are really just using Mysql.pm, and not DBD::Mysql...
Yuck.  

> What I thought could work is something like that:

> $sql_statement = "SELECT * FROM user WHERE user_name='$user_name'";
> $sth = $dbh->query($sql_statement);

According to the documentation, you are right on.  The docs follow to 
say that:

	  @arr = $sth->fetchrow;        # Array context
	  $firstcol = $sth->fetchrow;   # Scalar context
	  @arr = $sth->fetchcol($col_number);
	  %hash = $sth->fetchhash;  <-- you need to try this one

will get you the desired data types.  Specifically:

: %hash = $sth->fetchhash;

: return a complete hash. The keys in this hash are the column names of 
: the table, the values are the table values. Be aware, that when you 
: have a table with two identical column names, you will not be able to 
: use this method without trashing one column. In such a case, you
should 
: use the fetchrow method. 

But it also has, in big, bold letters:

	OBSOLETE SOFTWARE 

so, you should probably get your sysadm to get the DBD::Mysql modules 
installed.


HTH


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

Date: Sat, 8 Jul 2000 06:35:16 +0200
From: "Raphael Pirker" <raphaelp@nr1webresource.com>
Subject: Re: help with MySQL connection...
Message-Id: <8k6bgq$ojk$18$2@news.t-online.com>

so I just put the fetchhash right beneath the code like this?

$host = "localhost";
$datbase = "db15389b";
$user = "us15389b";
$password = "HARRY1";

use Mysql;

$dbh = Mysql->connect($host, $database, $user, $password);
$sql_statement = "SELECT * FROM user WHERE user_name='$user_name'";
$sth = $dbh->query($sql_statement);
%hash = $sth->fetchhash;




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

Date: Sat, 08 Jul 2000 01:05:11 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: help with MySQL connection...
Message-Id: <3966B687.78AFBCB1@attglobal.net>

Raphael Pirker wrote:
> 
> so I just put the fetchhash right beneath the code like this?
> 
> $host = "localhost";
> $datbase = "db15389b";
> $user = "us15389b";
> $password = "HARRY1";
> 
> use Mysql;
> 
> $dbh = Mysql->connect($host, $database, $user, $password);
> $sql_statement = "SELECT * FROM user WHERE user_name='$user_name'";
> $sth = $dbh->query($sql_statement);
> %hash = $sth->fetchhash;


Try it out and see what happens.  I Haven't worked with that module,
so i can't say.  I've only used the DBI.


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

Date: 8 Jul 2000 13:43:14 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: help with MySQL connection...
Message-Id: <8k77l2$g03$1@orpheus.gellyfish.com>

On Fri, 07 Jul 2000 16:25:46 -0400 Drew Simonis wrote:
> Raphael Pirker wrote:
>> 
>> Ok, no problem. I just don't think that the code I have currently doesn't
>> really help (I suck at Perl! :-) 
> 
> Me too =)
> 
>> 
>> use Mysql;
> 
> So they are really just using Mysql.pm, and not DBD::Mysql...
> Yuck.  
> 
>> What I thought could work is something like that:
> 
>> $sql_statement = "SELECT * FROM user WHERE user_name='$user_name'";
>> $sth = $dbh->query($sql_statement);
> 
> According to the documentation, you are right on.  The docs follow to 
> say that:
> 
> 	  @arr = $sth->fetchrow;        # Array context
> 	  $firstcol = $sth->fetchrow;   # Scalar context
> 	  @arr = $sth->fetchcol($col_number);
> 	  %hash = $sth->fetchhash;  <-- you need to try this one
> 
> will get you the desired data types.  Specifically:
> 
> : %hash = $sth->fetchhash;
> 
> : return a complete hash. The keys in this hash are the column names of 
> : the table, the values are the table values. Be aware, that when you 
> : have a table with two identical column names, you will not be able to 
> : use this method without trashing one column. In such a case, you
> should 
> : use the fetchrow method. 
> 
> But it also has, in big, bold letters:
> 
> 	OBSOLETE SOFTWARE 
> 
> so, you should probably get your sysadm to get the DBD::Mysql modules 
> installed.
> 

Well yes but it says immediately under that :

       As of Msql-Mysql-modules 1.19_10 M(y)sqlPerl is no longer
       a separate module.  Instead it is emulated using the DBI
       drivers. You are strongly encouraged to implement new code
       with DBI directly. See the COMPATIBILITY NOTES entry else­
       where in this document below.

So they are going to be forced to install DBI and DBD::Mysql anyway.

/J\
-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


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

Date: Sat, 08 Jul 2000 13:45:28 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: help with MySQL connection...
Message-Id: <396768B8.8A35232E@attglobal.net>

Jonathan Stowe wrote:

> >       OBSOLETE SOFTWARE
> >
> > so, you should probably get your sysadm to get the DBD::Mysql modules
> > installed.
> >
> 
> Well yes but it says immediately under that :
> 
>        As of Msql-Mysql-modules 1.19_10 M(y)sqlPerl is no longer
>        a separate module.  Instead it is emulated using the DBI
>        drivers. You are strongly encouraged to implement new code
>        with DBI directly. See the COMPATIBILITY NOTES entry else­
>        where in this document below.
> 
> So they are going to be forced to install DBI and DBD::Mysql anyway.

What I understood from the OP's request was that his admin had a 
pre-DBI module to work with.  If this were the case, hw would still 
be stuck with the old syntax methods, right?


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

Date: Sun, 09 Jul 2000 21:53:51 GMT
From: Steve Palincsar <palincss@his.com>
Subject: Re: help with MySQL connection...
Message-Id: <3968F4B5.9B16AA9A@his.com>

Raphael Pirker wrote:
> 
> Hi folks,
> 
> I have a trouble: My host will only install mysql.pm on their server. Can I
> query a database with that module? I want to do the following:
> 

I wonder if you could install DBI and the mysql DBD in your space if the
sysadmin won't cooperate.


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

Date: Mon, 10 Jul 2000 15:58:21 +0200
From: "Raphael Pirker" <raphaelp@nr1webresource.com>
Subject: Re: help with MySQL connection...
Message-Id: <8kcl3c$b15$11$1@news.t-online.com>

it might be possible - but for how long you account will last is another
question... :-)

Steve Palincsar <palincss@his.com> wrote in message
news:3968F4B5.9B16AA9A@his.com...
> Raphael Pirker wrote:
> >
> > Hi folks,
> >
> > I have a trouble: My host will only install mysql.pm on their server.
Can I
> > query a database with that module? I want to do the following:
> >
>
> I wonder if you could install DBI and the mysql DBD in your space if the
> sysadmin won't cooperate.




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

Date: Mon, 10 Jul 2000 14:33:08 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: help with MySQL connection...
Message-Id: <3969de3d.207067@news.skynet.be>

Raphael Pirker wrote:

>Steve Palincsar wrote ...

>> I wonder if you could install DBI and the mysql DBD in your space if the
>> sysadmin won't cooperate.

>it might be possible - but for how long you account will last is another
>question... :-)

There's two sides to that coin... ISP's that offer too little, deserve
that customers run away.

-- 
	Bart.


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

Date: Thu, 06 Jul 2000 07:13:47 -0700
From: Synpax <senatorpalpatineNOseSPAM@dereth.net.invalid>
Subject: Help with SMTP
Message-Id: <07f4aacf.47c7b980@usw-ex0103-023.remarq.com>

I am grateful for any help I can get.

I am trying to send mail using smtp. I apparently need a
smtp.pm. It is not located in my perl directories and i am
trying to find it on the web now. It is hard to find, been
looking for ten minutes.

Let me know if i am on the right track. I have plenty of coding
examples to test the smtp. I am running on a development server.
This is the error:

Can't locate Net/SMTP.pm in @INC (@INC contains: d:/Perl/lib
d:/Perl/site/lib .) at d:\Inetpub\wwwroot\AIM\cgi-bin\test2.pl
line 2.
BEGIN failed--compilation aborted at d:\Inetpub\wwwroot\AIM\cgi-
bin\test2.pl line 2.

If you know where i can get the module, tell me. If i can get it
i will do a local 'use' statement or 'require'.


Thanks.


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

Got questions?  Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com



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

Date: Thu, 06 Jul 2000 10:29:16 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Help with SMTP
Message-Id: <396497BC.4CA682F2@attglobal.net>

Synpax wrote:
> 
> I am grateful for any help I can get.
> 
> I am trying to send mail using smtp. I apparently need a
> smtp.pm. It is not located in my perl directories and i am
> trying to find it on the web now. It is hard to find, been
> looking for ten minutes.

Holy cow!  Ten entire minutes!  Man, I feel for you.  I hate 
spending ten whole minutes looking for something.  I usually 
give up after 8, 9 at the most.  I'm pretty proud that you 
made it ten entire minutes.  WoW.



http://search.cpan.org  (and the module is Net::SMTP, part of Libnet)


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

Date: Thu, 06 Jul 2000 07:38:52 -0700
From: Synpax <senatorpalpatineNOseSPAM@dereth.net.invalid>
Subject: Re: Help with SMTP
Message-Id: <0c8fb9aa.96b2eb33@usw-ex0103-018.remarq.com>

Thanks for your help.

The problem is my knowledge of resources on the web is pretty
limited, so the list was exhausted in ten minutes.




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

Got questions?  Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com



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

Date: Thu, 06 Jul 2000 15:18:07 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: Help with SMTP
Message-Id: <MPG.13cf4073fc0aa350989772@news>

Synpax writes ..
>The problem is my knowledge of resources on the web is pretty
>limited, so the list was exhausted in ten minutes.

  www.cpan.org

-- 
 jason - elephant@squirrelgroup.com -


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

Date: Mon, 3 Jul 2000 23:38:43 -0700
From: "Glen Heide" <jheide@sprint.ca>
Subject: HELP!  DB on the web
Message-Id: <zEf85.46492$mP2.284900@newscontent-01.sprint.ca>

I'm a sorta-newbie at Perl and I got a question.  Last year, I had a group
of people help me make a Web/Database using Perl.  We used an Win32::ODBC
module.  My question is that is there another way to connect to a database
other then using an ODBC module?  I still want to use a Microsoft Access
Database though.  Got any Ideas?  Any suggestions would help too.   =)


--
    Yours Truly,
        Glen Heide




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

Date: Tue, 04 Jul 2000 08:03:05 GMT
From: neil@brevity.org (Neil Kandalgaonkar)
Subject: Re: HELP!  DB on the web
Message-Id: <8js5bg$4nk$1@localhost.localdomain>

In article <zEf85.46492$mP2.284900@newscontent-01.sprint.ca>,
Glen Heide <jheide@sprint.ca> wrote:

> My question is that is there another way to connect to a database
>other then using an ODBC module? 

What's wrong with ODBC?

>I still want to use a Microsoft Access
>Database though.  

This isn't really a perl question, it depends on what sort of connections
Access supports.

I am not familiar with MS stuff, but consider DBI and one of either 
DBD::ODBC, or maybe DBD::ADO. I think Win32::ODBC is not maintained any more,
DBI is perl's standard database module.


-- 
Neil Kandalgaonkar <neil@brevity.org>


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

Date: Tue, 04 Jul 2000 01:34:10 -0700
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: HELP!  DB on the web
Message-Id: <3961A182.5BFD722E@jpl.nasa.gov>

Glen Heide wrote:
> I'm a sorta-newbie at Perl and I got a question.  Last year, I had a group
> of people help me make a Web/Database using Perl.  We used an Win32::ODBC
> module.  My question is that is there another way to connect to a database
> other then using an ODBC module?  I still want to use a Microsoft Access
> Database though.  Got any Ideas?  Any suggestions would help too.   =)

The DBI and DBD::ODBC are on CPAN.  (Then when you need to switch
databases, you will need only minor changes the your scripts.)

Jon


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

Date: Tue, 4 Jul 2000 20:43:25 +0100
From: "David E. Gordon" <davidgordon@mail.com>
Subject: HELP! inserting a line into numerous files
Message-Id: <39623f8a@eeyore.callnetuk.com>

I have lots of html files that I want to add a single line of code to.
(after the <body> tag....i need to add a SSI virtual link).   It also would
be good if it would work recursively down directories.

From what I hear of Perl, I reckon Perl is the language to do it, but I'm
stuck!!  Can anyone help me out?!  Point me in the right direction.   Is it
possible?

Thanks,

David G.




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

Date: 4 Jul 2000 14:25:29 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: HELP! inserting a line into numerous files
Message-Id: <39625649@news.victoria.tc.ca>

David E. Gordon (davidgordon@mail.com) wrote:
: I have lots of html files that I want to add a single line of code to.
: (after the <body> tag....i need to add a SSI virtual link).   It also would
: be good if it would work recursively down directories.

: From what I hear of Perl, I reckon Perl is the language to do it, but I'm
: stuck!!  Can anyone help me out?!  Point me in the right direction.   Is it
: possible?

To edit a single file you could do something like the following from the
command line.  This assumes the <BODY> tag is unique and is completely on
a single line , but this sounds like a one-of so just monitor the results
by hand to be sure

  perl -i.BAK -pe "s/(<BODY.*?>)/${1}New_line_goes_here/" the_file.html

(tested on windows, on unix the quote chars probably need to be different)

For a bunch of files, on unix use find, and run the above on each file
that's found.

On windows you can build a list of commands to edit files something like
this

  dir/s/b  | perl -pe "s/^/Your_command_goes_here /" > do_all.bat

The command you want is the 'perl -i.BAK...etc...here/" ' from the first
example.




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

Date: Tue, 4 Jul 2000 18:08:35 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: HELP! inserting a line into numerous files
Message-Id: <slrn8m4o33.fim.tadmc@magna.metronet.com>

On Tue, 4 Jul 2000 20:43:25 +0100, David E. Gordon <davidgordon@mail.com> wrote:

> Subject: HELP! inserting a line into numerous files
                 ^^^^^^
>I have lots of html files that I want to add a single line of code to.


   perldoc -q insert


Perl FAQ, part 5:

   "How do I change one line in a file/
    delete a line in a file/
    insert a line in the middle of a file/
    append to the beginning of a file?"


> It also would
>be good if it would work recursively down directories.


use the File::Find module for, well, finding files  :-)

   perldoc File::Find


>Can anyone help me out?!  

Done.

>Point me in the right direction.   

Done.

>Is it
>possible?


Yes.


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Wed, 05 Jul 2000 23:27:20 GMT
From: "Ed Foy" <ed@nospam.com>
Subject: HELP!!! BEGIN block is driving me nuts!
Message-Id: <svP85.33178$NP5.996988@newsread2.prod.itd.earthlink.net>

Greetings,

I am having a problem with some code in a BEGIN block that is driving me
to distraction. There must be a simple answer but I have been unable to
find it.

First, my environment is Perl 5.004 under UNIX. I cannot compile my
scripts locally, but my ISP provides a remotely accessible compiler.
What I am trying to accomplish is to redirect STDERR to STDOUT (this
part works) so that I can see runtime errors via HTTP (this works). The
problem is that I am getting a compile error that I cannot resolve. I've
reduced the code to the following (verbatim) to demonstrate the problem:

#!/usr/local/bin/perl5

require 5.004;

BEGIN {
    print "Content-type: text/html\n\n";
    open (STDERR, ">&STDOUT") or die "Cannot Redirect STDERR: $!";
}

my $Dummy = "";
exit;

The above code results in the following error message on compilation:

TEST.PL contains syntax errors.
Content-type: text/html\n\n

For some reason the "Content-type: text/html\n\n" is a problem. If I
comment out the print statement or move the print statement outside the
BEGIN block then there is no error. If I assign the string to a variable
it still fails as in:

BEGIN {
    $foo = "Content-type: text/html\n\n";
    print $foo;
    open (STDERR, ">&STDOUT") or die "Cannot Redirect STDERR: $!";
}

If anyone can point to a solution to this problem it would very much be
appreciated. I have been unable to find anything in the Camel book or
perldocs to explain this error.

Ed




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

Date: Thu, 06 Jul 2000 00:30:27 GMT
From: mcmorran@visi.net (Peter McMorran)
Subject: Re: HELP!!! BEGIN block is driving me nuts!
Message-Id: <3963d31d$1$zpzbeena$mr2ice@news.visi.net>

Hi Ed,

In <svP85.33178$NP5.996988@newsread2.prod.itd.earthlink.net>, on
07/05/00 
   at 11:27 PM, "Ed Foy" <ed@nospam.com> said:

>Greetings,

>I am having a problem with some code in a BEGIN block that is
>driving me to distraction. There must be a simple answer but I
>have been unable to find it. 

>First, my environment is Perl 5.004 under UNIX. I cannot compile
>my scripts locally, but my ISP provides a remotely accessible
>compiler. What I am trying to accomplish is to redirect STDERR
>to STDOUT (this part works) so that I can see runtime errors via
>HTTP (this works). The problem is that I am getting a compile
>error that I cannot resolve. I've reduced the code to the
>following (verbatim) to demonstrate the problem:

>#!/usr/local/bin/perl5

>require 5.004;

>BEGIN {
>    print "Content-type: text/html\n\n";
>    open (STDERR, ">&STDOUT") or die "Cannot Redirect STDERR:
>$!"; }

>my $Dummy = "";
>exit;

>The above code results in the following error message on
>compilation:

>TEST.PL contains syntax errors.
>Content-type: text/html\n\n

You really should install your own copy of perl for debugging and
testing. It would certainly give a better message than "syntax
errors".

I ran this on my venerable perl 5.002 under OS/2 (disabling the
require 5.004) and it runs fine, including the redirect. However,
you may not be able to guarantee the ordering of the merged
streams -- when I send the output to a file, with a forced
runtime error, the error always appears before the content-type.
Obviously, this is platform-dependent.


>For some reason the "Content-type: text/html\n\n" is a problem.
>If I comment out the print statement or move the print statement
>outside the BEGIN block then there is no error. If I assign the
>string to a variable it still fails as in:

>BEGIN {
>    $foo = "Content-type: text/html\n\n";
>    print $foo;
>    open (STDERR, ">&STDOUT") or die "Cannot Redirect STDERR:
>$!"; }

>If anyone can point to a solution to this problem it would very
>much be appreciated. I have been unable to find anything in the
>Camel book or perldocs to explain this error.

>Ed



Cheers,
Peter

-- 
-----------------------------------------------------------
mcmorran@visi.net (Peter McMorran)
-----------------------------------------------------------



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

Date: Sun, 09 Jul 2000 18:03:57 -0700
From: nikita <nikitta@ica.net>
Subject: HELP!!!!!!!!!!
Message-Id: <396920FD.275E4FCC@ica.net>

#  Hy everybody,
#
#  How can I force the script discern odd numbers and  even numbers?
#  I would appreciate for any help
#  regarding the script.
#
#
#   Thanks in advance,
#
#    Serguei

##################################################################


#!/usr/bin/perl
   chomp($num = <STDIN>);
#divid a number by 2 to get the number with remainder.
   $num /=2;
#compare the number with remainder with a floating point number
   if ($num = "%.f"){
        print "You have an odd number\n";
}
   else{
        print "You have an even number\n";
}
exit;


#  the compare doesn't work





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

Date: Mon, 10 Jul 2000 00:20:35 +0200
From: "qwerty" <vioon@hotmil.com>
Subject: Re: HELP!!!!!!!!!!
Message-Id: <8katsp$fch$1@spectra.a2000.nl>


if (int($var/2) == ($var/2)){ number is even....}


nikita <nikitta@ica.net> wrote in message news:396920FD.275E4FCC@ica.net...
> #  Hy everybody,
> #
> #  How can I force the script discern odd numbers and  even numbers?
> #  I would appreciate for any help
> #  regarding the script.
> #
> #
> #   Thanks in advance,
> #
> #    Serguei
>
> ##################################################################
>
>
> #!/usr/bin/perl
>    chomp($num = <STDIN>);
> #divid a number by 2 to get the number with remainder.
>    $num /=2;
> #compare the number with remainder with a floating point number
>    if ($num = "%.f"){
>         print "You have an odd number\n";
> }
>    else{
>         print "You have an even number\n";
> }
> exit;
>
>
> #  the compare doesn't work
>
>
>




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

Date: 9 Jul 2000 23:31:06 GMT
From: mbadolato@cybernox.com (Mark Badolato)
Subject: Re: HELP!!!!!!!!!!
Message-Id: <8F6CA4A8Cmbadolatocybernoxcom@206.165.3.70>

[posted and mailed]

nikitta@ica.net (nikita) wrote in <396920FD.275E4FCC@ica.net>:

>#  How can I force the script discern odd numbers and  even numbers?
>#  I would appreciate for any help
>#  regarding the script.

print 'You have an ', ($num % 2) ? 'odd' : 'even', ' number.';

--Mark


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

Date: Wed, 05 Jul 2000 15:42:17 GMT
From: srhadden@my-deja.com
Subject: Hidden junk in my strings?
Message-Id: <8jvl0l$csg$1@nnrp1.deja.com>

I'm working in Solaris and I'm making system calls using this:

open(<PIPE>, "system command |")

while(<PIPE>)
{
	push(@array, $_);
}


The problem I'm having is that some people have shell environments that
print some garabage along with the system output.  For example, one
user's environment would always output a "\", which would ruin my first
entry in my array.

Then, I had this problem where there were escape characters or something
at the beginning of the first string.  Visually it appeared fine when I
printed the string out, but the SIZE was too long.  I then used a tool
to look at it more low level and I saw something like "ESC[12" or
something at the beginning.

Can someone point me to some info or suggest a way to make system calls
that does not use the environment of the user?

Thanks.


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


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

Date: Wed, 5 Jul 2000 12:41:37 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Hidden junk in my strings?
Message-Id: <slrn8m6pa1.hfr.tadmc@magna.metronet.com>

On Wed, 05 Jul 2000 15:42:17 GMT, srhadden@my-deja.com <srhadden@my-deja.com> wrote:

>I'm working in Solaris and I'm making system calls using this:
 ^^^                                                ^^^^^^^^^^


I doubt that you are being entirely accurate there...


>open(<PIPE>, "system command |")
      ^    ^                    ^^

Why are you doing _input_ there.

<angle brackets> mean "do some input here", but the "here" there
is an awfully strange place to be doing input.  :-)

You are missing either a semicolon or a test of the return value too.


>while(<PIPE>)
>{
>	push(@array, $_);
>}


You don't need that loop:

   @array = <PIPE>;   # input operator in list context


And if you are going to put the whole thing into memory anyway,
you don't even need a pipe open at all:

   @array = qx/system command/;    # backticks


>Can someone point me to some info or suggest a way to make system calls
>that does not use the environment of the user?


External programs inherit their environment from your Perl
program's environment.

You are free to mess with the environment before calling the
external program.

You change the environment of your Perl program by modifying
the %ENV hash.


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

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


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