[17651] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5071 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Dec 9 06:10:26 2000

Date: Sat, 9 Dec 2000 03:10:11 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <976360211-v9-i5071@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 9 Dec 2000     Volume: 9 Number: 5071

Today's topics:
    Re: How do I find out my own IP Address? <cvh@gmx.de>
    Re: List Values and Arrays (Chris Fedde)
    Re: NEWBIE: Help me make a module 'USE-able' on my web  <ter@my-deja.com>
    Re: non-blocking safe pipe opens <bkennedy99@home.com>
    Re: Perl Help with LWP (Chris Fedde)
    Re: PLEASE CHECK MY CODING! (Tim Hammerquist)
    Re: Uploading file via CGI <g.soper@soundhouse.co.uk>
    Re: Uploading file via CGI (David Efflandt)
        Why isn't Perl highly orthogonal? <brannon@lnc.usc.edu>
    Re: Why isn't Perl highly orthogonal? <dave@dave.org.uk>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sat, 09 Dec 2000 10:13:46 +0100
From: Christoph <cvh@gmx.de>
Subject: Re: How do I find out my own IP Address?
Message-Id: <3A31F7CA.49D48720@gmx.de>

Tony Curtis wrote:
> 
> >> On Fri, 8 Dec 2000 20:09:13 -0500,
> >> "Randy Harris" <harrisr@bignet.net> said:
> 
> > Dave Brondsema <brondsem@my-deja.com> wrote in message
> > news:90rsip$dt7$1@nnrp1.deja.com...
> >> In article <3A3165FF.A1434D27@gmx.de>, Christoph
> >> <cvh@gmx.de> wrote: > Hello, > > could anybody tell me
> >> how to find out the IP-address that my >
> >> internet-provider gives me at dial-up?  > I allready
> >> searched CPAN but I couldn't find anything that looks
> > like
> >> a > solution.  >
> >>
> >> print "REMOTE_ADDR: $ENV{REMOTE_ADDR}<br>\n";
> >> %ENV is a has of the cgi environmental variables.
>
>
> > Dave, that does not work on my NT4 system.  However:
> 
> That's because Dave's answer addresses finding the client
> connecting to a web server, which, however, isn't relevant
> here.

Ok, but I this gave me an idea. I simply could change the ip-up script
which is called by the pppd after establishing the connection, and
simply export one more environmental variable which is my IP-address.
 
> >     use Socket; use Sys::Hostname; my $host =
> > hostname(); my $addr = inet_ntoa(scalar
> > gethostbyname($host || 'localhost'));
> 
> That will return the address of the _hostname_
> 
> That won't necessarily find the address of the ethernet or
> ppp (or ...) interface.  In some situations you may have
> more than 1 such interface.

And if you don't have a network-card (I only got a modem) it simply
returns the address of the loopback device.
 
> You might want to search deja for past discussions of this
> topic in this newsgroup.

I will do this but thank you all for your help.

Bye,
  Christoph


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

Date: Sat, 09 Dec 2000 05:39:52 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: List Values and Arrays
Message-Id: <IAjY5.80$B9.170159104@news.frii.net>

In article <slrn932mni.22l.tadmc@magna.metronet.com>,
Tad McClellan <tadmc@metronet.com> wrote:
>Otto Wyss <otto.wyss@bluewin.ch> wrote:
>
>>Doing
>>
>>        perldoc perlfaq4
>>        /list
>>
>>revealed that the FAQ was there, but why didn't match this simple search
>>the word "list" in the text 
>>
>>        "What is the difference between a list and an array?" 
>>
>>What's best way to get to the text in a FAQ?
>
>
>I use grep(1) to search the *.pod files.
>
>I use vi(1) to read the *.pod files.
>


Tom Christiansen's new perlman(1) utility and it's assorted links
has been working quite well for me.  It was available at

    http://doriath.perl.com/misc/perlman-alpha0.tar.gz

on 09/08/2000 but I can't get it there to confirm it as of this writing.
There may be a more mature release by there by now. 

chris


-- 
    This space intentionally left blank


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

Date: Sat, 09 Dec 2000 10:11:55 GMT
From: Tim Richardson <ter@my-deja.com>
Subject: Re: NEWBIE: Help me make a module 'USE-able' on my web site STEP-BY-STEP???
Message-Id: <90t0ha$7ht$1@nnrp1.deja.com>

:
> Thanks so much dtbaker.  Just the sort of step-by-step response I was
hoping
> for.  Thanks for being so thorough... and so patient!
>
My thanks also. With this post, I finally got it working, after so much
trying.
I made a couple of small changes that I had to do to make it work with
the Perl distribution I have.


> <dtbaker_dejanews@my-deja.com> wrote in message
> news:90gqcj$e0k$1@nnrp1.deja.com...
> > In article
<I8QW5.45250$nh5.3258849@newsread1.prod.itd.earthlink.net>,
> >   "Alan Mailer" <clarityassoc@earthlink.net> wrote:
> > > A week or so ago I posted the following message:
> > > > >Please excuse the complete naivete of this question but:  since
I
> > may be
> > > > >deploying my perl scrips on a Unix based web server...
> > ----------------------
> >
> > *most* modules can be installed with the CPAN tool that takes most
of
> > the headache out of download and install. There are a few that you
have
> > to do all the unpacking and "making" yourself. You can always give
it a
> > shot with CPAN first. You should go read the FAQs at www.cpan.org,
but
> > here is a little cheat-sheet to help get going:
> >
> > for modules than can be installed with CPAN, its an easy way to
go....
> > better than the manual process of unpacking and making usually.
> >
> > - first, telnet to your host.
> > - enter interactive mode:
> >
> > $ perl -MCPAN -e shell
> >
> > - to get a help menu
> >
> > cpan> h
> >
> > - to check configuration, use:
> >
> > cpan> o conf
> >
> > - typically, the only one you may want to set to make local non-root
> > installs easy is to set a config var:
> >
> > cpan> o makepl_arg PREFIX=/home/<yourdomain>/usr
or try
o conf makepl_arg PREFIX=/home/<...>

> > cpan> o commit
or try
o commit conf

> >
> > - then you can do installs as simply as:
> >
> > cpan> install Image::Size
> >
> > - then you'll have to add lines in your source to "find" your local
> > installs. the path to the lib should be where the *.pm can be found.
> > something like:
> >
> > use lib "/home/<yourdomain>/usr/lib/perl5/site_perl/5.005" ;
> > use my::module ;
> >
> >
> >
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
> >
>
>

--
Tim Richardson (search string: qweeblebeast)


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


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

Date: Sat, 09 Dec 2000 06:25:14 GMT
From: "Ben Kennedy" <bkennedy99@home.com>
Subject: Re: non-blocking safe pipe opens
Message-Id: <efkY5.182844$td5.26092219@news1.rdc2.pa.home.com>


"Scott Wiersdorf" <sgp22@ipartner.net> wrote in message
news:3A301DBD.40D97804@ipartner.net...
> Hello friends,
>
> I posted last week but didn't ask the right question (and had buggy code
> to post too, thx No-bull).
>
> In the perlipc manpage there is a section called 'safe pipe opens' that
> explains how to open a child to read from:

The "safety" in this section has to do with security and setuid stuff, so it
may not be applicable to what you need to do

> I'd like to do something like the above but make it a non-blocking read
> (I think) because I'll be forking off several dozen children at a time
> and all should write to the same parent (that's another question I
> have).

> I'm familiar with how 'select' works (for reading from multiple
> filehandles) but am stumped on how to do it where the child writes back
> to the parent.

You can use select on multiple blocking filehandles with no issues.  To get
several child processes to write to one parent process, you can use the
pipe() command to open up read/write pairs of file handles (one of many ways
to do it).  Here is a basic example

use IO::Select;
use IO::File;

my $sel = new IO::Select;

for (my $i=1; $i <= 5; $i++) {
    pipe(my $reader,my $writer) or die "Cannot pipe: $!";
    my $kid = fork();
    if ($kid) { # code of parent process
        close $writer; # close writing end of pipe
        $sel->add($reader); # we will read from this later
    } else { # code of child process
        close $reader; # close reading end of pipe
        $writer->autoflush(1); # make sure output gets flushed through pipe!
        while(1) { # child code goes here
            print $writer "I am $$\n"; # this output gets sent to parent via
the pipe
            sleep rand(10);
        }
        exit;
    }
}

while(1) { # code to watch the output
    foreach my $client ($sel->can_read) { # loops through the $reader
handles
        my $data = <$client>;
        print "Got $data";
    }
}

Hope this helps --

--Ben Kennedy




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

Date: Sat, 09 Dec 2000 06:17:05 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Perl Help with LWP
Message-Id: <B7kY5.84$B9.188796928@news.frii.net>

[this posting has de-jeopardized the quoted text]

In article <g2hY5.62414$2A2.2809552@news20.bellglobal.com>,
Wayne Hayes <hayes@sympatico.ca> wrote:
>Enrico Ng wrote in message <90s3ig$8e8$1@newsx.cc.uic.edu>...
>>I wanted to try learning more about LWP and perl.
>>I found a good site a while ago at webreview.com, but the articles arent
>>there anymore
>>does anyone else no of any good sites?
>>
>
>http://www.cpan.org/ , http://www.perl.com
>
>also
>
>Web Client Programming        # Good info on browsers, http, sockets, lwp::,
>etc.
>Clinton Wong
>O'Reilly
>ISBN 1-56592-214-x
>

Surprisingly the LWP cookbook has a few good things to say about using
LWP.  If you have LWP installed you have the cookbook. Try

    perldoc lwpcook

from some convenient command line.

Good Luck
chris
-- 
    This space intentionally left blank


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

Date: Sat, 09 Dec 2000 11:02:33 GMT
From: tim@degree.ath.cx (Tim Hammerquist)
Subject: Re: PLEASE CHECK MY CODING!
Message-Id: <slrn9344du.3gj.tim@degree.ath.cx>

Fryar386 <fryar386@aol.com> wrote:
> Sorry, this may sound a little stupid, but what does trying it from the command
> line (sorry, I'm just a beginner)

You check from the command line to make sure it's outputing headers
correctly, that the HTML is correct; this way you can check to make sure
the script works correctly.  If all's well at the command line, then the
problem may be with the server.

It's just another way of ruling out possible problems.  Call it a
control experiment.  ;)

So on your page, do you get to choose a character to play as?  Will you
be implementing Sensu beans at all?  Do you get to talk trash to the
other player?  That's half the fun of the show.  ;)

-- 
-Tim Hammerquist <timmy@cpan.org>

Experience is a good school, but the fees are high.
	-- Heinrich Heine


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

Date: Sat, 09 Dec 2000 09:21:10 +0000 (GMT)
From: Geoff Soper <g.soper@soundhouse.co.uk>
Subject: Re: Uploading file via CGI
Message-Id: <4a2a1ee26cg.soper@soundhouse.co.uk>

In article <slrn9339e7.2vc.efflandt@efflandt.xnet.com>,
   David Efflandt <efflandt@xnet.com> wrote:
> On Fri, 08 Dec 2000, Geoff Soper <g.soper@soundhouse.co.uk> wrote:
> >In article <4a296bcb8dg.soper@soundhouse.co.uk>, Geoff Soper
> ><g.soper@soundhouse.co.uk> wrote:
> >> i'm using the following piece of code in my first attempt to upload a
> >> file using CGI. While the file is created it is of zero length. Could
> >> somebody point out my error?

> Problem #1 is that, unless CGI.pm changed, upload('upload_1') does not
> exist, it should be param('upload_1').

OK, it's not coming up with an error (about undefined function or
somesuch) as it was before I changed:
use CGI qw(:standard);
to
use CGI qw(:standard upload);

I thought from the CGI.pm documentation (In the part about creating an
upload field) that this upload() function was available for this purpose
from CGI.pm . I think it did say it was a recent addition.

> Problem #2 is that you are handling a binary like a text file.  That
> might or might not work.  See what 'perldoc CGI' says about saving
> binary files.

OK, it happens for my test runs I was trying to upload a text file, even
if my method of printing is wrong it sould print something shouldn't it?
Even if it is wrong?

Thanks for you help!

-- 
Geoff Soper
g.soper@soundhouse.co.uk
Take a look at the Soundhouse page http://www.soundhouse.co.uk/


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

Date: Sat, 9 Dec 2000 10:54:21 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Uploading file via CGI
Message-Id: <slrn9343q6.3l5.efflandt@efflandt.xnet.com>

On Sat, 09 Dec 2000, Geoff Soper <g.soper@soundhouse.co.uk> wrote:
>In article <slrn9339e7.2vc.efflandt@efflandt.xnet.com>,
>   David Efflandt <efflandt@xnet.com> wrote:
>> On Fri, 08 Dec 2000, Geoff Soper <g.soper@soundhouse.co.uk> wrote:
>> >In article <4a296bcb8dg.soper@soundhouse.co.uk>, Geoff Soper
>> ><g.soper@soundhouse.co.uk> wrote:
>> >> i'm using the following piece of code in my first attempt to upload a
>> >> file using CGI. While the file is created it is of zero length. Could
>> >> somebody point out my error?
>
>> Problem #1 is that, unless CGI.pm changed, upload('upload_1') does not
>> exist, it should be param('upload_1').
>
>OK, it's not coming up with an error (about undefined function or
>somesuch) as it was before I changed:
>use CGI qw(:standard);
>to
>use CGI qw(:standard upload);
>
>I thought from the CGI.pm documentation (In the part about creating an
>upload field) that this upload() function was available for this purpose
>from CGI.pm . I think it did say it was a recent addition.
>
>> Problem #2 is that you are handling a binary like a text file.  That
>> might or might not work.  See what 'perldoc CGI' says about saving
>> binary files.
>
>OK, it happens for my test runs I was trying to upload a text file, even
>if my method of printing is wrong it sould print something shouldn't it?
>Even if it is wrong?

If you define an 'upload' function in your 'use CGI ..." statement then
upload('upload_1') would be a custom function translated to the string
"<upload>upload_1</upload>" which when printed to your browser is probably
an unknown tag and therefore hidden.  As far as I know, all field values
including uploaded file name and handle are passed as param('fieldname').

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: Sat, 09 Dec 2000 08:54:13 GMT
From: Terrence Brannon <brannon@lnc.usc.edu>
Subject: Why isn't Perl highly orthogonal?
Message-Id: <lby9xqj7pp.fsf@lnc.usc.edu>


One day my boss asked me: "how do you get the length of an array in
Perl?" So I told him:

scalar @array;

But of course what irked me is how unintuitive and irregular Perl is
and how this forced my boss to ask me something like that.

LENGTH $string => length $string
LENGTH @array  => scalar @array

PORTION $string => substring $string, $offset, $length
PORTION @array  => @array[$offset..$offset+$length]

In other words, conceptually similar operations do not map to the same
name in Perl. Why does this make Perl a better and not worse language,
than the intended replacement to Perl, Ruby, which is in fact highly
regular in all places where Perl isn't, with the above being just a
few examples? 

-- 
Terrence Brannon




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

Date: Sat, 09 Dec 2000 09:11:50 +0000
From: Dave Cross <dave@dave.org.uk>
Subject: Re: Why isn't Perl highly orthogonal?
Message-Id: <ikt33tsprfpk782ijqoi8bacqingbs3u2k@4ax.com>

On Sat, 09 Dec 2000 08:54:13 GMT, Terrence Brannon
<brannon@lnc.usc.edu> wrote:

>
>One day my boss asked me: "how do you get the length of an array in
>Perl?" So I told him:
>
>scalar @array;
>
>But of course what irked me is how unintuitive and irregular Perl is
>and how this forced my boss to ask me something like that.
>
>LENGTH $string => length $string
>LENGTH @array  => scalar @array
>
>PORTION $string => substring $string, $offset, $length
>PORTION @array  => @array[$offset..$offset+$length]
>
>In other words, conceptually similar operations do not map to the same
>name in Perl. Why does this make Perl a better and not worse language,
>than the intended replacement to Perl, Ruby, which is in fact highly
>regular in all places where Perl isn't, with the above being just a
>few examples? 

The length of a string and the number of elemetns in an array really
aren't the same thing at all, so it makes sense to me that I find them
in different ways. The same goes for substrings and array slices.

Thinking of these concepts as similar seems to meto be a hangover from
C, where strings are arrays of characters, but surely we've moved on
since then.

Maybe your boss is a C programmer?

Dave...

-- 
<http://www.dave.org.uk>  SMS: sms@dave.org.uk


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

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


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