[7822] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1447 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 10 12:07:18 1997

Date: Wed, 10 Dec 97 09:00:22 -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           Wed, 10 Dec 1997     Volume: 8 Number: 1447

Today's topics:
     ? Determining the directory of an executing script ? <stanier@neuma.com>
     [Q] Several misc. questions ()
     Re: accessing a file in directory other than cgi script (Bart Lateur)
     Re: best way to find new ora.com releases cheaply (was  lvirden@cas.org
     Bug in h2ph -- Re: Anyone done any utmp/wtmp stuff with <jdporter@min.net>
     Re: Dynamic array names (Andrew M. Langmead)
     Re: Extracting key-value pairs from HTML FORM text <kelvin@pubgroup.com>
     Re: Finding the FILE SIZE (Andrew M. Langmead)
     Local Array initialized to a constant <PageMan@BigFoot.com>
     Re: mkdir not mking my dir <dballing@speedchoice.com>
     Re: mkdir not mking my dir charlot@SPAM-FREE.org
     Re: Multiple tie/untie on gdbm database failing <doug@tc.net>
     Re: Need documentation on WORD_BASIC ole module (John Prideaux)
     Re: Perl Plug-In for Netscape? lvirden@cas.org
     quick script <c.forde@qub.ac.uk>
     Re: Recommended PERL-book? lvirden@cas.org
     removing duplicate entries from the PATH variable <alester@bfsec.bt.co.uk>
     Re: removing duplicate entries from the PATH variable <xxTony.Curtis@vcpc.univie.ac.at>
     Re: removing duplicate entries from the PATH variable (Marek Rouchal)
     Re: Returning information from an nslookup ?? <qdtcall@esb.ericsson.se>
     Re: Returning information from an nslookup ?? (Marek Rouchal)
     running perl with cgi on a NT? (Calle ]sman)
     Re: Socket I/O in Perl5 (Kerry Schwab)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 10 Dec 1997 10:26:13 -0500
From: "jeff stanier" <stanier@neuma.com>
Subject: ? Determining the directory of an executing script ?
Message-Id: <66mcf8$f7n$1@news.intranet.ca>

I am calling a perl script (addvars.pl)  from another application.  The
script "requires " another file containing sub-routines (commonsub.pl).
addvars.pl and commonsub.pl are in the same directory.   Since I am calling
the addvars.pl from  another directory "." does not equal the location of
the addvars.pl or commonsub.pl.  Can I determine the location of the
addvars.pl script as it is executing and unshift or push it into @INC.


Many thanks.






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

Date: 10 Dec 1997 16:40:21 GMT
From: nicholas@neko.binary9.net ()
Subject: [Q] Several misc. questions
Message-Id: <slrn68thff.7ji.nicholas@neko.binary9.net>

Hi folks, I have several unrelated questions I would like to ask.
--
1. Usage of *{}

In my quest to improve my 'perl' programming cleanliness, I decided 
I wanted an 'enum' package similiar to the 'constant' one. I thought
the syntax of

use enum qw(
	ERR_NOERROR
	ERR_WARNING
	ERR_CRITICAL
	ERR_BROKEN
        );

(so that $ERR_NOERROR==0, $ERR_WARNING==1, etc...)

would be just hunky dory. So I looked at constant.pm and came up with
this:

--
package enum;

sub import {
    my $callpack=caller;
    my($pack,@enums)=@_;
    my $tmp;

    for $tmp (0..$#enums) {
	eval "\$${callpack}::$enums[$tmp]=$tmp";
    }
}

1;
--

Which works. However, I have a couple questions. The first is, in
constant.pm, notation like

   *{"${pkg}::${name}"}=value

is used. But when I tried to do the same inside of my enum, like this:

   *{"\$${callpack}::$enums[$tmp]"}=$tmp;

The variables aren't set. Could someone help me out on this? I have
one of those feelings that the *{} notation is more correct. Plus I
have intrinsic negativity against 'eval'.

2. Timing out from an operation
Is there a better way to do timeouts other than:

eval {
   local $SIG{ALRM}=sub{ die };
   alarm(5);
   $_=<STDIN>;
   alarm(0);
};

if ($@) {
   # timed out!
}

????

3.
I recently wanted to try the new perl5.004_54, so I brought it down
and compiled it. Well, it fails MANY MANY of the tests. Since I'm
using glibc under Linux, I'm sure its related to that. Where is there
an appropriate place (mailling list,newsgroup) to ask for help? I'm
very excited about the prospect of using threads under Perl.

Thank you all for your time!



-- 
___________________________________________________________________________

 simple is elegant                                    nicholas@binary9.net
___________________________________________________________________________


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

Date: Wed, 10 Dec 1997 16:04:35 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: accessing a file in directory other than cgi script?
Message-Id: <3491b70c.16915856@news.tornado.be>

none@nowhere.com wrote:

>Is it possible to open a file in a perl cgi script that is in a
>superdirectory (or any other directory for that matter) than the one
>which is in the script itself?

The reason why it doesn't work, could be because your script is accessed
via a different path than you think it is (via links).

Try this script:
	
	print "Content-type: text/plain\n\n";
	print "This script is $0\n";

I think you may be amazed about the result.

The net result is that "..\datafile.txt" then tries to open a file in a
different directory than you think it does.

Using absolute paths doesn't look as nice, but ought to work.

HTH,
Bart.


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

Date: 10 Dec 1997 16:16:26 GMT
From: lvirden@cas.org
Subject: Re: best way to find new ora.com releases cheaply (was Re: Q: Learning perl with no progr. experience)
Message-Id: <66mf8q$27k$3@srv38s4u.cas.org>


According to Russell Schulz  <Russell_Schulz@locutus.ofB.ORG>:
:Randal Schwartz <merlyn@stonehenge.com> writes:
:
:> No, can't say anything in public about content or timeline, but keep
:> watching www.ora.com.
:
:or biz.oreilly.announce (moderated).
:
:oh no, wait, they stopped using that in May.  gnash.

But they _do_ have quite a nice mailing list for announcements.  It's
called ora-news .
-- 
Larry W. Virden                 INET: lvirden@cas.org
<URL:http://www.teraform.com/%7Elvirden/> <*> O- "We are all Kosh."
Unless explicitly stated to the contrary, nothing in this posting should
be construed as representing my employer's opinions.


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

Date: Wed, 10 Dec 1997 10:13:21 -0500
From: John Porter <jdporter@min.net>
Subject: Bug in h2ph -- Re: Anyone done any utmp/wtmp stuff with Perl?
Message-Id: <348EB191.3D68@min.net>

Yes, Andrew, I checked out this problem; the errors are occuring
in sys/types.ph, lines 59 and 61 (in my configuration). Look for 
occurences of the string pid_t.  I believe that this is a bug in
h2ph.  If not everyone has this problem, then maybe there's
something unusual in our sys/types.h files.

What I did to remove the fatal error was delete the (&pid_t) in
these two lines.  (Somehow this C typecast got through h2ph.)
I can't vouch for the correctness of the result, though...

John Porter
jporter@logicon.com


Andrew Pollock wrote:
> 
> I'm about to wade through CPAN, but I thought I'd ask here first...
> 
> I need a Perl script to make utmp/wtmp entries (it's a login replacement).
> I've run the h2ph script on all the relevant header files, but it still
> doesn't work:
> 
> Number found where operator expected at (eval 37) line 1, near ") 0"
>         (Missing operator before 0?)
> Number found where operator expected at (eval 85) line 1, near ") 0"
>         (Missing operator before 0?)
> String found where operator expected at (eval 92) line 1, near "'unsigned
> long'
> 'int'"
>         (Missing operator before  'int'?)
> String found where operator expected at (eval 150) line 1, near
> "&__PATH_ETC_INE
> T"/hosts.equiv""
>         (Missing operator before "/hosts.equiv"?)
> String found where operator expected at (eval 167) line 1, near
> "&__PATH_ETC_INE
> T"/syslog.conf""
>         (Missing operator before "/syslog.conf"?)
> 
> is what I get when running a bare script with just require "utmp.ph" in it.
> 
> Any suggestions would be appreciated.
> 
> Andrew
> --
> 
> ----
> Andrew Pollock  Programmer/System Administrator
> apollock@bit.net.au http://staff.bit.net.au/apollock
> Brisbane Internet Technology Pty Ltd.


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

Date: Wed, 10 Dec 1997 15:07:35 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Dynamic array names
Message-Id: <EKzBCn.52p@world.std.com>

Corey Leighton <cleighto@*ctron.com> writes:

>Anyone have any suggestions on how I can dynamically name arrays?  I
>want to do something like this:

What you are describing is a feature called "symbolic references". See
the perlref man page for details.

But have you thought of using a multidimentional data structure
instead?

@{$data{$file}} = <some stuff>;

Each file is a key in a hash called %data, and the associated value is
a reference to the array containing the information you want to keep
for that file.

See the perldsc man page for details.
-- 
Andrew Langmead


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

Date: Wed, 10 Dec 1997 10:04:58 -0600
From: "Kelvin D. Olson" <kelvin@pubgroup.com>
Subject: Re: Extracting key-value pairs from HTML FORM text
Message-Id: <348EBDAA.6D01A78B@pubgroup.com>

Chris Schoenfeld wrote:

> I retreive an HTML document containing a FORM using LWP.
>
> Now I want to access the key-value pairs of the FORM elements without
> doing the regexp's myself, out of both laziness and a desire that the
> parser be very robust and heavily tested (quotes/noquotes, names w/o
> values, multi-line tags, etc.etc.).
>
> I have looked over the LWP/HTML module docs, but I can't seem to find
> this ability - does it exist?
>

I don't know just how helpful I can be, considering I'm just STARTING to
learn perl. The reason, however, that I even endeavored to learn perl is
because when I use Comso Create on my SGI workstation to create a form
and generate a CGI script to work with it, it writes a perl script. Fact
is, the perl script that is auto-generated by Cosmo does (I think)
exactly what you're looking for. It pulls the form data into key-value
pairs, and then returns it to the submittor's browser in an html table.
However, I've taken this CGI script and edited it to instead write the
data in an entirely different (quote-comma-quote delimited) format onto
disk.

If you'd like, you could e-mail me the HTML form, and I'll dump it into
Cosmo Create, tell it to generate a script, and e-mail the script back
to you... then you can do with it whatever you like.

Regards,
KDO
--
==============================================================
Kelvin D. Olson                     Director of Media Services
kelvin@pubgroup.com                       The Publishing Group
(612) 522-1200 x302                            Minneapolis, MN




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

Date: Wed, 10 Dec 1997 15:02:23 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Finding the FILE SIZE
Message-Id: <EKzB3z.zv@world.std.com>

psullivan@stlnet.com (psullivan) writes:

>I was wondering how I find the file size under unix. I tried using stat:

>$filesize = (stat ($filename))[7];

It works for me here:
  perl -we '$filename = shift; print +(stat($filename))[7]'  .newsrc

Are you sure that $filename contains what you think it does. (If it
was read from a file or from STDIN, did you chomp() the line
terminator?)

Maybe you should start by doing less in each statement.

@stat = stat($filename) || die "Unable to stat $filename: $!\n";
$filesize = $stat[7];

Also, you might want to take a look at the variable $filename under
the debugger. Saying something like:

   print join "|", split '', $filename

can sometime reveal things you didn't expect.


>But that gave me a 0. I also tried an array of file listings:

>$filesize = (stat (@files[$x]))[7];

Does perl give you a warning here? If not, you should be running the
script with the "-w" switch.
-- 
Andrew Langmead


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

Date: 10 Dec 97 10:35:11 -0600
From: "Marc Page" <PageMan@BigFoot.com>
Subject: Local Array initialized to a constant
Message-Id: <B0B420E4-A8CA8@130.164.17.4>

I'm trying to initialize a local array variable to a list of string
constants.  Here is what I tried:

	local(@code)={
	            "7CE8C9A91D953C06E384D1351400", 	#0
	            "7E4607A94D0100",                   			#1
	            "11996B2AB6166300951590100",       	#2
	            "1DD86B22B2A2D2444650500",         		#3
	            "9C786B26B9590169A1C0500",         		#4
	            "D194725EC3A65C7B934E8C41500",     	#5
	            "196AA1E55BB8951F2784D3D710500",   	#6
	            "5DBB9AAD9022124580000",           		#7
	            "D18A2726DF68A214836A322190500",   	#8
	            "E4A776149CBAEDF09AE2DAD1400"};    	#9


but when I try to access it like:

print "[$code[4]]\n";

, I get strings like "HASH(0x2e9fe40)", my output is:

[HASH(0x2e9fe40)]

  Any help is greatly appreciated.

--------------------------------------------------------------------
    - Marc Page <PageMan@BigFoot.com>
       http://www.ridgenet.net/~mackays/pages.cgi
--------------------------------------------------------------------
640K ought to be enough for anybody.
- Bill Gates, 1981
--------------------------------------------------------------------
This message was created and sent using the Cyberdog Mail System
--------------------------------------------------------------------





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

Date: Wed, 10 Dec 1997 09:30:48 -0600
From: Derek Balling <dballing@speedchoice.com>
Subject: Re: mkdir not mking my dir
Message-Id: <D4399AAB81ED8D2C.E5A76D304F5D4DC2.B6D9A6F5D7BD28A5@library-proxy.airnews.net>

Carsten Posingies wrote:
> 
> Leon Andrews wrote:
> 
> >  If I do...
> >
> > $thedir = "/export/home/nc/NC/html/talk/boards/dir_name";
> > mkdir $thedir, oct("775");
> >
> > then the dir is successfully created.
> >
> > if I do
> >
> > $thedir = "/export/home/nc/NC/html/talk/boards/$directory";
> > mkdir $thedir, oct("775");
> >
> > where $directory is exactly "dir_name", nothing happens.
> 
> Tried that? ->
> 
> $directory = "dir_name";
> $thedir = "/export/home/nc/NC/html/talk/boards/".$directory;
> mkdir $thedir, oct("775");

Or perhaps:

$directory = "dir_name";
$thedir = "/export/home/nc/NC/html/talk/boards\/$directory";
mkdir $thedir, oct("775");

Something to tell Perl that the "/" and the "$" are *NOT* 'together'.

(Mileage may vary, I didn't actually test this code)

D


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

Date: 10 Dec 1997 11:42:39 -0500
From: charlot@SPAM-FREE.org
Subject: Re: mkdir not mking my dir
Message-Id: <66mgpv$qi5@stratus.CAM.ORG>

In article <348EA3E0.D9F866D1@pc-design.de>,
Carsten Posingies  <pos@pc-design.de> wrote:
>Leon Andrews wrote:
>
>>  If I do...
>>
>> $thedir = "/export/home/nc/NC/html/talk/boards/dir_name";
>> mkdir $thedir, oct("775");
>>
>> then the dir is successfully created.
>>
>> if I do
>>
>> $thedir = "/export/home/nc/NC/html/talk/boards/$directory";
>> mkdir $thedir, oct("775");
>>
>> where $directory is exactly "dir_name", nothing happens.
>
>Tried that? ->
>
>$directory = "dir_name";
>$thedir = "/export/home/nc/NC/html/talk/boards/".$directory;
>mkdir $thedir, oct("775");
>

That won't change a thing.  Here's what I'd do:

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

use strict;

my $directory = "dir_name";
my $thedir = "/export/home/nc/NC/html/talk/boards/$directory";
mkdir $thedir, 0775 or die("Unable to create dir: $!");
--------------------------

Richard.
-- 
Richard Bellavance -- charlot(at)cam(dot)org -- http://www.cam.org/~charlot/
    "All along this path I tread  /  My heart betrays my weary head
     With nothing but my love to save / From the cradle to the grave"
                                 (Eric Clapton, "From the cradle")


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

Date: 10 Dec 1997 10:35:03 -0500
From: Douglas McNaught <doug@tc.net>
To: steve.vanderburg@lhsc.on.ca (Steve van der Burg)
Subject: Re: Multiple tie/untie on gdbm database failing
Message-Id: <m2btyp9pp3.fsf@ono.tc.net>

[mailed and posted]

steve.vanderburg@lhsc.on.ca (Steve van der Burg) writes:

> This brings up another, more fundamental question: How do I tell if
> a tie has been successful?  Testing $! seems to be a bad idea...

Er...  Check to see if tie() returned undef?  Just like any other Perl 
function? 

-Doug
-- 
sub g{my$i=index$t,$_[0];($i%5,int$i/5)}sub h{substr$t,5*$_[1]+$_[0],1}sub n{(
$_[0]+4)%5}$t='encryptabdfghjklmoqsuvwxz';$c='fxmdwbcmagnyubnyquohyhny';while(
$c=~s/(.)(.)//){($w,$x)=g$1;($y,$z)=g$2;$w==$y&&($p.=h($w,n$x).h($y,n$z))or$x==
$z&&($p.=h(n$w,$x).h(n$y,$z))or($p.=h($y,$x).h($w,$z))}$p=~y/x/ /;print$p,"\n";


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

Date: Wed, 10 Dec 1997 14:48:29 GMT
From: alastl@ctnet.net (John Prideaux)
Subject: Re: Need documentation on WORD_BASIC ole module
Message-Id: <348eab04.1917635@news.fgi.net>

On Tue, 9 Dec 1997 22:27:39 -0800, "P. Nguyen"
<pcnguyen@u.washington.edu> wrote:

>
>I have try to start out my own by lookin at the excel example and produce
>a small script that will read word doc file and save it as htm file.  (I
>use word 97 file option, filesavehtml.  here is an example:
>
>use OLE;
>
>$application =3D CreateObject OLE 'Word.Basic' || die $!;
>
>if (-f "e:\\inetpub\\test.doc") {
>=09$application->{'Visible'} =3D 1;
>=09$application->FileOpen("e:\\inetpub\\test.doc");
>#        $application->WebSelectHyperlink("TRUE");
>#=09$application->ToolsCreateDirectory("e:\\inetpub\\blah");
>=09$application->FileSaveHtml("e:\\inetpub\\test.htm");
>=09$application->FileExit;
>=09$application =3D NULL;
>}
>1;

I thought that office 97 used VBA for it's OLE functionality.
I would presume that Word Basic would still be supported,
but I would doubt that it had been updated to support the
Internet.

A suggestion:
Turn on your macro recorder, perform the functions you
want to perform, then look at the macro.

Hope this helps.
John Prideaux         voice: (217)839-2121  email: alastl@ctnet.net
Aladdin Steel, Inc.   fax:   (217)839-4327
Route 16 East
Gillespie, IL  62033  My opinions are not those of Aladdin Steel, Inc.


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

Date: 10 Dec 1997 16:12:17 GMT
From: lvirden@cas.org
Subject: Re: Perl Plug-In for Netscape?
Message-Id: <66mf11$27k$2@srv38s4u.cas.org>


According to Alex Tang  <altitude@ren.us.itd.umich.edu>:
:I'm not sure if this is what you're talking about, but try
:http://interact.canoe.ca/~bsugars/nsapi_perl.htm

when I attempt access to that page, I get:

Not Found

The requested object does not exist on this server. The link you followed is either outdated, inaccurate, or the
server has been instructed not to let you have it. 

-- 
Larry W. Virden                 INET: lvirden@cas.org
<URL:http://www.teraform.com/%7Elvirden/> <*> O- "We are all Kosh."
Unless explicitly stated to the contrary, nothing in this posting should
be construed as representing my employer's opinions.


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

Date: Wed, 10 Dec 1997 15:39:04 +0000
From: Colin Forde <c.forde@qub.ac.uk>
Subject: quick script
Message-Id: <348EB798.5A24@qub.ac.uk>

Was wondering if some perl whizz kid would like a wee problem.
Ive got a file of text with dns addresses in it, also ip addresses.
These are scattered through the records of the file.
I would like to replace the host in each ip address to *
ie 123.456.7.8 becomes 123.456.7.*
for dns addresses i would like to curtail at the 4th component
ie a1.aaa.bbb.uk would be left alone but
   cc.a1.aa.bb.uk would become just a1.aaa.bbb.uk
Thanks
Colin
-- 

________________________________________________________________
C.Forde@queens-belfast.ac.uk    phone : +44 (0)1232 245133 x3950        
				fax   : +44 (0)1232 230592


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

Date: 10 Dec 1997 16:03:39 GMT
From: lvirden@cas.org
Subject: Re: Recommended PERL-book?
Message-Id: <66megr$27k$1@srv38s4u.cas.org>


According to Jonathan C. Willeke <jwilleke@ix.netcom.com>:
:Finally, I recommend that you check out
:
:    http://language.perl.com/critiques/index.html
:
:if you haven't already.  It's dated, but you can get a sense of what

What part of it do you consider dated?  Are the reviews there no longer
valid?

-- 
Larry W. Virden                 INET: lvirden@cas.org
<URL:http://www.teraform.com/%7Elvirden/> <*> O- "We are all Kosh."
Unless explicitly stated to the contrary, nothing in this posting should
be construed as representing my employer's opinions.


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

Date: Wed, 10 Dec 1997 15:31:57 +0000
From: Adrian Lester <alester@bfsec.bt.co.uk>
Subject: removing duplicate entries from the PATH variable
Message-Id: <348EB5ED.5080@bfsec.bt.co.uk>

Does anyone have any suggestions on how I can check the directories
listed on $PATH and, if any are duplicated, reomve the first occurance
of it?


I've tried a few things but am barking up the wrong tree.

The code below doesn't actually change the code...

#!/usr/bin/perl -w
 
use strict;
 
{
   # my $path = $ENV{'PATH'};
 
    my $path = '/a/b/c/d:/a/b/c/e:/a/b/c/d:/a/b:/a/b:';
 
    print STDOUT "Path is $path \n";
 
    $path =~ s|(\w+:)(\w*)($1)|$2$1|g ;
 
    print STDOUT "Path is $path \n";
}


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

Date: 10 Dec 1997 17:04:09 +0100
From: Remove xx <xxTony.Curtis@vcpc.univie.ac.at>
To: alester@bfsec.bt.co.uk
Subject: Re: removing duplicate entries from the PATH variable
Message-Id: <7xlnxtkww6.fsf@vcpc.univie.ac.at>

Re: removing duplicate entries from the PATH variable,
Adrian <alester@bfsec.bt.co.uk> said:

Adrian> Does anyone have any suggestions on how I can check
Adrian> the directories listed on $PATH and, if any are
Adrian> duplicated, reomve the first occurance of it?

how about this? (semi-tested :-)

    my %seen = ();
    my @idirs = reverse(split(/:/, $ENV{PATH}));
    my @odirs = ();
     
    foreach $d (@idirs) {
        # hash entry prevents multiple matches
        if ($seen{$d}) {
            warn "remove duplicate <$d>\n";
            next;
        }
        $seen{$d} = 1;
        unshift(@odirs, $d);
    }
    
    # test...
    my $path = join(":", @odirs);
    print "new path = <$path>\n";


tony


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

Date: 10 Dec 1997 17:00:51 +0100
From: Marek.Rouchal@-nospam-hl.siemens.de (Marek Rouchal)
Subject: Re: removing duplicate entries from the PATH variable
Message-Id: <66mebj$23@buffalo.HL.Siemens.DE>

In article <348EB5ED.5080@bfsec.bt.co.uk>, Adrian Lester <alester@bfsec.bt.co.uk> writes:
> Does anyone have any suggestions on how I can check the directories
> listed on $PATH and, if any are duplicated, reomve the first occurance
> of it?

Try this (it keeps track of the order, too):

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

use strict;

my $PATH = '/a/b/c/d:/a/b/c/e:/a/b/c/d:/a/b:/a/b:';

my $i = 1;
my %paths;

foreach(split(/:/,$PATH)) {
    $paths{$_} = $i++ unless(defined $paths{$_});
    }
$PATH = join(':',sort {$paths{$a} <=> $paths{$b}} keys %paths);

print "$PATH\n";
__END__

HTH,

Marek

PS. If you want to reply by Email, please remove -nospam- from
    the address. Thank you.


-- 
  Marek Rouchal                   Phone : +49 89/636-25849
     SIEMENS AG, HL CAD SYS       Fax   : +49 89/636-23650
     Balanstr. 73                 mailto:Marek.Rouchal@-nospam-hl.siemens.de
     81541 Muenchen               PCmail:Marek.Rouchal.PC@-nospam-hl.siemens.de


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

Date: 10 Dec 1997 16:17:14 +0100
From: Calle Dybedahl <qdtcall@esb.ericsson.se>
Subject: Re: Returning information from an nslookup ??
Message-Id: <isg1o1kz2d.fsf@godzilla.kiere.ericsson.se>

Carsten Posingies <pos@pc-design.de> writes:

> are you on a Unix machine? If, you should start your favorite editor,
> hack in some C-lines that do the gethostbyaddr() system call to STDOUT
> and use this in your perl script.

Why, when Perl has gethostbyname built in?

sandra:~> perl -MSocket -e 'print scalar gethostbyaddr(inet_aton("130.236.254.203"), AF_INET),"\n";'
sandra.lysator.liu.se
sandra:~> 

-- 
		    Calle Dybedahl, UNIX Sysadmin
       qdtcall@esavionics.se  http://www.lysator.liu.se/~calle/


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

Date: 10 Dec 1997 16:23:52 +0100
From: Marek.Rouchal@-nospam-hl.siemens.de (Marek Rouchal)
Subject: Re: Returning information from an nslookup ??
Message-Id: <66mc68$g@buffalo.HL.Siemens.DE>

In article <348EA581.A85BC45@pc-design.de>, Carsten Posingies <pos@pc-design.de> writes:
> Burt Lewis wrote:
> > >$return = `nslookup 207.180.0.20`;
>
> are you on a Unix machine? If, you should start your favorite editor,
> hack in some C-lines that do the gethostbyaddr() system call to STDOUT
> and use this in your perl script. To format an nslookup return is just
> a waste of time since it's driving you nuts. If you need the C-source, mail
> me.

Or you use the perl builtin functions gethostbyaddr/gethostbyname.
Try "perldoc perlfunc" and look for gethostbyaddr/gethostbyname.
Good luck!

Marek

PS. If you want to reply by Email, please remove -nospam- from
    the address. Thank you.


-- 
  Marek Rouchal                   Phone : +49 89/636-25849
     SIEMENS AG, HL CAD SYS       Fax   : +49 89/636-23650
     Balanstr. 73                 mailto:Marek.Rouchal@-nospam-hl.siemens.de
     81541 Muenchen               PCmail:Marek.Rouchal.PC@-nospam-hl.siemens.de


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

Date: 10 Dec 1997 17:28:28 +0100
From: md4calle@mdstud.chalmers.se (Calle ]sman)
Subject: running perl with cgi on a NT?
Message-Id: <w7p67oxrwlv.fsf@fraggel76.mdstud.chalmers.se>

I wonder if someone want to share experience with running
some cgi-scripts on a NT-webserver.

What differs from running it on a unix?
what do one has to think about regarding security?

is there some neat webserver one can download that I can run on W95/NT so I
can try out the stuff at home? (the computer
shall not be connected to the net, I just want to see that the cgi-scripts
works as supposed to)

what things exist on NT instead of sendmail?

/Calle

**************************************************************************
*         *         My homepage about the author Tom Holt:               *
*        /_\        http://www.mdstud.chalmers.se/~md4calle/holt/        *
*     { ~._.~ }                                                          *
*      (  Y  )      other things like OnLine Guitar Archive linkpage     *
*     ( )~*~( )     and heaps of musiclinks can be found at              *
*     (__)-(__)     http://www.mdstud.chalmers.se/~md4calle/             *
**************************************************************************



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

Date: 10 Dec 1997 09:24:39 -0700
From: kschwab@nyx.net (Kerry Schwab)
Subject: Re: Socket I/O in Perl5
Message-Id: <66mfo7$duh$1@nyx.nyx.net>

In article <348D93D5.B800556@cyberjunkie.com>,
Erik D. Jones <erikdj@cyberjunkie.com> wrote:
>I am working with PERL5.003 and I'm writing a program that scans a range
>of IP addresses.  For each IP address it attempts a socket connection to
>a particular PORT.  Everything works great and I am able to process the
>errors properly and all that (set by errno from the connect() function
>call), but the connection timeout value is set so high that without
>creating a multithreaded program, this scan is going to take a million
>years.
>
>get/setsockopt does not seem to have a value that specifically relates
>to connection timeouts.  It has
>SO_SNDTIMEO and SO_RCVTIMEO, but those timers seem to be related to the
>actual data comm. once a connection has already been established.  I
>looked in my $INCLUDE/sys/socketvar.h and saw that the socket struct has
>a 
>so_timeo private variable related to connection timeouts, but I can't
>change that.  
>

[ comp.lang.perl is dead, *.modules has little to do with this,
  followups set to comp.lang.perl.misc ]

Some options:

1) fork() and do x number of connect()'s in parallel

   (well, this is easy to implement)

2) use alarm() to timeout the connect()'s earlier
 
   (doesn't make much sense in your context)

3) use non-blocking connect and select()

   ( More complex to implement than fork...) 

   to set a filehandle for non-blocking behaviour: 
   use Fcntl;
   fcntl(HANDLE,F_SETFL,O_NONBLOCK) or die "no non-block? $!\n";
  
   Check your local man page for connect to see more details.
   Here's an  excerpt from the HPUX 10.x manpage:

---------
         If the socket is of type SOCK_STREAM, connect() attempts to contact
      the remote host to make a connection between the remote socket (peer)
      and the local socket specified by s.  The call normally blocks until
      the connection completes.  If nonblocking mode has been enabled with
      the O_NONBLOCK or O_NDELAY fcntl() flags or the FIOSNBIO ioctl()
      request and the connection cannot be completed immediately, connect()
      returns an error as described below.  In these cases, select() can be
      used on this socket to determine when the connection has completed by
      selecting it for writing.

      O_NONBLOCK and O_NDELAY are defined in <sys/fcntl.h> and explained in
      fcntl(2), fcntl(5), and socket(7).  FIOSNBIO is defined in
      <sys/ioctl.h> and explained in ioctl(2), ioctl(5), and socket(7).
----

----

   (errno section)

   [EINPROGRESS]                    Nonblocking I/O is enabled using
                                    O_NONBLOCK, O_NDELAY, or FIOSNBIO, and
                                    the connection cannot be completed
                                    immediately.  This is not a failure.
                                    Make the connect() call again a few
                                    seconds later.  Alternatively, wait for
                                    completion by calling select() and
                                    selecting for write.

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


Kerry


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

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

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