[16258] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3670 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 14 14:15:54 2000

Date: Fri, 14 Jul 2000 11:15:42 -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: <963598541-v9-i3670@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 14 Jul 2000     Volume: 9 Number: 3670

Today's topics:
    Re: PRINTing " "" " <juex@deja.com>
        printing out list of checkboxes to a file. <none@init.com>
        Problems with Perl Proxyserver tallisyn@my-deja.com
    Re: Pushing referenced objects on an array nobull@mail.com
    Re: Redirect External Program's output on Windows ? joerg@sql.de
    Re: Redirect External Program's output on Windows ? <rhomberg@ife.ee.ethz.ch>
        Running Programs Within Perl spock0000@my-deja.com
    Re: Running Programs Within Perl <sariq@texas.net>
    Re: Running Programs Within Perl spock0000@my-deja.com
    Re: Running Programs Within Perl <sariq@texas.net>
    Re: Shortcut for non-defined variables (James Weisberg)
    Re: String length? (Tad McClellan)
    Re: String length? (Tad McClellan)
        system question spock0000@my-deja.com
    Re: The newbie question <bart.lateur@skynet.be>
    Re: The newbie question <mhofer@jpmorgan.com>
    Re: Upper-to-lower case problem <bart.lateur@skynet.be>
    Re: Use strict & subroutines nobull@mail.com
    Re: Use strict & subroutines (Tad McClellan)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 14 Jul 2000 10:46:36 -0700
From: "Jürgen Exner" <juex@deja.com>
Subject: Re: PRINTing " "" "
Message-Id: <396f5258@news.microsoft.com>

"Uri Guttman" <uri@sysarch.com> wrote in message
news:x78zv5kckh.fsf@home.sysarch.com...
[...]
> then use qq or here docs. there is still no need for escaped quote
> chars. there is never a need for them and it is ugly to see.

I honestly do not understand why you object so strongly against using
escaped quotes.
Granted, it may look ugly and there are other ways to do it.
But:
- One of the strengths of Perl is that there is more than one way to do
things
- Escaped quotes are _the_ standard way in any script or programming
language I know of (ranging from sh and VBS to Lips, Haskell, and C++).
Therefore anyone who knows at least a little bit about programming is
familiar with them already. On the other hand how many programming languages
offer "qq" or here documents?
- Do you also object to \n, \t, and their cousins? They are exactly the
same. Explicit newlines are not allowed in strings. Therefore you need a
different way to denote them. Explicit double quotes are not allowed in
strings. Therefore you need a different way to denote them. Why would you
want to tread a double quote differently then a newline?

jue




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

Date: Fri, 14 Jul 2000 18:42:20 +0100
From: "Paul [[AGGTA] Total Fuckup]" <none@init.com>
Subject: printing out list of checkboxes to a file.
Message-Id: <wjIb5.807$Z_6.4047@news11-gui.server.ntli.net>

Hello,

        Im having some big problems trying to get my CGI script to print a
list of selected checkboxes to a file.

What i have is a list of checkboxes called  game and what i want my script
to do is print out the check boxes that was selected to a file.

Ive tried this:

#!/usr/local/bin/perl
use CGI 'param';
print "Content-type: text/html\n\n";
print join "," , param ( 'game' );

and it works but i dont  want it displayed on the screen i want it in a file
(like a guestbook file). Ive also tried putting that into my actual script
but all i get is either nothing in the place where it should be or just a 0.
My other fields in the form work properly and they add themself to the file.
Its just the checkboxes that dont work.

Any ideas?

Thanks,

            Paul




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

Date: Fri, 14 Jul 2000 15:13:58 GMT
From: tallisyn@my-deja.com
Subject: Problems with Perl Proxyserver
Message-Id: <8knan4$g15$1@nnrp1.deja.com>

I'm trying to get a database connection to a MS SQL server running over
a Perl DBI proxyserver. I've got the DBI and DBD::ODBC working from an
NT machine. But now I want to use DBD::Proxy to get the same access
from a linux machine. I think I've got all the modules installed, but I
can't get the NT machine to run "dbiproxy". The error message it
returns:

Can't call method "tid" on an undefined value at
E:/Perl/site/lib/Net/Daemon/Log.pm line 75.

Questions:
1) Anyone know why this is happening?
2) Where can I find good documentation for setting up and using the
proxyserver.


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


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

Date: 14 Jul 2000 17:12:15 +0100
From: nobull@mail.com
Subject: Re: Pushing referenced objects on an array
Message-Id: <u9n1jku1wg.fsf@wcl-l.bham.ac.uk>

Antony <mcnultya@nortelnetworks.com> writes:

> I'm terrible at explaining this stuff,

In that case do what we always tell people to do.  Reduce your problem
to a small (a dozen lines or so) stand-alone script that (appart from
the problem you are trying to isolate) will compile and run user "-w"
and "use strict".

If that doesn't allow you to solve the problem for yourself then post
that script IN ITS ENTIRITY so that people can attempt to reproduce
the error.

If you do all that you probably won't need to explain anything.

> It returns an error of "Not a SCALAR reference at ..."
> 
> Can anyone explain why it is like this please ?

No, you don't tell us at which line of your script it is reporting the
error and having looked at the script you posted I'd guess you have
chosen to omit the line where the error is occuring.

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


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

Date: Fri, 14 Jul 2000 15:31:24 GMT
From: joerg@sql.de
Subject: Re: Redirect External Program's output on Windows ?
Message-Id: <8knboc$guc$1@nnrp1.deja.com>

Greetings !

In article <8kfdsv$mqb$1@nnrp1.deja.com>,
  undergronk@yahoo.com wrote:
> In article <8kf6j5$gmr$1@nnrp1.deja.com>,
>   joerg@sql.de wrote:
[ = I myself, J.B.]
> > [...]
> >
> > I need to call external programs that write to their "standard
> > output", but I need to keep that text in files.
> > I would prefer to include "standard error" with the output.

I just found out this is a "must", not just a "like to" ;-)

> >
> > On Unix, I call "system" with a string parameter that contains
> > redirection characters:
> > [...]
> >    system "program arg1 arg2 > result 2>&1"
> > which does exactly what I want.
> <snip.
> > What is the best way to achieve the desired effect ?
>
> You could use backticks to capture all the output of the program and
> then print that, if you don't mind STDOUT and STDERR mixed together
>
> $output = `someprogram.exe`;
> print $output;

I tried that - it collects STDOUT fine, but STDERR still goes
to the console and so is lost.

My environment is this:

I have a set of test program sources. The Perl script is to
compile, link, and then run each of these programs.
I need to store the STDOUT and STDERR (several of these tests
intentionally  produce run time error messages) into a protocol file
specific for the test case.
Later, I will collect these files from several machines (various
Unixes and one Win-NT) and compare them.

If there is no way to specifically collect STDERR of an external
program on WinNT (it seems like - neither backticks nor
   open ( FILE, "program |" )
got STDERR in my tests),
can I dynamically change the STDERR destination of the running Perl
program for each test case and then let the test object inherit this
setting ?

Thanks for all hints,
Joerg Bruehe

--
Joerg Bruehe, SQL Datenbanksysteme GmbH, Berlin, Germany
     (speaking only for himself)
mailto: joerg@sql.de


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


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

Date: Fri, 14 Jul 2000 18:00:04 +0200
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: Redirect External Program's output on Windows ?
Message-Id: <396F3904.BBEAAE37@ife.ee.ethz.ch>

joerg@sql.de wrote:
> 
> Dear Perl users,
> 
> I ask for hints when porting a Perl program from Unix to Win32:
> 
> I need to call external programs that write to their "standard
> output", but I need to keep that text in files.
> I would prefer to include "standard error" with the output.

open3() should help
see perlipc and IPC::Open3

- Alex


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

Date: Fri, 14 Jul 2000 15:55:43 GMT
From: spock0000@my-deja.com
Subject: Running Programs Within Perl
Message-Id: <8knd60$m8k$1@nnrp2.deja.com>

Hello, I am trying to write a perl script that will interact with a unix
program. The command to run the program is easy to do, but I cannot for the
life of me figure out how to get the program to write answers to the query
within the unix program.  Because the unix program is running, the perl
program is on pause until the unix program quits.  i need to give more info
to the unix program before it quits so that it will do what it is supposed to
 .

I know this is kind of a  bad eplanaiton of the problem, but does anyone know
how to run both programs and have one respond to the other many times?



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


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

Date: Fri, 14 Jul 2000 11:13:15 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: Running Programs Within Perl
Message-Id: <396F3C1B.E2C5860@texas.net>

spock0000@my-deja.com wrote:
> 
> Hello, I am trying to write a perl script that will interact with a unix
> program. The command to run the program is easy to do, but I cannot for the
> life of me figure out how to get the program to write answers to the query
> within the unix program.

I *think* you're looking for

IPC::Open3

- Tom


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

Date: Fri, 14 Jul 2000 16:59:31 GMT
From: spock0000@my-deja.com
Subject: Re: Running Programs Within Perl
Message-Id: <8kngt9$l5l$1@nnrp1.deja.com>






In article <396F3C1B.E2C5860@texas.net>,
  Tom Briles <sariq@texas.net> wrote:
> spock0000@my-deja.com wrote:
> >
> > Hello, I am trying to write a perl script that will interact with a
unix
> > program. The command to run the program is easy to do, but I cannot
for the
> > life of me figure out how to get the program to write answers to the
query
> > within the unix program.
>
> I *think* you're looking for
>
> IPC::Open3
>
> - Tom
>

Ummm, what is that and how does it work?


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


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

Date: Fri, 14 Jul 2000 12:33:00 -0500
From: Tom Briles <sariq@texas.net>
Subject: Re: Running Programs Within Perl
Message-Id: <396F4ECC.E3D77875@texas.net>

spock0000@my-deja.com wrote:
> 
> In article <396F3C1B.E2C5860@texas.net>,
>   Tom Briles <sariq@texas.net> wrote:
> > spock0000@my-deja.com wrote:
> > >
> > > Hello, I am trying to write a perl script that will interact with a
> unix
> > > program. The command to run the program is easy to do, but I cannot
> for the
> > > life of me figure out how to get the program to write answers to the
> query
> > > within the unix program.
> >
> > I *think* you're looking for
> >
> > IPC::Open3
> 
> Ummm, what is that and how does it work?

Ummm, what effort have you made to find out?  None, I'd wager.

perldoc -q pipe
perldoc perlipc
perldoc IPC::Open2
perldoc IPC::Open3

The answers to 99% of your Perl questions are as close as your
harddrive.

- Tom


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

Date: Fri, 14 Jul 2000 15:33:53 GMT
From: chadbour@wwa.com (James Weisberg)
Subject: Re: Shortcut for non-defined variables
Message-Id: <BpGb5.2848$IZ1.19157@iad-read.news.verio.net>

In article <slrn8mru6i.bar.tadmc@magna.metronet.com>,
Tad McClellan <tadmc@metronet.com> wrote:
>On Thu, 13 Jul 2000 16:28:40 GMT, James Weisberg <chadbour@wwa.com> wrote:
>
>>   Is there a shorthand for
>>the statement:
>>
>>   $val = (defined $val) ? $val : -1;
>
>>   where $val is set to -1 if $val is not defined. 
>
>   $val = -1 unless defined $val:

	Well that looks nicer, but if I alter the situation slightly and
want to assign $result to -1 if $val is not defined, else $val, then
I am still left with the following (so it seems):

	$result = (defined $val) ? $val : -1;

	That's still ugly, especially if instead of $val, I got some variable
like $hash{$key1}{$key2} that I want to assign to $result.

	From what I've read so far, it seems as if there's been some debate
about a '??' operator that would replace the "$val def= -1" syntax of my
original post. So too, could one write:

	$result = $val ?? -1;

	That certainly looks much nicer to me. What's the hold up?


-- 
World's Greatest Living Poster


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

Date: Fri, 14 Jul 2000 10:27:19 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: String length?
Message-Id: <slrn8mu8q7.dbt.tadmc@magna.metronet.com>

On Fri, 14 Jul 2000 04:05:45 -0500, Jim Kauzlarich <o1technospam@skyenet.nospam.net> wrote:
>
>"Craig Berry" <cberry@cinenet.net> wrote in message
>news:smtel1icnd6138@corp.supernews.com...

>> See the discussion on
>> packages in the Camel book.
>
>Which one?  


There _is_ only one Camel book...


>"Programming Perl"?


 ... and that is it.



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


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

Date: Fri, 14 Jul 2000 10:48:29 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: String length?
Message-Id: <slrn8mua1t.dbt.tadmc@magna.metronet.com>

On Fri, 14 Jul 2000 01:45:56 -0500, Jim Kauzlarich <o1technospam@skyenet.nospam.net> wrote:
>
>"Tad McClellan" <tadmc@metronet.com> wrote in message
>news:slrn8mseeq.c0u.tadmc@magna.metronet.com...
>> On Thu, 13 Jul 2000 16:43:12 -0500, Jim Kauzlarich
><o1technospam@skyenet.nospam.net> wrote:
>> >"Craig Berry" <cberry@cinenet.net> wrote in message
>> >news:sms11e6qnd629@corp.supernews.com...
>> >> Jim Kauzlarich (o1technospam@skyenet.nospam.net) wrote:
>> >>   s/\@/\$/
>> >
>> >Regular expression I assume?  I haven't really delved into them yet.  Is
>> >that a substitution?

>> i.e.    if ( $_[$count] ne "" ) {
>>              ^
>>              ^ scalar, not array slice as you have above
>
>Sorry, don't know what you mean here.


The short version:

   Do not write:        if ( @_[$count] ne "" ) {

   Write instead:       if ( $_[$count] ne "" ) {




The long version:

Those two forms are a *different type* of data.

The difference does not make a difference with the operation
of _your_ code, but it is a bad habit to get into as there are
several places where the difference is profound and surprising.

(i.e. You will eventually debug until you curse and scream, only
      to eventually find that you used a slice where you wanted
      a scalar)

The one you had is an "array slice".

   perldoc perldata

and see the "Slices" section.


The recommended alternative one is a "scalar", also described
in perldata.



>> >I'm a bit surprised that no one snapped at my mis-attempt at using
>strict.
>> >"use strict();"  I'd been up for about 20 hours, and when I attempted to
>add
>> >strict. It came back with the following err that I'm still not sure what
>> >means  (mee tawk gud englush, eh?)
>>
>>
>> Are you sure?
>
>About which part?


About the part where you say you did

   use strict();

and got a strictness-related message.


>And no, by the way.  I'm not.   :)


heh.


>> type:
>>
>>    perldoc perlmod
>>
>> and see the "Packages" section.
>
>Ok.  Is a perldoc question off topic?  


No.

All of the programs that form part of the perl distribution are
on-topic here.

'perldoc' is but one of those programs.


>I'm gonna admit it.  Every time I try
>to use perldoc I can't seem to scroll through it the way it seems I should.


So don't use it then.

It is only a convenient way of looking up stuff in the docs.

If your idea of "convenient" differs from perldoc's operation on
your system, then just use some other method of viewing the docs  :-)


You get the complete set of docs along with the perl distribution.

perldoc is just a way to view them.

Find out where they are on your system, and grep away using
any method you have available.



>Tanx,  and l8r


Please avoid the IRC style of misspellings here.

We prefer the old fashioned form of misspelling on Usenet.

(i.e. the unintentional ones)



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


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

Date: Fri, 14 Jul 2000 17:12:13 GMT
From: spock0000@my-deja.com
Subject: system question
Message-Id: <8knhku$lnk$1@nnrp1.deja.com>

Ok, I'm using the system command to call the su Unix routine on an AIX
4.3.3 system.  I'm using cgi to grab a username and passwords and
putting them into variables.  The program will run the su system command
with the correct username from the cgi field, but I don't know how to
supply the password that the su routine requires.  Because it's no
longer a shell prompt, another system call doesn't work.  right now my
program gets stuck on a "Please enter "username"'s password:" prompt.
Any ideas?


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


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

Date: Fri, 14 Jul 2000 18:28:24 +0200
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: The newbie question
Message-Id: <t6fums0b68n5qdpmto0lvir5bksm3holid@4ax.com>

HiTekHick wrote:

>My question is, (when relevant) should I attempt a lame reply that may 
>have mistakes unbeknownst to myself, or just leave it up to the old pro`s 
>to handle? 

If you have tested your idea, and it seems to be working properly, then
by all means, feel free to post it.

Correcting unobvious mistakes is something many people can benefit from
-- including you, the one who stands corrected.

-- 
	Bart.


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

Date: Fri, 14 Jul 2000 13:26:33 -0400
From: "Michael D. Hofer" <mhofer@jpmorgan.com>
Subject: Re: The newbie question
Message-Id: <396F4D49.24ED76DA@jpmorgan.com>

Bart Lateur wrote:
> 
> HiTekHick wrote:
> 
> >My question is, (when relevant) should I attempt a lame reply that may
> >have mistakes unbeknownst to myself, or just leave it up to the old pro`s
> >to handle?
> 
> If you have tested your idea, and it seems to be working properly, then
> by all means, feel free to post it.
> 
> Correcting unobvious mistakes is something many people can benefit from
> -- including you, the one who stands corrected.
> 
> --
>         Bart.

amen!  thanks bart.  [damn boundary value issues!] :)

-- 
Michael D. Hofer


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

Date: Fri, 14 Jul 2000 18:28:22 +0200
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Upper-to-lower case problem
Message-Id: <l3fumsgvfos8bqvqc1n6iua864qkt0ov02@4ax.com>

Alan Page wrote:

>If Perl is available for the Win95 platform, would it be easier for me to
>install it locally for testing purposes?

Definitely.

You can get perl at <www.activestate.com> or at <www.dynamicstate.com>.
The latter distribution comes with an Apache web server.

-- 
	Bart.


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

Date: 14 Jul 2000 17:05:36 +0100
From: nobull@mail.com
Subject: Re: Use strict & subroutines
Message-Id: <u9u2dsu27i.fsf@wcl-l.bham.ac.uk>

Andrei <andrei@unforgettable.com> writes:

> If I use "use strict" in a subroutine does it refer only to that
> subroutine or to the whole script ?

The subroutine, well actually the BLOCK.  For the whole story see
"perldoc perlmodlib" (as the "perldoc strict" manpage tells you to).

The manuals are your friends - do not be affraid to use them.

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


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

Date: Fri, 14 Jul 2000 11:08:14 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Use strict & subroutines
Message-Id: <slrn8mub6u.dbt.tadmc@magna.metronet.com>

On Fri, 14 Jul 2000 09:07:03 GMT, Andrei <andrei@unforgettable.com> wrote:

>If I use "use strict" in a subroutine does it refer only to that
>subroutine or to the whole script ?


What happened when you tried it?


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


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