[12290] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5890 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 4 17:07:26 1999

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

Perl-Users Digest           Fri, 4 Jun 1999     Volume: 8 Number: 5890

Today's topics:
    Re: Calling another Perl script <nobody@newsfeeds.com>
    Re: CGI Scripting to a database <gregm@well.com>
    Re: CGI Scripting to a database <perlguy@technologist.com>
        CGI.pm <rnelson@odtools.com>
    Re: CGI.pm <rootbeer@redcat.com>
    Re: DBI vs ODBC?? <REMOVENOSPAMwmtoh@singnet.com.sg>
    Re: Determining height and with of uploaded Graphic fil <REMOVENOSPAMwmtoh@singnet.com.sg>
    Re: Determining height and with of uploaded Graphic fil <rootbeer@redcat.com>
        Doesn't matter <oliver@admiralq.free-online.net>
        Efficient way to extract form tags from an HTML page.-- (Jamie Jackson)
    Re: Executing adduser? Follow Up. <rootbeer@redcat.com>
        Expect problem on NT nunzio1714@my-deja.com
        Local filehandles <john.wood@diamond.co.uk>
    Re: Multiple line read from file ?? (Larry Rosler)
    Re: Newbie: Would really appreciate some pointers on as (Larry Rosler)
    Re: Password Generator (Ben Coleman)
        perl acting up on NT, problem with reading * as an argu dominikos@my-deja.com
        Processing incoming mail <cwillison@vrcis.com>
    Re: Processing incoming mail <rootbeer@redcat.com>
        Q: Auto-indent & colorize perl code? <andrew@alumni.haas.org>
    Re: Q: Auto-indent & colorize perl code? <rootbeer@redcat.com>
    Re: Q: Auto-indent & colorize perl code? <magus@cs.cmu.edu>
    Re: Q: Auto-indent & colorize perl code? <jeff@vpservices.com>
        reading and writing to a pipe <bill.lewis@corp.usa.net>
    Re: reading and writing to a pipe (Randal L. Schwartz)
        replacing a word in a flat file <sjain@uswest.com>
        resolution: taint checking (Alan Young)
    Re: s/a*/x/g behavior <uri@sysarch.com>
        Simple newbie question... (Mark Morley)
    Re: Simple newbie question... <rootbeer@redcat.com>
    Re: Simple newbie question... <perlguy@technologist.com>
    Re: Simple newbie question... (Larry Rosler)
    Re: Simple question about hashes <nbarney@csd.sdl.usu.edu>
    Re: Simple question about hashes <uri@sysarch.com>
    Re: The artistic license and perl: <rra@stanford.edu>
    Re: Using DLL functions in Perl sbeaulieu@my-deja.com
        Using Or to evaluate multiple values jeff5491@my-deja.com
    Re: Using Or to evaluate multiple values <uri@sysarch.com>
    Re: What is the meaning of '.' in @INC? <rootbeer@redcat.com>
        XS: Overriding errno? <elf@halcyon.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Fri, 4 Jun 1999 12:03:52 -0700
From: Anonymous <nobody@newsfeeds.com>
Subject: Re: Calling another Perl script
Message-Id: <3758259f@anonymous.newsfeeds.com>

Wyzelli:

TIMTOWTDI -- I do it with backticks...

    chomp($reply = `perlfunc $arg`);

Note that I use bash, the files containing my scripts don't end
with ".pl", and I put "#!/usr/bin/perl -w" at the top of each file.
For other approaches, you might need something like `perl
perfunc.pl $arg`.

--
David
dchristensen@california.com



Wyzelli wrote in message <34P53.3$xx4.1438@vic.nntp.telstra.net>...
>What is the correct (or best) way to invoke one Perl Script from
another?
>
>ie I have one script which contains some subroutines and I want to
write
>another to test for certain conditions (date related) before
running the
>first.
>
>I have searched the FAQ, PerlDOC and all things I can think of but
I guess I
>am searching on exactly the wrong keywords.
>
>Even a pointer to the correct FAQ would be appreciated!
>
>TIA
>
>Wyzelli
>
>
>



  --------== Posted Anonymously via Newsfeeds.Com ==-------
     Featuring the worlds only Anonymous Usenet Server
    -----------== http://www.newsfeeds.com ==----------


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

Date: Fri, 04 Jun 1999 11:49:31 -0700
From: Greg McCann <gregm@well.com>
Subject: Re: CGI Scripting to a database
Message-Id: <37581FBB.2BA1A3BE@well.com>

paulm@dirigo.com wrote:
> 
> In article <3756D144.5C659782@well.com>,
>   Greg McCann <gregm@well.com> wrote:
> > paulm@dirigo.com wrote:
> > >
> > > I'm currently in the process of setting up our database to be web
> > > enabled.  Does anyone know of a place where I can get an idea of
> how to
> > > write CGI scripts to query a database via ODBC?
> >
> > http://www.roth.net/perl/odbc/
> Sweet!  This is a great start. With this in mind, does this site go
> into detail about how the code would look to pull out data from
> fields/tables from a database and then send them to an html file?

IIRC, it's a little sparse on detail, especially when it comes to creating HTML
from data sets.  You'll need to study HTML formatting and CGI techniques to make
this work.

The comp.infosystems.www.authoring.cgi newsgroup is a good source for additional
information on CGI issues that are not perl-specific.

Greg

-- 

======================
Gregory McCann
http://www.calypteanna.com

"Be kind, for everyone you meet is fighting a great battle."  Saint Philo of
Alexandria


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

Date: Fri, 04 Jun 1999 15:04:53 -0500
From: Brent Michalski <perlguy@technologist.com>
Subject: Re: CGI Scripting to a database
Message-Id: <37583165.F390B68C@technologist.com>

You are probably better off using the DBD::ODBC drivers because you can
then port your code directly to Unix just by changing the ::ODBC driver
to whatever the new one is.

I have an example of a MySQL database at:
http://www.inlink.com/~perlguy/sql

Good luck,
Brent


Greg McCann wrote:
> 
> paulm@dirigo.com wrote:
> >
> > In article <3756D144.5C659782@well.com>,
> >   Greg McCann <gregm@well.com> wrote:
> > > paulm@dirigo.com wrote:
> > > >
> > > > I'm currently in the process of setting up our database to be web
> > > > enabled.  Does anyone know of a place where I can get an idea of
> > how to
> > > > write CGI scripts to query a database via ODBC?
> > >
> > > http://www.roth.net/perl/odbc/
> > Sweet!  This is a great start. With this in mind, does this site go
> > into detail about how the code would look to pull out data from
> > fields/tables from a database and then send them to an html file?
> 
> IIRC, it's a little sparse on detail, especially when it comes to creating HTML
> from data sets.  You'll need to study HTML formatting and CGI techniques to make
> this work.
> 
> The comp.infosystems.www.authoring.cgi newsgroup is a good source for additional
> information on CGI issues that are not perl-specific.
> 
> Greg
> 
> --
> 
> ======================
> Gregory McCann
> http://www.calypteanna.com
> 
> "Be kind, for everyone you meet is fighting a great battle."  Saint Philo of
> Alexandria


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

Date: Fri, 04 Jun 1999 13:17:52 -0600
From: Ryan Nelson <rnelson@odtools.com>
Subject: CGI.pm
Message-Id: <37582660.B758E924@odtools.com>

I was wondering if anyone could give me some assistance with using
CGI.pm.  I am trying to get direct access to the string passed to stdin
by an HTML POST.  I can't use the "param" function because it parses the
value for me, whereas I want the raw data.  I've tried using
"param_fetch," but I must be using it incorrectly because it does not
retrieve the parameter I request, and exits with "abnormal program
termination."  Any suggestions?

Thanks,
Ryan Nelson
rnelson@odtools.com



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

Date: Fri, 4 Jun 1999 12:39:37 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: CGI.pm
Message-Id: <Pine.GSO.4.02A.9906041229320.10794-100000@user2.teleport.com>

On Fri, 4 Jun 1999, Ryan Nelson wrote:

> I was wondering if anyone could give me some assistance with using
> CGI.pm.  I am trying to get direct access to the string passed to
> stdin by an HTML POST.

I can't see what use the raw data could be to you, but I think you might
want (the undocumented) @CGI::QUERY_PARAM. That's not exactly what you
asked for, though. 

If you _know_ that the data are coming via STDIN, you could read them
yourself and initialize CGI.pm via new(). But that's not the best way.

If you have any "real" use for this information, you should probably ask
the module's author to provide a way to access it. By "real", I mean that
this wouldn't apply if you're only doing this for your own amusement, say. 

Cheers!

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



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

Date: Sun, 6 Jun 1999 03:52:57 +0800
From: "Luke" <REMOVENOSPAMwmtoh@singnet.com.sg>
Subject: Re: DBI vs ODBC??
Message-Id: <7j9bes$12q$1@clematis.singnet.com.sg>

Hi,

      My problem now is choosing between DBI method or Win32::ODBC method.

    Is there any speed difference?  To my knowledge, using DBI adds an extra
layer over ODBC.  Is this correct?

    Is DBD an equiv of ODBC drivers??

    Would using DBI+DBD make it easier to port the source codes from NT to a
Unix system as compared to ODBC?  And would using it make porting DATABASEs
be easier too?


Luke

CMcphe6584 <cmcphe6584@aol.com> wrote in message
news:19990603172437.16926.00000122@ng-fz1.aol.com...
> Luke,
>
> >  Could someone tell me the difference between DBI and ODBC and which
> >method is better to use to interface a program with a database?
>
> I'd always use DBI - it has multiple DBDs
> beneath it, so you can plug in your DBD::Oracle
> (or whatever) instead of your DBD::ODBC.
>
> The only thing that needs to change in your code
> should be the connect stuff (user/pass/db name/type).  And if you make
these
> parameters....
>
> Colin McPherson




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

Date: Sun, 6 Jun 1999 03:45:40 +0800
From: "Luke" <REMOVENOSPAMwmtoh@singnet.com.sg>
Subject: Re: Determining height and with of uploaded Graphic files
Message-Id: <7j9b18$12l$1@clematis.singnet.com.sg>

Hi,

   Is there a way to determine the SIZE (memory-wise) of an image file
before the actual upload to server commences, so that I can bar images above
a certain size.  By upload, I mean a user uploading via web browser to my
server.  This is to prevent unneccessary disk space going to waste as well
as preventing someone from hogging the bandwidth of my server.

Luke



<mraffin@cisclub.acad.emich.edu> wrote in message
news:7j0tnc$7ko$1@nnrp1.deja.com...
> I need to determine the height and width of graphic files that users
> upload (via browser) to my site.  Is this possible?
>
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.




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

Date: Fri, 4 Jun 1999 13:14:19 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Determining height and with of uploaded Graphic files
Message-Id: <Pine.GSO.4.02A.9906041310550.10794-100000@user2.teleport.com>

On Sun, 6 Jun 1999, Luke wrote:

>    Is there a way to determine the SIZE (memory-wise) of an image file
> before the actual upload to server commences, so that I can bar images
> above a certain size.

If this is possible, it's done by means of the protocol through which your
program communicates with the remote client. You can find more information
through the docs, FAQs, and newsgroups about the protocol. Cheers!

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



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

Date: Fri, 4 Jun 1999 18:59:25 +0100
From: "Oliver Brown" <oliver@admiralq.free-online.net>
Subject: Doesn't matter
Message-Id: <bAU53.615$Hy4.628@wards>


Oliver Brown <oliver@admiralq.free-online.net> wrote in message
news:BqU53.613$Hy4.605@wards...
>
>
>




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

Date: Fri, 04 Jun 1999 20:15:35 GMT
From: wasteNOSPAMbasket@bigfoot.com (Jamie Jackson)
Subject: Efficient way to extract form tags from an HTML page.--Suggestions?
Message-Id: <375830c3.84665292@news.erols.com>

Assuming my script has already grabbed a webpage (contents stored in
$page), can you suggest an efficient way of extracting (then
appropriately printing) only the <form***>, <input***>, and </form>
tags?

I am new to Perl, and I have come up with a bunch of ways to do this,
but they are horribly unattractive and inefficient.

Thank you very much,
Jamie Jackson  (email repliers: remove "NOSPAM")


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

Date: Fri, 4 Jun 1999 11:33:16 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Executing adduser? Follow Up.
Message-Id: <Pine.GSO.4.02A.9906041117150.10794-100000@user2.teleport.com>

On 4 Jun 1999, Vincent Ridderikhoff wrote:

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

Why is that commented out? Using strict won't cause you any problems with
calling an external program, and it may help you to catch bugs in your
code.

> print "Reading File.\n ";
> open(FILE,"new.txt");

Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.

>   $line = <FILE>;
>     while ($line ne "") {
>       chomp($line);
>  ($user, $pass) = split(/;/,$line);
>         #print ($user,"\t",$pass);
>  $line = <FILE>;
>   }

Now, do you see that $user and $pass are being overwritten each time
through the loop? I think you want something like this, although you may
want to change some of the details.

    while (<FILE>) {
	chomp;
	s/#.*//;	# Drop comments
	s/^\s+//;	# Drop leading whitespace
	s/\s+$//;	# and trailing
	next unless /\S/;	# Skip blank lines
	my($user, $pass) = split /\s*;\s*/;
	warn "Bad username: '$user'"
	    unless $user =~ /^[a-z][a-z0-9]{1,7}$/;
	unless ($pass) {
	    warn "Missing password for user $user";
	    $pass = rand(10000) . rand(10000);	# :-)
	}
	warn "Bad password for user $user"
	    unless $pass =~ /\S{5,}/;
	&add_user($user, $pass);	# code to be written...
    }

Now, you can either make the add_user subroutine or put the system() call
in there. Good luck!

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



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

Date: Fri, 04 Jun 1999 16:51:31 GMT
From: nunzio1714@my-deja.com
Subject: Expect problem on NT
Message-Id: <7j906f$hqr$1@nnrp1.deja.com>

I'm trying to run perl scripts using the Expect.pm
module on an NT box.  I've installed activestate
perl and downloaded and copied all applicable *.pm
for CPAN (Stty.pm, Pty.pm, Expect.pm). The Install
readme form CPAN says to copy the *.pm files to
directories in the @INC array.  I've done that but
when I run a simple script:

#!/usr/local/bin/perl -w

use Expect;

I get an error message stating:

Can't locate lodable object for IO::Tty in
@INC.(@INC contains: c:/perl/lib/IO c:/perl/lib
c:/perl/site/lib .) at ex1.plx line 7.
BEGIN failed--compilation aborted ex1.plx line 7.

I run the script using the command:
perl ex1.plx

What is the problem?


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


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

Date: Fri, 4 Jun 1999 20:56:27 +0100
From: "Paul Wood" <john.wood@diamond.co.uk>
Subject: Local filehandles
Message-Id: <7j9b1d$2at$1@nclient3-gui.server.ntli.net>

I see people talking about local filehandles and how to create them, but I
am just curious as to their uses. How much of a boon are they and should I
be using them?
Thanks,

-Paul.




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

Date: Fri, 4 Jun 1999 11:21:01 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Multiple line read from file ??
Message-Id: <MPG.11c1b8e481357f8f989b6c@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <3757d8cb@news.uk.ibm.net> on Fri, 4 Jun 1999 16:49:39 +0200, 
Vincent Vanbiervliet <vincent_vanbiervliet@be.ibm.com> says...
> Maybe I understood your post wrong, but I have no idea why the output
> would be interesting. This is what I got:
 ... 
> %%%%Label_&&&&
> %%%%1:
>     data
>     data
>     data
> Label_&&&&
> %%%%2:
>     data
>     data
> Label_&&&&
> %%%%3:
 ...

> > In article <7j8f7u$87n$1@tasmania.dev.ict.nl> on Fri, 4 Jun 1999
> > 14:04:33 +0200, Robert Meppelink <robert.meppelink@ict.nl> says...
 ...
> > > Now I want to read the all data line's from Label_1 till Label_2,
> > > Label2 till Label_3 etc.

That's what the code I posted does.  I put in the %%%% and &&&&
to demarcate the values of $_ that are returned on each iteration.
Here they are without the noise:

Label_

1:
    data
    data
    data
Label_

2:
    data
    data
Label_

3:
    ...

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


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

Date: Fri, 4 Jun 1999 11:52:17 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Newbie: Would really appreciate some pointers on assigning index number   to RHS replacement of a regex
Message-Id: <MPG.11c1c0399ca724c6989b6e@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <37581751.973CBEB5@netzero.net> on Fri, 04 Jun 1999 14:13:37 
-0400, CY <k1001@netzero.net> says...
 ...
>     I want to replace apple with orange and assign the index number
> (i.e. 1, 2, 3, 4,...) in front of "orange"
> 
> I try 
 ...
> $counter=0;
> $o="orange";
> $styring =~s/apple/($counter++).$o/ige;
> 
> neither of them work.

This seems to work for me (same as your second try, quoted above)!

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

$_ = "pineapples applesauce SNAPPLE\n";
my $counter = 0;
my $o = 'orange';
s/apple/$counter++ . $o/ige;
print;
__END__

pine0oranges 1orangesauce SN2orange

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


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

Date: Fri, 04 Jun 1999 20:36:53 GMT
From: tnguru@termnetinc.com (Ben Coleman)
Subject: Re: Password Generator
Message-Id: <3758373d.1560247166@news.mindspring.com>

On Fri, 04 Jun 1999 09:24:10 GMT, NukeEmUp@ThePentagon.com (David Cantrell)
wrote:

>A good method is to use a large dictionary, choose two random words
>and concatenate them with a random non-alphabetic character in the
>middle

A.K.A. "The Compuserve Method".  This works out fairly well as long as you
keep the words short.

Ben
-- 
Ben Coleman
Senior Systems Analyst
TermNet Merchant Services, Inc.
Atlanta, GA


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

Date: Fri, 04 Jun 1999 18:20:03 GMT
From: dominikos@my-deja.com
Subject: perl acting up on NT, problem with reading * as an argument
Message-Id: <7j95c9$jvo$1@nnrp1.deja.com>

I try to run the same perl script on unix, using version 5.004_04, and
on NT, using version 5.005_02. My script is very simple,

#! /usr/sbin/perl
#

foreach $header ( @ARGV ) {
    print $header,"\n";
}

when I run it on unix as ./new.pl *.pl, it lists all the perl scripts in
a directory. When I run it on NT, it complains that it cannot find *.pl.

What is a work around this problem? I really want to have one script
running on both platforms.

- Dominik



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


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

Date: Fri, 04 Jun 1999 11:46:59 -0700
From: Chris Willison <cwillison@vrcis.com>
Subject: Processing incoming mail
Message-Id: <37581F23.F3C9BA5F@vrcis.com>

Is there an easy way, in Perl (of course) to scan through
the inbox of my mail account looking for emails that failed?
This would all run on the server (A solaris machine)


Thanks,


Dweezel.




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

Date: Fri, 4 Jun 1999 12:04:18 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Processing incoming mail
Message-Id: <Pine.GSO.4.02A.9906041202340.10794-100000@user2.teleport.com>

On Fri, 4 Jun 1999, Chris Willison wrote:

> Is there an easy way, in Perl (of course) to scan through
> the inbox of my mail account looking for emails that failed?

Maybe you want the Net::POP3 module from CPAN? Hope this helps!

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



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

Date: Fri, 04 Jun 1999 12:54:32 -0700
From: Andrew Vik <andrew@alumni.haas.org>
Subject: Q: Auto-indent & colorize perl code?
Message-Id: <37582EF5.37EE412C@alumni.haas.org>


Is there any nifty method of taking perl code and automatically
indenting and colorizing for loops, commands, etc.?  MSIE does this
nicely for HTML in its VIEW SOURCE command.

Thanks in advance.

Andrew
San Francisco


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

Date: Fri, 4 Jun 1999 13:03:19 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Q: Auto-indent & colorize perl code?
Message-Id: <Pine.GSO.4.02A.9906041302440.10794-100000@user2.teleport.com>

On Fri, 4 Jun 1999, Andrew Vik wrote:

> Is there any nifty method of taking perl code and automatically
> indenting and colorizing for loops, commands, etc.?  

The FAQ talks about this in section three. Cheers!

    http://www.cpan.org/doc/manual/html/pod/perlfaq3.html

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



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

Date: 04 Jun 1999 16:30:29 -0400
From: Nat Lanza <magus@cs.cmu.edu>
Subject: Re: Q: Auto-indent & colorize perl code?
Message-Id: <uocso87k8t6.fsf@evelake.pdl.cs.cmu.edu>

Andrew Vik <andrew@alumni.haas.org> writes:

> Is there any nifty method of taking perl code and automatically
> indenting and colorizing for loops, commands, etc.?  MSIE does this
> nicely for HTML in its VIEW SOURCE command.

Can you be a little more specific about what you want?

Do you want an editor that does syntax highlighting and knows a bit
about Perl? [x]emacs should do nicely there, and I assume that
vi/vim/whatever fancy version of vi you like will do the same.

Or do you want something that takes perl code and pretty-prints it,
outputting postscript, HTML, or something else?


--nat

-- 
nat lanza --------------------- research programmer, parallel data lab, cmu scs
magus@cs.cmu.edu -------------------------------- http://www.cs.cmu.edu/~magus/
there are no whole truths; all truths are half-truths -- alfred north whitehead


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

Date: 4 Jun 1999 20:16:52 GMT
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Q: Auto-indent & colorize perl code?
Message-Id: <375833A2.CF902DB9@vpservices.com>

Andrew Vik wrote:
> 
> Is there any nifty method of taking perl code and automatically
> indenting and colorizing for loops, commands, etc.?  MSIE does this
> nicely for HTML in its VIEW SOURCE command.

Emacs cperl-mode does a great job of this. It *is* available for M$
platforms. OTOH, if you think M$IE does anything nicely, this might not
be the best answer for you. :-)

-- Jeff


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

Date: Fri, 04 Jun 1999 12:31:37 -0600
From: William Lewis <bill.lewis@corp.usa.net>
Subject: reading and writing to a pipe
Message-Id: <37581B89.E2B454B9@corp.usa.net>

I am attempting to send some command through a file
handle and retrieve the output of the command.
This works fine.  This command however uses a secured
shell network link(ssh) to execute the command ans
sometimes asks for the password required to access
the system.

I would like the script to answer this for me if possible.  Is there a
way to do this with just using file handles or do I have to do something
special?

Currently it looks something like this:

open(pipe,"ssh <command>|")
while <inpipe>
  { if(grep(/<string>/, $_))
	{print $_;}
  }
close everything;

that is the basic code. I have tried duping the pipe file handle and
writing to it but it doesnt seem to work.

thanks
Bill Lewis


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

Date: 04 Jun 1999 12:00:04 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: reading and writing to a pipe
Message-Id: <m1lndzg5aj.fsf@halfdome.holdit.com>

>>>>> "William" == William Lewis <bill.lewis@corp.usa.net> writes:

William> I am attempting to send some command through a file
William> handle and retrieve the output of the command.
William> This works fine.  This command however uses a secured
William> shell network link(ssh) to execute the command ans
William> sometimes asks for the password required to access
William> the system.

If I recall, ssh uses /dev/tty, so pipes won't work.  You need
to use something with pseudo-tty support, like Expect.pm.

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Fri, 04 Jun 1999 14:07:44 -0600
From: Samir Jain <sjain@uswest.com>
Subject: replacing a word in a flat file
Message-Id: <37583210.36E0C1E6@uswest.com>

Hi,
 This is my first program and i am stuck.. I have a flat file which
looks like this

usr1:passwd1
usr2:passwd2
usr3:passwd3

I want to replace passwd1 with passwdx.

Please help

Samir






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

Date: Fri, 04 Jun 1999 19:04:46 GMT
From: alany@2021.com (Alan Young)
Subject: resolution: taint checking
Message-Id: <3764232b.13875811@news.supernews.com>

Thank you all for your quick responses.

This was the problem:

I was getting insecure $ENV{PATH} while running -T errors.  I had
tried a number of things (including some that would have broken taint
checking in this instance) and wasn't getting it to work.  I wasn't
finding any help in perldoc (at least I wasn't asking the right
questions).

This was the answer:

$ENV{PATH} must be explicitly set, must begin with a slash (/) and
must be writable only by the same owner/group as the calling program.

This information was in the perldiag and perlsec documentation.

Thanks again for all your help.

Alan


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

Date: 04 Jun 1999 15:37:30 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: s/a*/x/g behavior
Message-Id: <x7n1yfahad.fsf@home.sysarch.com>

>>>>> "JP" == James Peregrino <james_peregrino@harvard.edu> writes:

  JP> Do you know, (or anywhere else know) where it is documented that
  JP> Perl will advance the pointer so that it doesn't infinitely
  JP> replace the null string?  Is it in perlre or the Friedl book?  I'm
  JP> not claiming it isn't documented, it just points out to me that I
  JP> haven't read some section of the documentation thoroughly enough.

MRE page 249, bottom covers this very issue.

perlre (5.005_02) (about page 17 in man format) covers it under the
heading 'Repeated patterns matching zero-length substring'. it even
warns that is is poorly written and i agree. look for the paragraph
which says 'The higher level-loops preserve an additional state between
iterations'.

also mark-jason dominus's regex lecture at the recent perl tutorials in
boston covered it too.

effectlively, if there was no bump, then m/x*/g would loop forever. so
if the previous match in /g mode is an empty string, a special bump is
done to stop the loop.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: 4 Jun 1999 19:38:53 GMT
From: mark@islandnet.com (Mark Morley)
Subject: Simple newbie question...
Message-Id: <7j9a0d$nd9$1@news.islandnet.com>

Both of these tests evaluate to true:

   "0" == 0
   "0" eq 0

So how can one distinguish between the string "0" and the number 0?

Mark


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

Date: Fri, 4 Jun 1999 12:44:08 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Simple newbie question...
Message-Id: <Pine.GSO.4.02A.9906041243560.10794-100000@user2.teleport.com>

On 4 Jun 1999, Mark Morley wrote:

> So how can one distinguish between the string "0" and the number 0?

See the FAQ. Cheers!

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



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

Date: Fri, 04 Jun 1999 15:02:35 -0500
From: Brent Michalski <perlguy@technologist.com>
Subject: Re: Simple newbie question...
Message-Id: <375830DB.F0679046@technologist.com>

Simple.

If you use ==, it means you are looking at numbers.

If you use eq, it means you are looking at strings.

Perl doesn't care and will treat it accordingly.  If you throw a
mathematical operator at it, it will happily do the operation.  If you
perform string manipulations on it, it will happily do that too.

If you've programmed in other "bondage" languages where you have to
declare everything as this type or that, try to just forget about all of
that.  Perl does all of that for you automagically.

HTH,
Brent

- Why settle for beans when you can have Perl(s)?

Mark Morley wrote:
> 
> Both of these tests evaluate to true:
> 
>    "0" == 0
>    "0" eq 0
> 
> So how can one distinguish between the string "0" and the number 0?
> 
> Mark


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

Date: Fri, 4 Jun 1999 13:35:58 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Simple newbie question...
Message-Id: <MPG.11c1d8886711b289989b6f@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <Pine.GSO.4.02A.9906041243560.10794-
100000@user2.teleport.com> on Fri, 4 Jun 1999 12:44:08 -0700, Tom 
Phoenix <rootbeer@redcat.com> says...
> On 4 Jun 1999, Mark Morley wrote:
> 
> > So how can one distinguish between the string "0" and the number 0?
> 
> See the FAQ. Cheers!

Please be more explicit.  I couldn't find anything about this in the 
FAQ.  perlfaq4:  "How do I determine whether a scalar is a 
number/whole/integer/float?" doesn't respond to this question.

I thought that one really couldn't distinguish between them, because 
each is converted into the other in relevant contexts.

    length( 0 ) == 1
    length('0') == 1
     0  + $n == $n
    '0' + $n == $n 
     0  . $x eq "0$x"
    '0' . $x eq "0$x"

I couldn't get anywhere with pack/unpack either. 

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


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

Date: Fri, 04 Jun 1999 13:53:08 -0600
From: Neal Barney <nbarney@csd.sdl.usu.edu>
Subject: Re: Simple question about hashes
Message-Id: <37582EA4.9B3C2311@csd.sdl.usu.edu>

Michel Dalle wrote:
> 
> Because $hash{$junk} is 0 ( = false), so it is indeed 'not found'.
> 
> You should try using this instead :
> 
> if (defined($hash{$junk})) {
> ..
> }
> else {
> ..
> }
> 
> Michel.

	Ah!  That makes much more sense now.  I was wondering if a function
such as 'defined' existed...  Thanks.  ;)


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

Date: 04 Jun 1999 16:18:17 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Simple question about hashes
Message-Id: <x7g147afee.fsf@home.sysarch.com>

>>>>> "NB" == Neal Barney <nbarney@csd.sdl.usu.edu> writes:

  NB> Michel Dalle wrote:
  >> 
  >> Because $hash{$junk} is 0 ( = false), so it is indeed 'not found'.
  >> 
  >> You should try using this instead :
  >> 
  >> if (defined($hash{$junk})) {
  >> ..
  >> }
  >> else {
  >> ..
  >> }
  >> 
  >> Michel.

  NB> 	Ah!  That makes much more sense now.  I was wondering if a
  NB> function such as 'defined' existed...  Thanks.  ;)

but as someone else posted it is better to use exists, as in the case
where a key exists but has an undefined value, then defined will be
false. exists never checks the value, just whethet the key is in the
hash.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: 04 Jun 1999 12:11:57 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: The artistic license and perl:
Message-Id: <ylvhd393wi.fsf@windlord.stanford.edu>

Chris Nandor <pudge@pobox.com> writes:
> Russ Allbery <rra@stanford.edu> wrote:

>> Nowhere here does it say anything about *use*.  So you charge a
>> licensing fee per use of the modified version of Perl and make people
>> purchase a license to use it.

> It doesn't explicitly say "use".  It doesn't have to.  No fee is charged
> for the item itself.  Part of "the item itself" necessarily includes the
> use of it.  At least, in English it does.  I don't know about
> Lawyerspeak, and I don't care.  The lawyers can go jump in a big hole
> together and never come out.  The language is very clear here.  It
> doesn't need to be fixed.

It's probably pointless arguing with you about any license, then, since
you don't seem to be willing to accept the reality of how they're used.
The people interpreting them will be lawyers.  Judges are lawyers.  If
it's not clear to a lawyer, what will be *enforced* should it ever come to
court is what the lawyers think of it.

It's nice that you don't like lawyers.  It's also completely irrelevant.
Your opinion on the clarity of the license doesn't matter, only theirs.
It's okay not to like that, but that doesn't change reality.

> That said, I don't oppose a clarification to include "use".

Clarifications of that sort are precisely what I'm arguing for.

> I just can't see why it is necessary, or how any judge or jury could
> possibly be convinced that "the item itself" does not include its use.

It's not necessarily the case that a jury would even be involved.  And
you'll notice that the other software licenses explicitly include the use
of the item, so there's other work in the field that sets a precendent for
treating them as separate things.  See the discussion in the GPL on this
point, for example.  And note that the Open Source Definition does *not*
talk about the use of the item, and in private e-mail with Eric Raymond
that's apparently *intentional* and it's *expected* that someone can
change a licensing fee per use.

>> | 5. You may charge a reasonable copying fee for any distribution of this
>> | Package.  You may charge any fee you choose for support of this Package.
>> | You may not charge a fee for this Package itself.  However, you may
>> | distribute this Package in aggregate with other (possibly commercial)
>> | programs as part of a larger (possibly commercial) software distribution
>> | provided that you do not advertise this Package as a product of your
>> | own.  You may embed this Package's interpreter within an executable of
>> | yours (by linking); this shall be construed as a mere form of
>> | aggregation, provided that the complete Standard Version of the
>> | interpreter is so embedded.

>> So you write some trivial little wrapper around the Perl interpretor
>> that changes a command-line option or something, and then distribute it
>> as proprietary software.

> Sure.  Go for it.  Why is this Bad?  You can't call it perl, so I don't
> care.

Of course you can call it Perl.  Where in point 5 does it say you can't
call it Perl?

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Fri, 04 Jun 1999 19:12:59 GMT
From: sbeaulieu@my-deja.com
Subject: Re: Using DLL functions in Perl
Message-Id: <7j98fh$l8i$1@nnrp1.deja.com>


> The simplest way is to make the DLL an Automation server DLL,
> and use Win32::OLE to load the component like you would
> any Automation component. Making an Automation DLL is as
> easy as making a regular one in modern compilers.
>
> Scott
>


But how can this be done with Visual C++ 6.0?  I haven't found examples
anywhere for it.  Only one on Excel that comes with every book or doc
on Win32::OLE.  I got XS to work fine, but that only worked with C.  I
need to call C++ functions now and I'm getting errors that seemed to be
related to the fact I'm using C++ code.  In reading other posts, this
seems to be a common problem.  One solution: A C wrapper for C++?
There has got to be a better way, I hope.  I wouldn't even know where
to begin.

Stephen


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


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

Date: Fri, 04 Jun 1999 19:01:52 GMT
From: jeff5491@my-deja.com
Subject: Using Or to evaluate multiple values
Message-Id: <7j97qo$l04$1@nnrp1.deja.com>

I need to evaluate input from a search page and
respond based on the user's input.

This works for a single city match.

elsif (($DATA{'city_text'} || $DATA{'city'}) eq
"MOUNT EDEN")
	{
	print "Mount Eden Rocks!";
	}

There are cases where the print statement will be
common for numerous cities.

This doesn't work for a multiple city match.

elsif (($DATA{'city_text'} || $DATA{'city'}) eq
("MOUNT EDEN" || "SUNOL"))
	{
	print "Cities in Alameda County Rock!";
	}

Is there an elegant way to list all the cities
that apply to this print statement in one elsif
statement?

Thanks,

Jeff


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


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

Date: 04 Jun 1999 16:32:57 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Using Or to evaluate multiple values
Message-Id: <x7aeufaepy.fsf@home.sysarch.com>

>>>>> "j" == jeff5491  <jeff5491@my-deja.com> writes:


  j> elsif (($DATA{'city_text'} || $DATA{'city'}) eq
  j> ("MOUNT EDEN" || "SUNOL"))

where did you get the idea that eq || works across data and not
expressions? did you read the perl docs on those operators? what other
languages do you know that allow that operation?

  j> Is there an elegant way to list all the cities
  j> that apply to this print statement in one elsif
  j> statement?

use the hash, luke!

in general when you see the problem of matching against of a set of things, a
hash is the answer (when set size > 2 or so).

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

publicize what you don't know.

don't take this too personally, but posters from deja are the new
aohellers. using a web form to read and post news must be amazingly
crippling IMO.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Fri, 4 Jun 1999 11:02:52 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: What is the meaning of '.' in @INC?
Message-Id: <Pine.GSO.4.02A.9906041054240.10794-100000@user2.teleport.com>

On Fri, 4 Jun 1999, David Cantrell wrote:

> Because your webserver is broken.  It should set the current directory
> to /cgi-bin/asubdir before running the script but it doesn't.  

Actually, that turns out not to be part of the CGI spec.

    http://hoohoo.ncsa.uiuc.edu/cgi/

Consequently, any CGI program which depends upon being given a certain
working directory is broken. The solution is to explicitly chdir at the
start of the program, as in your suggestion.

> [Copying newsgroup posts to me by mail is considered rude]

You know, I'm glad you said that. I would surely have sent you a copy if
you hadn't, and I'd have offended you for no good reason. If only the
boundaries were always so clear. Of course, if ever I unintentionally
transgress, I hope you'll forgive. Cheers!

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



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

Date: Fri, 4 Jun 1999 11:59:15 -0700
From: Elf Sternberg <elf@halcyon.com>
Subject: XS: Overriding errno?
Message-Id: <Pine.GUL.4.10.9906041156240.8591-100000@coho.halcyon.com>


	I'd like to override the settings on errno so that I can set them
myself.  Looking around inside the guts of mg.c, this doesn't seem
possible.  Anyone get this to work?

		Elf

Elf M. Sternberg, rational romantic mystic cynical idealist
       If you're so smart, why aren't you naked?
A.A 1493                        http://www.halcyon.com/elf/



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

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


Administrivia:

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

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

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 5890
**************************************

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