[6600] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 225 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 3 06:46:25 1997

Date: Thu, 3 Apr 97 03:00:23 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 3 Apr 1997     Volume: 8 Number: 225

Today's topics:
     Re: arrg (Tad McClellan)
     Re: base conversion (for unix rgb/hex converter) <tom@eiscat.uit.no>
     Basic procedure(merge 2 files) <rty333@email.sps.mot.com>
     Re: Creating a mailto link with a predefined subject li <hennecke@dbag.ulm.daimlerbenz.com>
     Re: Dates before epoch <mpeppler@mbay.net>
     Re: file parsing (Tad McClellan)
     File Read/Write Problem <bnahas@darwin.cc.nd.edu>
     Re: HELP: case insensitivity (Tad McClellan)
     Re: How to use "read()" (Tad McClellan)
     Re: How to use "read()" <flg@vhojd.skovde.se>
     LDAP and Perl (Duncan Harris)
     Re: Match ? (Tad McClellan)
     Re: Match ? <eric@nettown.com>
     Multiple Page Forms????? <emperor@Pathway1.pathcom.com>
     Re: PERL 5.0 on Windows 95... (Nathan V. Patwardhan)
     Perl and VMS <100121.2745@CompuServe.COM>
     perl Compiler on NT, help please. <eric@nettown.com>
     Re: Reading data from _DATA_ <bill@stygian.com>
     Re: Running program on a remote machine (Joshua Lerner)
     setsockopt(IP_HDRINCL) <ken_taylor@hotmail.com>
     Re: Turning output of command into input <shane@together.net>
     Re: Turning output of command into input (Joshua Lerner)
     Re: Turning output of command into input (Tad McClellan)
     Re: Unix and ease of use (WAS: Who makes more ...) ("Bob Taylor")
     Re: Wanted, a currency converter? Automatic file downlo (Abigail)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 2 Apr 1997 21:08:46 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: arrg
Message-Id: <uv6vh5.hsq.ln@localhost>

Dan Boorstein (danboo@ixl.com) wrote:
: Brian Lorraine wrote:
: > 
: > argggg... I'm writing a guestbook program right now in perl. I was just
: > about done with it and then i decided to change a little something on
: > one of the scripts "/cgi-bin/lorraine/gstbook.pl". It didn't work, agve
: > me some error message yadda yadda yadda.. so no biggie right? I just
: > change it back to the way it was (or at least the way i THINK it was)
: > and it still duzn't work.. rather odd cuz i ran it before... anyhoo I
: > ran it in the unix shell to see what line the so called "error" was on
: > and it said line 28... this one:
: > 
: > @eachrec = split(/##/, @wholething[0];


: try:

: @eachrec = split(/##/, @wholething[0]);
:                                      ^
:                                      ^
: You forgot your trailing paren. just before the semicolon.
: Additionally you may want to change @wholething[0] to $wholething[0].
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Of course, since Brian was having trouble with his script,
he surely had already turned on the -w switch to let perl help
with the debugging.

So he already knew about that change, because perl itself 
mentioned it...  

( you did use the -w switch as soon as your script got buggy, didn't you? )


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 03 Apr 1997 11:31:44 +0200
From: Tom Grydeland <tom@eiscat.uit.no>
Subject: Re: base conversion (for unix rgb/hex converter)
Message-Id: <trragswiyn.fsf@eiscat.uit.no>


David Staschover (das@panix.com) (Wanting a unix one-liner) asked:

> :  Is there a function in perl to convert bases?

to which ebohlman@netcom.com (Eric Bohlman) replied:

> Not for converting arbitrary bases, but for this application take a look 
> at printf, sprintf, pack and unpack.

Well, bc can convert between arbitrary bases, and should be standard on
unix, right?  You won't have as much control over output formats, though.

> If all you want to do is take 3 decimal numbers typed on the command line 
> and convert them into a 6-character hex code, the following will do it:

> printf "%02X%02X%02X\n", @ARGV[0..2];

As will (insert wanted numbers)

echo "obase=16;10;24;15422567890" | bc

(with the added convenience of arbitrary precision, although that's
probably not very interesting in this case)

-- 
//Tom Grydeland <Tom@nospam.eiscat.no>  # delete 'nospam.' for valid address
                The case of Randal Schwartz - http://www.lightlink.com/fors/


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

Date: Thu, 03 Apr 1997 14:48:09 +0000
From: Yoshiaki Murakami <rty333@email.sps.mot.com>
Subject: Basic procedure(merge 2 files)
Message-Id: <3343C320.57FD@email.sps.mot.com>

Hello!
I just start to learn Perl.
I can creare very simple procedure for make report from tab 
delimitted flat type file. 
Next, I tried to merge 2 files by 2 or more key items as below. 
Does anybody create procedure for me?
I don't have any sample procedure alound me. 

(File-1)                             (File-2)
BookName(Key);Price         BookName(Key);Auther;Volume
Perl Basic       ;$10            Perl Basic       ;Mr.A    ;100 pages
                             
(Merge File-1 and File-2)
BookName;Auther;Volume     ;Price
--------- ------ --------- -----
Perl Basic Mr.A    100 pages  $10

Thank you for your help. 

Regards, 
    Yoshi.


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

Date: Thu, 03 Apr 1997 11:38:52 +0200
From: "Dr. Marcus Hennecke" <hennecke@dbag.ulm.daimlerbenz.com>
To: Andrew Starr <atstarr@nowhere.edu>
Subject: Re: Creating a mailto link with a predefined subject line.
Message-Id: <33437AAC.234@dbag.ulm.daimlerbenz.com>

Andrew Starr wrote:
> [mailed and posted]

Likewise

> No need for Perl on this one.
> 
> <A HREF = "mailto:username@domain.com?subject=hello">

Please do not use this construct! It was invented by Netscape and is
only supported by newer versions of Netscape and Lynx. All other
browsers respond to this by not delivering the mail *at all*!

This is a typical case of a Netscape invention. HTML 2.0 already had a
solution for this problem:

<A HREF="mailto:username@domain.com" TITLE="Some subject">...</A>

but of course this would have been too simple for Netscape, so instead
they invented a method that would break other browsers (and also older
versions of their own browser as I might add).

You should check out comp.infosystems.www.authoring.html where this
question is asked many times per day (seems like nobody is reading the
FAQ anymore).

Anyway, to make this at least somewhat more appropriate for this group,
you could make the anchor point to a CGI script that does the mailing
for you. It could then add any header you like to the mail, including
the subject.

Marcus


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

Date: Tue, 01 Apr 1997 07:57:02 -0800
From: Michael Peppler <mpeppler@mbay.net>
To: smc@smcnet.com
Subject: Re: Dates before epoch
Message-Id: <3341304E.5D60@mbay.net>

Scott M. Crevier wrote:
> 
> I'm looking for suggestions on how to deal with dates before
> 01-Jan-1970. I've boiled down my needs into two practical examples:
> 
> 1. If I was born on Nov 7, 1962, how can I calculate my age?
> 2. How can I find out what day of the week I was born on?
> 
> Now, I can do both of the above with dates after the Nixon era, but
> I'm working with the Kennedy years. Here's a sample of code (perl 5)
> that I'd like to make work:

I know that the C version of timelocal() on SunOS & Solaris handles this
(as I've used it to store dates in time_t format for historical stock
prices going back to 1930 :-), and running this little script shows
that perl's localtime() handles it too (at least on Solaris:)

prompt> perl -e 'print scalar(localtime(-1000000)), "\n";'
Sat Dec 20 02:13:20 1969

The problem then is figuring out how to get timelocal to return
negative numbers...

Michael
-- 
Michael Peppler, Data Migrations Inc.
mpeppler@mbay.net or mpeppler@bix.com



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

Date: Wed, 2 Apr 1997 22:03:14 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: file parsing
Message-Id: <26avh5.45r.ln@localhost>

Melissa Butler (mbutler@es.com) wrote:
: -- I am trying to extract data from a flat file by using the substr()
: command, but it is not reading the right characters. Is there any
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

What does that mean?

zero characters?
starts with the 21st char instead of the 20th?
gets the 25 characters, but far away from what you wanted to capture?


: suggestions? 

Have you run it with the -w switch to enable warnings from perl?


: I am trying to find a command that works similiar to the
: cut command in shell script.

: Here is a sample:
: while ($varrec=<INPUT>){


Have you dropped a 

print "'$varrec'\n";  # show what perl is trying to take the substring from

statement in here?


: 	$compa = substr($varrec,20,25) 

Drop in this line here:

print "'$compa' extracted from '$varrec'\n" if length($varrec) < 20;

: }


That works fine for me. Of course, my data isn't the same as yours.

When framing your question, you should try and pare it down to
a complete script. Else you may not get the correct answer. 

Without both your code and your data we can only _guess_ what 
your problem _might_ be.

If you had shown something like the below, then we would have a
better chance of _knowing_ what your script's problem is.


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


$lines =<<LINES;
-- I am trying to extract data from a flat file by using the substr()
command, but it is not reading the right characters. Is there any
suggestions? I am trying to find a command that works similiar to the
cut command in shell script.
too short.
LINES


foreach $varrec (split /\n/, $lines) {
   print "\$varrec is ", length($varrec), " characters long\n";
   $compa = substr($varrec,20,25);
   print "$compa\n";
}
-----------------------


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Wed, 02 Apr 1997 23:25:27 -0500
From: brian nahas <bnahas@darwin.cc.nd.edu>
Subject: File Read/Write Problem
Message-Id: <33433137.6FC8@darwin.cc.nd.edu>

Hi,
	I need a little help.  I am trying to open a file
for read and write access.  I am trying to read up to a certain
point and then write over the rest.  I am opening the file using:
open(FILEHANDLE,"+<filename");
This allows me to read up to a certain point, but then when I write
it appends to the end of the file.  If I use:
open(FILEHANDLE,"+>filename");
I am not able to read from the file.  It is a rather large file
so I do not want to have to read it all in to an array and then
do my editing.  Any help would be greatly appreciated.  Thanks.
-Brian Nahas


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

Date: Wed, 2 Apr 1997 21:03:55 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: HELP: case insensitivity
Message-Id: <rm6vh5.hsq.ln@localhost>

Jason Bodnar (jason@cimedia.com) wrote:
: "Aurangzeb M. Agha" <aagha@cis.ohio-state.edu> wrote:

: >Sorry this is a bit long winded.  I'm using perl5.003 to grab zipcodes
: >from a flat file.  The problem is that I initially wrote the code to
: >handle numeric zipcodes only, and now I'm confronted with using Canadian
: >zipcodes too.  I used:
: >
: >    # if $zipcode is a substring of $zip starting at position 0
: >    if ($zipcode eq substr($zip, 0, $length)) {


In English:

if $zipcode matches the first part of $zip...


: >       # get $zip record
: >    }
: >

: Why not just use a regexp to start with:

: if ($zipcode =~ /$zip/i) { ...
       ^^^^^^^     ^^^^

Need to match the beginning of the string to do what the if() above
is doing...

Swap those around too, to do what the if() above is doing...

;-)


In English:

if $zipcode matches the first part of $zip...



In Regex:

if ($zip =~ /^$zipcode/i) { ...  


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Wed, 2 Apr 1997 20:51:31 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: How to use "read()"
Message-Id: <jv5vh5.5rq.ln@localhost>

Ho Kee Ping (hokp@hpsgns1.sgp.hp.com) wrote:
: Hi,
:   I am having trouble understanding how to use the read() function.
: The book I have states that :
  ^^^^^^^^

Book! We don't need no stinkin' book.

Because we have the Plain Old Documentation files to
help us with this sort of question.


:   read(FILEHANDLE, BUFFER, LENGTH, [OFFSET])

:   What I want to know is what does [OFFSET] do?


What you want to do when you want to know is to look for the
function that you want to know about in the free documentation
that is *included with the perl distribution*.

the perlfunc man page says:

"An OFFSET may be specified to place the read
data at some other place than the beginning of the string."

Does that do it for you?



Wouldn't it be great to answer your own question in about 20
seconds and look like a perl know-it-all, rather than
post here and wait hours, days, and look like a foo^H^H^H
non perl know-it-all?



--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 3 Apr 97 06:55:15 GMT
From: "Fredrik Lindberg" <flg@vhojd.skovde.se>
Subject: Re: How to use "read()"
Message-Id: <01bc3ffc$10b46ea0$e20f10c2@odens.di.vhojd.skovde.se>

>>>>> Ho Kee Ping wrote in article 
>  I am having trouble understanding how to use the read() function.
> The book I have states that :
> 
>   read(FILEHANDLE, BUFFER, LENGTH, [OFFSET])
> 
>   What I want to know is what does [OFFSET] do?

Taken from the perlfunc man page: 

      read FILEHANDLE,SCALAR,LENGTH
               Attempts to read LENGTH bytes of data into variable SCALAR
from the specified FILEHANDLE.  Returns the
               number of bytes actually read, or undef if there was an
error.  SCALAR will be grown or shrunk to the
               length actually read.  An OFFSET may be specified to place
the read data at some other place than the
               beginning of the string.  This call is actually implemented
in terms of stdio's fread call.  To get a
               true read system call, see sysread().

For example:

#!/usr/bin/perl

my $Buf = "Some text";
my $XBuf = "Some text";
my $NBytes = 0;

# Read 10 characters from STDIN
$nbytes = read(STDIN, $Buf, 10); 

print STDERR "Got: $Buf\n";    # Previosly value of $Buf overwritten.

# Read another 10 characters from STDIN

$nbytes = read(STDIN, $XBuf, 10,  5);  # Keep 5 first characters of $XBuf

print STDERR "Got: $XBuf\n";   # Will print "Some " plus whatever was read.

__END__

Hope this helps

/Fredrik






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

Date: 2 Apr 1997 23:42:50 GMT
From: duncan@sapio.co.uk (Duncan Harris)
Subject: LDAP and Perl
Message-Id: <memo.970402234226.128E@sapio.compulink.co.uk>


Is anybody doing anything with LDAP and Perl?

Perhaps an LDAP addon module, or native LDAP from Perl?

--
Duncan Harris, Sapio Design Ltd, Manchester, U.K.
~~~~~~~~~~~ mailto:duncan@sapio.co.uk ~~~~~~~~~~~
Web on CD-ROM?  Check out http://www.sapio.co.uk/


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

Date: Wed, 2 Apr 1997 22:40:56 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Match ?
Message-Id: <occvh5.par.ln@localhost>

Geoffrey Hebert (soccer@microserve.net) wrote:
: O.K. I should be able to read one of the books on perl and understand
: matching, but I can't figure this one out.  The scripted was copied
: and works.  


Get "Mastering Regular Expressions" by Jeffrey Friedl if you can.


: I would like some help to break it apart and explain it.

OK.


: It checks a URL for the format http://www.my.com/mydir/my.file
: and it works.

: # Let's check the URL's format
: /http:\/\/([^\/]*)\/*([^ ]*)/;
: $site=$1;
: if (!$site) {die("invalid URL format")}

: #      
: # http://   first part we got it is matching for http://
: #         ([^\/]*)    one or more /nnnnnn sets
                        ^^^^^^^^^^^

_zero_ or more of any character that is _not_ a slash.


:     Why would I not have to include .*

See the line above ;-)


:      like [^\/.*]*

_zero_ or more of any character except these one of these three:

  1) slash
  2) dot (period, full stop, ...)
  3) asterisk

( dot and asterisk) are not special in a [character class] )


: Because I can not thoroughly understand this, the remaining
: just appears to be magic.

: ([^ ]*)   What is this doing?  
            ^^^^^^^^^^^^^^^^^^^

See below.


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

$_='http://www.my.com/other/mydir/my.file';


########
# mine
########

# use m!! instead of //   avoid backslashitis
# (you can use a different punctuation char if you want)

m!
  http://    # match seven literal characters
  (.*?)      # match up to the first
  /          # slash
  (.*)       # match every thing after the first slash
!x;          # x lets me put these comments in here

$site=$1;
$filepath=$2;
print "site '$site'   filepath '$filepath'\n";
die "invalid URL format" unless $site;



########
# yours
########

# it's ugly, but I'll explain it anyway ;-)
/
 http:\/\/ # match seven literal characters (and spend calories typing too)
 ([^\/]*)  # match up to the first
 \/*       # slash OR (since the slash can match zero times)
 ([^ ]*)   # up the the first blank OR end of string
/x;

$site=$1;
$filepath=$2;
print "site '$site'   filepath '$filepath'\n";
die "invalid URL format" unless $site;
 ------------------------------


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Thu, 03 Apr 1997 00:12:50 +0000
From: Eric Poindexter <eric@nettown.com>
To: Geoffrey Hebert <soccer@microserve.net>
Subject: Re: Match ?
Message-Id: <3342F602.1EE81A7E@nettown.com>

Geoffrey Hebert wrote:
> 
> O.K. I should be able to read one of the books on perl and understand
> matching, but I can't figure this one out.  The scripted was copied
> and works.
> 
> I would like some help to break it apart and explain it.
> It checks a URL for the format http://www.my.com/mydir/my.file
> and it works.
> 
> # Let's check the URL's format
> /http:\/\/([^\/]*)\/*([^ ]*)/;
> $site=$1;
> if (!$site) {die("invalid URL format")}
> 
> #
> # http://   first part we got it is matching for http://
> #         ([^\/]*)    one or more /nnnnnn sets
>     Why would I not have to include .*
>      like [^\/.*]*
> 
> Because I can not thoroughly understand this, the remaining
> just appears to be magic.
> 
> ([^ ]*)   What is this doing?
> 
> Thanks

[x] means match the character x
[^x] means match any character that's NOT an x
* means match zero(0) or more times
+ means match one or(1) more times
x|y means x or y

[^ ]* means match anything that's not a space zero or more times...you
could just say [^ ], which means match any character that's not a space.
You can use m!/! instead of /\// to avoid the "leaning toothpick
syndrome".

I believe there are a few other problems with the pattern above, but I
don't know enough about you're application to comment intelligently.

see http://nettown.com/perl/src/pod/perlre.html or other perl
refercences, e.g. http://www.perl.com/perl for more info.

--
A. Eric Poindexter
<mailto:eric@nettown.com>
[http://nettown.com/perl/]
have a good day!


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

Date: 3 Apr 1997 05:23:58 GMT
From: "Jonathan S Hardiman" <emperor@Pathway1.pathcom.com>
Subject: Multiple Page Forms?????
Message-Id: <01bc3fee$507bfac0$ae0ff5cf@dixxonn.on.ca>

How would I go about performing the task of multiple page Web Forms???

Here's the deal:

On the first page I require people's Stats (i.e. address, name, e-mail,
company, type of order and the likes). The second page informs the person
of  how much the order they have selected costs, including shipping, and
asks the person to verify the information that they have sent. The third
page thanks them for the order and sends all the information to my database
so the order can be filled.

I know how to send the information to the database, and script the capture
of the data.

I guess my real question is: Do I need two scripts or can it be done with
one?
And, if it requires two scripts, how do I pass the information from the
first form into hidden fields in the second?

Thankyou,

Jonathan S Hardiman


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

Date: 3 Apr 1997 03:30:21 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: PERL 5.0 on Windows 95...
Message-Id: <5hv88d$989@fridge-nf0.shore.net>

Dico Reyers (dico@peionline.com) wrote:

: Where can I get PERL 5.0 for win95?  Is it easy to install? 

Ask the Perl-Fairy.  Ordinarily (following the tradition of the tooth fairy),
you'd put a tooth under your pillow, but I think it might be uncomfortable
putting your computer under your pillow, so you're probably better off checking
at http://www.activeware.com, and picking up perl5.003_07; DON'T get PerlScript
(for now), and DON'T get the Perl source.

Sweet dreams and good luck!

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: 3 Apr 1997 07:52:24 GMT
From: Frank Backes <100121.2745@CompuServe.COM>
Subject: Perl and VMS
Message-Id: <5hvnjo$po4$1@mhafc.production.compuserve.com>

Is there anybody out there
who got Perl running on a Vax ?

Any hint where I can find sources that compile on a DEC-Alpha 
with VMS or even a compiled executable for a VMS-Alpha ?

Any Version of Perl >= 4.000 would be helpfull ?

Thx in advance

Edwin Luebben
ISS - Groupe Cegedim


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

Date: Thu, 03 Apr 1997 00:58:38 +0000
From: Eric Poindexter <eric@nettown.com>
Subject: perl Compiler on NT, help please.
Message-Id: <334300BE.22F740A8@nettown.com>

I need some help installing the perl compiler on NT, please.

I have enjoyed the benifits of compilied perl on Sun, HP and Linux
operating systems, but not on NT. I have searched the web, including
Evangelo's Frequently Asked Questions (FAQ):
http://www.endcontsw.com/people/evangelo/Perl_for_Win32_FAQ.html   
and http://www.activeware.com, altavista and others.

But...

1. I cannot install the perl compiler without config.h. (and maybe else)
   Do I have to create this by hand?
   I cannot (I am using the gnu unix package (all.tar.gz) for win32 sh) 
   run Configure (see 1 below). 
   I cannot edit config.sh and run config_h.SH.

2. I cannot install "standard package perl"
  it hangs running miniperl to create Developers.c* when running nmake
  from the win32 directory, using cl.exe (I belive version 4.0)
  *(I apologize, the spelling of Developers.c may be wrong)

3. I cannot compile perl using the souce from activeware and others.

4. I cannot find documentation on the using the perl compiler under NT.

(I can install the pre-compiled version of perl from activeware.)

I Really appriecate any and all help you can give and experience you may
have. I love using perl, and the compiler goes a LONG way in quieting
opposition.

Thank you in advance.

My directory of perl compiler stuff is http://nettown.com/perl/compiler/
--
Eric
<mailto:eric@nettown.com>
[http://nettown.com/perl/]
have a good day!


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

Date: 3 Apr 1997 04:54:20 GMT
From: "Bill Brunning" <bill@stygian.com>
Subject: Re: Reading data from _DATA_
Message-Id: <01bc3feb$6e175aa0$c4d823c7@stygian>

C.D. Tobola <ctobola@rrnet.com.spam> wrote in article
<ctobola-ya023180000204972118400001@news.rrnet.com>...
> I'm a perl newbie -- hope this question isn't too foolish....
> 
> I'm building a simple database program. The data is stored after the
> program code using the _DATA_ filehandle.
> 
> Can someone tell me how to read the data (one line at a time) into an
> array. I know how to use iteration -- just don't know how to access this
> data.
> 
> Thanks!  -Cloy

-Cloy:

You can do it one line at a time, thusly:

     $Subscript = 0;

     while (<DATA>) {
         $DataArray[$Subscript++] = $_;
     }

 .... or, more succinctly:

     $Subscript = 0;
     $DataArray[$Subscript++] = $_ while <DATA>;    

 .... or, most Perlishly of all, in one gulp:

     @DataArray = <DATA>;

HTH.

Bill Brunning
bill@stygian.com


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

Date: 3 Apr 1997 00:43:40 -0500
From: jlerner@panix.com (Joshua Lerner)
Subject: Re: Running program on a remote machine
Message-Id: <5hvg2d$qac@panix3.panix.com>

[mailed and posted]

In article <01bc3fdf$2e8bc4e0$7d8a67cf@bbell.voicenet.com>,
Bob Bell <bbell@voicenet.com> wrote:

>your patience.  I am interested in using a Perl program where part of it
>would require running a program on a remote server.  For instance, if you
>were doing it manually, you could telnet to the machine, log in, and run
>the program.  Is there a way to do this in Perl code?  I haven't really

I believe there is a Perl module that emulates telnet.  (You could
always write an Expect script as well.) See

	http://www.perl.com/CPAN
 ..

>messed around with Perl modules yet, so it there some prebuilt code I

Don't worry, they are not hard to use.

>should be looking for?  Thanks, it is appreciated.  E-mail replies would
>probably be best, and URLs to sites with the info I need would be excellent

What if someone else wants to see the reply? ;-)

BTW, comp.lang.perl isn't active any more.

Joshua Lerner


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

Date: 27 Mar 1997 23:52:05 -0800
From: Ken Taylor <ken_taylor@hotmail.com>
Subject: setsockopt(IP_HDRINCL)
Message-Id: <5hftb5$ojo@lori.zippo.com>

Using Perl 5.003, linux 2.0.1

### $IPPROTO_IP == $SOL_IP == 0 $IP_HDRINCL == 2 ###
setsockopt RAWSOCK, $IPPROTO_IP, $IP_HDRINCL, 1; 

is giving an error "Operation not supported by transport endpoint"
What does this mean? A C program identical in operation works fine.

A peculiar point is that it changed to this error after numerous
trys, _without_ the source code being altered. Previously, the
call was returning success, and a datagram was being sent, but
the custom IP header was being replaced by the system, with
0.0.0.0 in the dest_adr field.

I've been over the code umpteen times, it seems fine, could it
be perl or linux at fault?


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

Date: Wed, 2 Apr 1997 22:41:26 -0500
From: Shane DeRidder <shane@together.net>
To: Bob Bell <bbell@voicenet.com>
Subject: Re: Turning output of command into input
Message-Id: <Pine.LNX.3.95.970402223822.2408E-100000@blah.together.net>

-----BEGIN PGP SIGNED MESSAGE-----

On 3 Apr 1997, Bob Bell wrote:

# 	I'm a fairly experienced programmer, but I'm new to Perl, so I
# appreciate your patience.  I am looking to use Perl to run an external
# program.  I know this can be done using the system() command.  How can I
# get to the output of that command?  Say I wanted the results of a "who". 

Well, you could do something like:

#!/path/to/perl

open(BLAH, "/bin/who |") || die "Can't execute who: $!";

while ($input = <BLAH>) {
    print $input;
}
close(BLAH);
## END

The | at the end of the open() statement tells perl to open the command
and make its output from stdout available on file descriptor 'BLAH.'


Shane-

- -------------------------+-------------------------+-----------------------
Shane DeRidder           | System Admin/Webmaster  | AnotherNet's Founder
shane@together.net       | Together Networks       | shane@another.net
http://blah.together.net | http://www.together.net | http://www.another.net
(802)860-5166            | (802)862-2030           | admin@another.net
- -------------------------+-------------------------+-----------------------
   * Finger shane@another.org for my PGP fingerprint and public key *
- ---------------------------------------------------------------------------


-----BEGIN PGP SIGNATURE-----
Version: 2.6.2
Comment: finger shane@another.org for my public key

iQCVAwUBM0MnE1Q4IBNbInGpAQF41wQAp8pcn24SLaxwFf83qdWcFfIJEp4AcEo+
AuBTdpykCxczH/Sgl7kRC8OaoGYmpSbYKfPB6iA+KELS8PVrdyqoO+mEmiq/OdXJ
yiU0bOs4qUN14JVAL1JfEYrsxugGCbXfwIkmrzfx7ZvLo8c+FMLbw2Nd3TPJgLcK
UvWmJHR3r+w=
=VOIz
-----END PGP SIGNATURE-----



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

Date: 3 Apr 1997 00:51:08 -0500
From: jlerner@panix.com (Joshua Lerner)
Subject: Re: Turning output of command into input
Message-Id: <5hvggc$qs9@panix3.panix.com>

[mailed and posted]

In article <01bc3fdf$af124bc0$7d8a67cf@bbell.voicenet.com>,
Bob Bell <bbell@voicenet.com> wrote:
>	I'm a fairly experienced programmer, but I'm new to Perl, so I appreciate
>your patience.  I am looking to use Perl to run an external program.  I

Hmm, where have I seen this before?  ;-)

>know this can be done using the system() command.  How can I get to the
>output of that command?  Say I wanted the results of a "who".  I know I
>could do system("who"), but I need to get to the information.  I know I

>Pointers to sites or FAQs with the info I need as just as good.

Excerpted from the perlfunc(1) man page:

system LIST
               document.  This is NOT what you want to use to
               capture the output from a command, for that you
               should merely use backticks, as described in the
               section on `STRING` in the perlop manpage.


Check perlop(1) for more on using backticks.

Joshua Lerner


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

Date: Wed, 2 Apr 1997 23:31:04 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Turning output of command into input
Message-Id: <oafvh5.mgr.ln@localhost>

Bob Bell (bbell@voicenet.com) wrote:
: 	I'm a fairly experienced programmer, but I'm new to Perl, so I appreciate
: your patience.  I am looking to use Perl to run an external program.  I
                                                     ^^^^^^^^
: know this can be done using the system() command.  How can I get to the
: output of that command?  Say I wanted the results of a "who".  I know I
: could do system("who"), but I need to get to the information.  

@who_results = `who`;  # backticks


: I know I
: could output to a file using ">" or pipe it to another program, but I would
                                                 ^^^^^^^^^^^^^^^

Or pipe it to your Perl script ;-)


: hope that there might be a cleaner way where I could just treat the output
: of my system() call like I would <STDIN>.  Thanks for all your help. 

open(WHO, "who|") || die "could not fork for who";
while (<WHO>) {
   if (/bbell/) {
      print "Hi Bob\n";
   }
}


: Pointers to sites or FAQs with the info I need as just as good.

Searching for 'external' (taken from you question above) in the new
Perl FAQs (available from http://www.perl.com) finds three lines:

--------------
In most cases, you write an external module to do it - see the answer
=head2 How can I capture STDERR from an external command?
There are three basic ways of running external commands:
--------------


And if you go look near that last line:

--------------
There are three basic ways of running external commands:

    system $cmd;                # using system()
    $output = `$cmd`;           # using backticks (``)
    open (PIPE, "cmd |");       # using open()

With system(), both STDOUT and STDERR will go the same place as the
script's versions of these, unless the command redirects them.
Backticks and open() read B<only> the STDOUT of your command.
--------------


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Thu, 3 Apr 1997 00:23:12 -0800
From: brtaylor@qtpi.lakewood.ca.%%%us ("Bob Taylor")
Subject: Re: Unix and ease of use (WAS: Who makes more ...)
Message-Id: <gdpvh5.ukg.ln@localhost>

In article <33422920.58C3@absyss.fr>,
	Douglas Seay <seay@absyss.fr> writes:
> Michael Craft wrote:
>> 
[snip]
> 
> Maybe we have diferent definitions of the idea "socialist".
> The French adopted socialism in 1848 (or there abouts)
> and haven't really looked back since.  Most european
> countries are socialist (some more than others).
> 
> Remember that socialism doesn't say "everything belongs
> to everybody", that is communism.  Socialism says that
> the government (or the people) help everyone irregardless
> of details such as social or financial status, how they
> got into the situation, whatever.  To achieve this end,
> they take the "surplus" resources from the less
> unfortunate to help the more unfortunate.
> 
socialism: n. A political and economic theory of social organization based
on collective or governmental ownership and democratic management of the
essential means for the production and distribution of goods; also, a policy
or practice based on this theory. Cf. collectivism, Fabianism, Marxism,
Bolshevism, communism.

> The socialist party is, in fact, socialist.  Every time
> Jospin (the current leader of the PS) is on TV, he talks
> about how we need to do more (ie-taxes) to help the poor,
> the needy and the hungry.  The right (ie-capitalists
> such as Chirac and Juppe) talking about how much taxes
> are already being consumed helping the poor.  They never
> talk about cutting social aide, just lowering taxes
> (although everyone can read between the lines).

This is NOT socialism. This is no more than the government taking from
the productive citizens to support the bureaucrats running "programs"
for the "poor". This policy will not work, can not work and has not worked.
This "argument" is nothing more than a line of BS. It has been demonstrated
by history that socialism leads to dictatorship which leads to war.
Socialism and democracy cannot co-exist!

> 
[snip]
> 
> As I said in another post, the strong-arm tactics that
> are associated with socialism are not part of the definition.
> Even in the US (a capitalistic country with a few bits
> and pieces of socialism), there is force when you don't
> contribute to the common good (ie- pay taxes).
> 

This is the first time I have seen taxes associated with the redistribution
of wealth referred to "the common good"!

Note the follow-up.

-- 
+---------------------------------------------------------------+
| Bob Taylor             Email: brtaylor@qtpi.lakewood.ca.us    |
|---------------------------------------------------------------|
| A witty statement goes here! (when I get to it!)              |
+---------------------------------------------------------------+


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

Date: Thu, 3 Apr 1997 07:26:56 GMT
From: abigail@ny.fnx.com (Abigail)
Subject: Re: Wanted, a currency converter? Automatic file download?
Message-Id: <E81wow.9n6@nonexistent.com>

On 3 Apr 1997 02:42:42 GMT, Nathan V. Patwardhan wrote in comp.lang.perl.misc:
++ Robert (robert@chalmers.com.au) wrote:
++ 
++ : Does anyone have any currency converter code?
++ 
++ Yes.  Give me five dollars, and I'll shake your hand.  These two are
++ interchangeable in at least five third world nations ... and the
++ exchange rate is always the same  :-)
++ 
++ : Also, I need a perl script to automatically download a text file every
++ : night?
++ 
++ Money?  Download files every night?  Are you part of a cartel?  :-)

Download every night? What if the rate changes in the morning? You 
want to lose money? What you should do is hook up to a Reuters live
feed, and replicate the rates around the world. ;)



Abigail



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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.  

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

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