[8087] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1706 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 22 18:07:24 1998

Date: Thu, 22 Jan 98 15:00:24 -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, 22 Jan 1998     Volume: 8 Number: 1706

Today's topics:
    Re: @ == @, comparing arrays (Earl Hood)
    Re: @ == @, comparing arrays (Clay Irving)
    Re: @ == @, comparing arrays (Clay Irving)
        @INC on winNT <none@nowhere.net>
    Re: Array Troubles <jdporter@min.net>
    Re: FORTRAN format, help! <jdporter@min.net>
        HELP: Stopping undefine function errors at compile time <mark@datasoft.on.ca>
        Net::FTP error trapping (Gene Hsu)
    Re: None <xxTony.Curtis@vcpc.univie.ac.at>
    Re: None (Martien Verbruggen)
    Re: Odd syntax problem <jdporter@min.net>
    Re: Parsing HTML tag parameters (Earl Hood)
    Re: Perl programming with NT4.0: sendmail problem (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
    Re: Perl programming with NT4.0: sendmail problem (Earl Hood)
    Re: PERL Rookie Problem (Faust Gertz)
        Perl5.003 problems with libgdbm.so.1 <me@my.com>
    Re: Please help me!! (Martien Verbruggen)
        possible reasons for broken pipe? lbowen@vic.com
    Re: Problem running perl script <barnett@houston.Geco-Prakla.slb.com>
        Q: How to view NT groups? (Win32::NetAdmin) <junk@sober.com>
        Q: How to view NT groups? (Win32::NetAdmin) <junk@sober.com>
    Re: re-route the standard-out from NT into Perl? <junk@sober.com>
    Re: Reg Expression, can it be improved? <jdporter@min.net>
    Re: Reverse of ReadParse <ajohnson@gpu.srv.ualberta.ca>
    Re: Reverse of ReadParse <scottj@mthcsc.wfu.edu>
    Re: space searching? <jdporter@min.net>
    Re: Trouble with a regex (Earl Hood)
        Unkown Error <ev@kzed.com>
        Wierd error messages??!! <snorris@post.cis.smu.edu>
    Re: Wierd error messages??!! <ajohnson@gpu.srv.ualberta.ca>
    Re: win32:ftp (Richard Bellavance)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 22 Jan 1998 22:11:28 GMT
From: ehood@medusa.acs.uci.edu (Earl Hood)
Subject: Re: @ == @, comparing arrays
Message-Id: <6a8g6g$a1q@news.service.uci.edu>

In article <34C792B6.21A7@wco.com>, Steven Smith  <steves@wco.com> wrote:
>I had assumed that @a1 == @a2 would compare two arrays and
>tell me if they were the same.  It doesn't and that makes
>sense to me -- we're taking the arrays into scalar context
>and comparing the number of elements in each group, right?
>
>Is there an easy way to tell if all elements of the array
>are the same short of a short subroutine?

	(@a1 == @a2) and ("@a1" eq "@a2")

You need the first comparison since an array with a single null
string item and the empty array will expand the same in double-quoted
strings.  To protect against changes to $", you could use join
on both arrays in the second comparison.

	--ewh
-- 
             Earl Hood              | University of California: Irvine
      ehood@medusa.acs.uci.edu      |      Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME


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

Date: 22 Jan 1998 17:37:11 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: @ == @, comparing arrays
Message-Id: <6a8hmn$ikc@panix.com>

In <34C792B6.21A7@wco.com> Steven Smith <steves@wco.com> writes:

>I had assumed that @a1 == @a2 would compare two arrays and
>tell me if they were the same.  It doesn't and that makes
>sense to me -- we're taking the arrays into scalar context
>and comparing the number of elements in each group, right?

>Is there an easy way to tell if all elements of the array
>are the same short of a short subroutine?

Amazing. Less than one week ago there was a thread with a subject 
called "elegant way to compare two arrays" --
  
  Subject:      Re: elegant way to compare two arrays
  From:         mick@picus.dcs.bbk.ac.uk (Mick Farmer)
  Date:         1998/01/14
  Message-ID:   <EMsCB8.LC9@mail2.ccs.bbk.ac.uk>
  Newsgroups:   comp.lang.perl.misc
  [More Headers]
  
  
  Dear Tobi,
  
  If you know that one character (say a period) didn't
  appear in your array elements, you could try something
  like this.
  
  if ( join('.', @arrayone) eq join('.', @arraytwo) ...
  
  Regards,
  
  Mick
  
and
  
  Subject:      Re: elegant way to compare two arrays
  From:         mick@picus.dcs.bbk.ac.uk (Mick Farmer)
  Date:         1998/01/14
  Message-ID:   <EMsCB8.LC9@mail2.ccs.bbk.ac.uk>
  Newsgroups:   comp.lang.perl.misc
  [More Headers]
  
  
  Dear Tobi,
  
  If you know that one character (say a period) didn't
  appear in your array elements, you could try something
  like this.
  
  if ( join('.', @arrayone) eq join('.', @arraytwo) ...
  
  Regards,
  
  Mick

I guess people would rather ask questions and wait for an answer than do
just a little search in Deja News or other search engines...

-- 
Clay Irving <clay@panix.com>                  I think, therefore I am. I think? 
http://www.panix.com/~clay/


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

Date: 22 Jan 1998 17:38:28 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: @ == @, comparing arrays
Message-Id: <6a8hp4$imo@panix.com>

Oops. The second message from last week was:
  
  Subject:      Re: elegant way to compare two arrays
  From:         ced@bcstec.ca.boeing.com (Charles DeRykus)
  Date:         1998/01/14
  Message-ID:   <EMsHyI.5Bx@bcstec.ca.boeing.com>
  Newsgroups:   comp.lang.perl.misc
  [More Headers]
  
  
  In article <34BCD1A9.1D13@swol.de>,
  Tobias Bugala  <TobiasBugala@swol.de> wrote:
   > Hi,
   > 
   > what would be the most elegant way to compare two different arrays?
   > 
   > if (@arrayone == @arraytwo) {..}
   > 
   > doesn't work...
   > 
   > 
   > while (($arrayone[$i] == $arraytwo[$1]) && ($arrayone[$i] != "")) {
   >       i++;
   >       }
   > 
   > would no be to elegant....
   > 
   > do you know a better way?
   > 
  
  
  If the arrays aren't inordinately large, you can use this. 
  This'll work in most cases even if array members are
  numeric. 
  
  
  if ( @arrayone == @arraytwo and "@arrayone" eq "@arraytwo") {
   ....   # arrays are same   
  
  
  HTH,
  --
  Charles DeRykus


-- 
Clay Irving <clay@panix.com>                  I think, therefore I am. I think? 
http://www.panix.com/~clay/


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

Date: Thu, 22 Jan 1998 15:01:14 -0600
From: adam <none@nowhere.net>
Subject: @INC on winNT
Message-Id: <34C7B39A.2FACCA81@nowhere.net>

for some reason when perl is run from the command line it has the
correct paths in @INC, yet when i execute cgi/perl scripts through the
web server @INC is empty. and i can't seem to assign to it. 
	does anyone know what i am talking about?
	any help much appreciated

adam


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

Date: Thu, 22 Jan 1998 17:07:11 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Array Troubles
Message-Id: <34C7C30F.10DE@min.net>

Todd McLaughlin wrote:
> 
> I have an array question.  Here's the bit of code:
> 
> for($i = 0; $person[$i][0] <> ""; $i++)
> {
>         @person[$i]=split(/ /,<datafile>);
> }
> 
> I'm trying to read lines (~50) in from a data file, separate the fields
> (3), and dump it into an 2D array.  Can you explain what's wrong with the
> above code?

1. That "not equals" operator you have is bogus.  Use 'ne' to compare
strings
   and != to compare numbers.
2. The loop will quit the first time it finds a false $person[$i][0]...
which
   will be the first time the test is performed.  Not what you want.
3. To assign to an array like that, you need to treat the variable
holding the
   array ( person[$i] ) like an array reference, which is a scalar:
	@{ $person[$i] } = split;
4. Perhaps better (prettier, to my eye) is to assign a ref to a ref:
	$person[$i] = [ split ];
4. Why not let <datafile> control the loop?  It's more natural.  Who
cares what
   the index value is?

my @person; # initialized to empty.
for ( <datafile> ) {
    push( @person, [ split ] );
}

Or even shorter:

my @person = map { [ split ] } <datafile>;


hth,
John Porter


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

Date: Thu, 22 Jan 1998 17:24:51 -0500
From: John Porter <jdporter@min.net>
Subject: Re: FORTRAN format, help!
Message-Id: <34C7C733.3F6@min.net>

Ying Hu wrote:
> 
> Perlers:
> >
> > How to get FORTRAN format by perl for example:
> >
> > data:
> > string1  12345.67    89    ing2
> > stri     12345.6      9 string2
> >   ring1   45.67      89 string2
> >
> > FORTRAN format:
> > (A7,2X,F8.2,4X,I2,A7)
> 
> My question is how to get "(A7,2X,F8.2,4X,I2,A7)" from the
> data by perl. Sorry!
> 
> Ying

So you're saying "given some data of this form, derive an appropriate
Fortran format string"?

If so, then you just need to use the builtin function called
data_to_fortran_format.

hth,
John Porter


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

Date: Thu, 22 Jan 1998 16:51:10 -0500
From: Mark Buckaway <mark@datasoft.on.ca>
Subject: HELP: Stopping undefine function errors at compile time. Possible?
Message-Id: <34C7BF4E.3D2C4D8F@datasoft.on.ca>

I like C for it's precise nature. I like to prototype my functions. I like to
declare all my variables. I've found doing such things saves time debugging when
one spelling mistake can take hours to find. In perl I always use 'use strict'
in my scripts. I recently discovered function prototypes so I can't do stupid
things like underdefine the number of arguments to pass to a function. What I
would like to know if it's possible somehow to have perl barf on undefined
functions.

For example:

#!/usr/local/bin/perl

sub SubRoutine() {
	print("Test\n");
}

MrSubRoutine();

MrSubRoutine does not exist and perl will not complain until the script is
actually run. This is very annoying when working with CGI's because a perl -cw
passes ok. I would like to be able to have perl barf on MrSubRoutine WHEN I run
something like perl -cw. Possible?

Presently, I am using perl 5.004.

Mark
-- 
-------------------------------------------------------------------------
Mark Buckaway   | mark@datasoft.on.ca   | http://www.datasoft.on.ca/~mark
=========================================================================
Cube farm - an office filled with cubicles.
=========================================================================
Join a list! Email majordomo@datasoft.on.ca for:
jokes    - the Jokes and Funny mailing list
movies   - the movie review and discussion list
bitch    - the Bitch and Complain list (vent frustrations here)
=========================================================================
     21000 recipes online! Check out http://www.recipepages.com
-------------------------------------------------------------------------


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

Date: Thu, 22 Jan 1998 13:52:59 -0800
From: gene@moreinfo.com (Gene Hsu)
Subject: Net::FTP error trapping
Message-Id: <gene-ya02408000R2201981352590001@corp.supernews.com>

How does one go about detecting when the ftp server dies in mid-connection?
I've been using the Net::Cmd methods ok and message to get some information,
but I've noticed that the process just hangs (truss reveals a poll) when
the connection breaks on the server end.

-- Gene


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

Date: 22 Jan 1998 23:03:47 +0100
From: Remove xx to reply <xxTony.Curtis@vcpc.univie.ac.at>
Subject: Re: None
Message-Id: <7xwwfsxj24.fsf@beavis.vcpc.univie.ac.at>

Re: None, Hal <hwigoda@Mcs.Net> said:

Hal> A associate of mine has a cgi form and script and he is
Hal> getting the message "Document has no data".

Hal> The data aceepted by the form was not written to the
Hal> flat file in his home directory.

You might be better off in a CGI newsgroup, this isn't
really a perl problem.

try

  http://www.boutell.com/

hth
tony




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

Date: 22 Jan 1998 21:50:17 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: None
Message-Id: <6a8eup$bbl$2@comdyn.comdyn.com.au>

[Subject: Re: None]

Check the article at 

http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post

on how to select aa good subject for your posts.

In article <199801221958.NAA04438@jupiter.mcs.net>,
	hwigoda@Mcs.Net (Hal Wigoda                     ) writes:
> 
> A associate of mine has a cgi form and script
> and he is getting the message "Document has no data".

This is not a perl problem. This is an error that is caused by
receiving a document without data. It's related to HTTP, and CGI.
Check one of the newsgroups comp.infosystems.www.*, and read the CGI
FAQ at

http://www.perl.com/CPAN/doc/FAQs/cgi/perl-cgi-faq.html

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Very funny Scotty, now beam down my
Commercial Dynamics Pty. Ltd.       | clothes.
NSW, Australia                      | 


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

Date: Thu, 22 Jan 1998 16:54:55 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Odd syntax problem
Message-Id: <34C7C02F.6B98@min.net>

Michael King wrote:
> 
> Try this instead:
> $_ = join('/', splice( [ split("/",$_) ], -1, 1)) if (/=/);

Not quite.  You're passing an array-ref to splice!
Deref the ref using @{} to get the array:

$_ = join('/', splice( @{[ split("/",$_) ]}, -1, 1)) if (/=/);


Of course, TMTOWTDI:

$_ = substr( $_, 0, rindex( $_, '/' ) ) if ( /=/ and /\// );

hth,
John Porter


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

Date: 22 Jan 1998 21:48:34 GMT
From: ehood@medusa.acs.uci.edu (Earl Hood)
Subject: Re: Parsing HTML tag parameters
Message-Id: <6a8eri$9ao@news.service.uci.edu>

In article <34c092cb.93214615@newshost.cc.utexas.edu>,
Ben Glazer <ben.glazer@mail.utexas.edu> wrote:
>I have a problem which seems to me like it should be relatively
>simple, but I've spent more time working on it than I care to admit.
>
>All I want to do is split the parameter list of an HTML tag into an
>array.  So, for example, starting off with input of
>
>	 <img src="pish.gif" alt="hello kitty" width=100>

You may want to look at the SGML::Util module that is part
of perlSGML (http://www.oac.uci.edu/indiv/ehood/perlSGML.html) and
the SGMLparse_attr_spec() function.

	--ewh
-- 
             Earl Hood              | University of California: Irvine
      ehood@medusa.acs.uci.edu      |      Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME


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

Date: Thu, 22 Jan 98 16:07:16 -0500
From: bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Subject: Re: Perl programming with NT4.0: sendmail problem
Message-Id: <34c7b611$2$ofn$mr2ice@speaker>

In <En6r7o.9FM@ig.co.uk>, on 01/22/98 at 12:40 PM,
   Jacqui Caren <Jacqui.Caren@ig.co.uk> said:
+-----
| >>Isn't POP3 just for reading mail?
| >
| >Some versons of POP3 allow the posting of mail as well.
|
| Which commands in the POP3 RFCs cover about mail submission?
| Do you know of any good POP enabled MUAs that use this and
| server side mail folder management?
+--->8

They're non-RFC, but commonly implemented.  The mailer I use supports sending
via POP3 --- but not well, mainly because POP3 doesn't support it well
(lacking an envelope, sendmail -t is the only viable implementation).

You're looking specifically for "XTND XMIT".

-- 
use 5.004;sub AUTOLOAD{print$_{$_.++$x{$_}}}sub new{my%x;%_=map{++$a%2?$_.++$x{
$_}:$_}split(//,pack('N*',unpack('w*',unpack('u*','M@H*HP\'2"@\C`88+SE/!EA(F!'.
"A'6\$LZV0+(3;C9QRA9NAPG2&D\\G(88:KL=A0\n4AN.5W\"\"&\\[W>;H>3S>0\@A\\N\@PB\$`")
)));bless{}}$b=(new main);map{$b->_}split(//,' Brandon S. Allbery KF8NH') # :-)



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

Date: 22 Jan 1998 21:42:44 GMT
From: ehood@medusa.acs.uci.edu (Earl Hood)
Subject: Re: Perl programming with NT4.0: sendmail problem
Message-Id: <6a8egk$94l@news.service.uci.edu>

In article <En6r7o.9FM@ig.co.uk>, Jacqui Caren  <Jacqui.Caren@ig.co.uk> wrote:
>[ newsgroups trimmed ]
>
>Which commands in the POP3 RFCs cover about mail submission?
>Do you know of any good POP enabled MUAs that use this and
>server side mail folder management?

Use IMAP.  Even the rfc for POP3 refers to IMAP if more
complex client/server operation are to be done.  It appears
some vendors are trying to use POP beyond what it was intended
for when IMAP would be the more appropriate protocol.

	--ewh
-- 
             Earl Hood              | University of California: Irvine
      ehood@medusa.acs.uci.edu      |      Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME


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

Date: Thu, 22 Jan 1998 21:43:44 GMT
From: faust@wwa.com (Faust Gertz)
Subject: Re: PERL Rookie Problem
Message-Id: <34c8aca4.4932587@news.wwa.com>

On 22 Jan 1998 18:44:24 GMT, Gellyfish@btinternet.com (Jonathan Stowe)
wrote:

>In article <34C761BB.15E32ABF@nortel.ca>, nemanja@nortel.ca says...
>
>As well as WinZip you may find that you will need a decent "make" and a 
>variety of other utilities to install the module in the "approved" manner.
>you can usually frig it up somehow but often the Makefile.PL technique just
>dont work on win95 (for me anyhow).

Are you using Activestate's (http://www.ActiveState.com/) distribution
of Perl?  I don't think MakeMaker hasn't been ported to their Perl for
Win32.  

I haven't had a chance to play with Perl under an Win32 environment,
but I have learned that Gary Ng had at one time ported perl to be
compiled with Microsoft Visual C++
(http://www.endcontsw.com/pub/perl_win32.zip).  It doesn't look like
he has done much with it for about a year and, of course, I think you
will also need Microsoft Visual C++, which isn't that cheap if you
don't already have it.  Also, I am not sure that it has been tried
under Windoze 95.

If you don't want to shell out all that cash and can get GNU-Win32
(http://www.cygnus.com/misc/gnu-win32) to work, you can try Karl
Martin Syring's port
(http://www.edv.agrar.tu-muenchen.de/~syring/gnu-win32/perl.zip).
Again, this port hasn't been touched for a while (since March of 1997)
and there is no guarantee that it will work under Windoze NT4, let
alone Windoze 95

Gurusamy Sarathy has a binary distribution of Perl for the Win32
platform (/CPAN-local/ports/win32/Standard/x86), compiled using
Borland C++ (version 5.02), built around Perl version 5.004_02.  This
seems to be the most favored and current of the non-ActiveState binary
distributions.  

As far as it's "make" capabilities, I'll quote from the readme.

> This bundle contains almost everything you will need for using Perl
> on Win32 platforms.  It also contains everything needed to build,
> test and install additional perl modules from CPAN that you may not
> find in here, provided they use the standard MakeMaker extension
> build tools.  Since MakeMaker needs a `make' utility, a Win32 binary
> of Dennis Vadura's `dmake' tool is supplied (see below for more on
> `dmake').  For using this distribution to build extensions that need
> a C compiler, you will also need either Borland C++ 5.02, or Visual
> C++ (version 2.0 and later).

A note for those using Microsoft's Visual C++.

> If you don't have the Borland compiler, it is also possible to build
> and use extension binaries compiled with Visual C++.  The converse--
> using a perl binary built under Visual C++ with extension binaries
> built under Borland C++--does not work due to a bug in the Visual
> C++ linker (present as of version 5.0).

Also, for those who are compilerless but still wish to, apparently
Perl 5.004_56 _can_ be built under Win32 with freeware Minimalist
Gnuwin32 (mingw32)
tools
(http://agnes.dida.physik.uni-essen.de/~janjaap/mingw32/download.html).
At least according to some messages I read in perl.porters-gw.  See

Subject:      Building 5.004_56 under win32 with mingw32
From:         Gurusamy Sarathy <gsar@engin.umich.edu>
Date:         1997/12/19
Message-ID:   <199712192346.SAA14411@aatma.engin.umich.edu>
Sender:       owner-perl5-porters@perl.org
To:           perl5-porters@perl.org
Newsgroups:   perl.porters-gw
X-Loop:       Perl5-Porters

and related articles for more details.  


HTH

Faust Gertz
Philosopher at Large


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

Date: Thu, 22 Jan 1998 17:10:17 -0500
From: Paul Humler <me@my.com>
Subject: Perl5.003 problems with libgdbm.so.1
Message-Id: <34C7C3C9.CA0A5F83@my.com>

I have just installed Perl 5.003 ELF on a Linux system.  It complained
about missing libgdbm.so.1 (previous version of perl apparently didn't
require this lib.)  I downloaded and installed the libgdbm.so.1.7.3 lib
and now get a different message about _h_error_ being undefined.  Has
anyone else seen this problem?

Does anyone know what version of Linux is required to run Perl5.003 (I
am using 1.2)?

Thanx in advance.
-Paul




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

Date: 22 Jan 1998 22:36:42 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
To: shailkumar@aol.com (SHAILKUMAR)
Subject: Re: Please help me!!
Message-Id: <6a8hlq$beg$1@comdyn.comdyn.com.au>

[Posted and Mailed]

In article <19980122043601.XAA01698@ladder01.news.aol.com>,
	shailkumar@aol.com (SHAILKUMAR) writes:

[snip]

I just saw this same (almost identical) post from you in
comp.lang.perl.modules. For future reference: You can crosspost one
article to multiple groups at the same time, which means that any
followups to it will appear in those same groups as well. Now you will
have to jump back and forth between the two groups to get your
answers. And, we have to read the same message twice, not knowing if
it has already been answered, thus wasting our valuable time typing
something, only to find out that the same answer was given by someone
else on a different group.

	thanks for future considerations,
	Martien

-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Advertising:  The science of arresting
Commercial Dynamics Pty. Ltd.       | the human intelligence long enough to
NSW, Australia                      | get money from it.


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

Date: 22 Jan 1998 11:59:22 -0800
From: lbowen@vic.com
Subject: possible reasons for broken pipe?
Message-Id: <6a88eq$al7@sdrn.zippo.com>

I am running a perl script to check for broken links on a web page and print it
to a text file.  It works fine, albeit slowly, and runs through an array of
URI's (@URLs), however the program usually stops running after the 10th loop
(this varies somewhat) and I get a message from my Unix server of "broken pipe".
Is this caused by the fact that the program runs very slowly, or is there
something in my code?

I have a second question about the regexp:  I can't really understand the logic
behind using the range [\w-\.]?  It seems as if just .* would serve the same
purpose--to match either www.aquafan.com, for example, or 209.50.230.65, for
example.  However, I tried .* and it does not match anything.

foreach $URL (@URLs)   {
       if ($URL =~ m#^http://([\w-\.]+):?(\d*)($|/(.*))#) 
            {$host = $1; $port = $2; $path = $3;}
       if ($path eq "") { $path = '/'; }
       if ($port eq "") { $port = 80; }
       $path =~ s/#.*//;
       $AF_INET = 2;
       $SOCK_STREAM = 1;
       $sockaddr = 'S n a4 x8';
       $hostname=$host;
       ($name,$aliases,$proto) = getprotobyname('tcp');
($name,$aliases,$port) = getservbyname($port,'tcp') unless $port =~ /^\d+$/;
       ($name,$aliases,$type,$len,$thisaddr) = gethostbyname($hostname);
        if (!(($name,$aliases,$type,$len,$thataddr) = gethostbyname($host)))
                              { &ConnectCodes('0'); } 
       $this = pack($sockaddr, $AF_INET, 0, $thisaddr);
       $that = pack($sockaddr, $AF_INET, $port, $thataddr);
       if (!(socket(S, $AF_INET, $SOCK_STREAM, $proto))) 
                               {$SOCK_STREAM = 2;
if (!(socket(S, $AF_INET, $SOCK_STREAM, $proto)))
                                   { &ConnectCodes('1')}
                         }
      if (!(connect(S, $that))) { &ConnectCodes('3') }
      select(S); $| = 1; 
      select(STDOUT);
      print S "HEAD $path HTTP/1.0\n\n";
      $response = <S>;
      ($protocol, $status) = split(/ /, $response);close(S);
      &StatusCodes("$URL");
          }
######################################################################
###   PURPOSE: WRITE THE STATUS CODES RETURNED                     ###
######################################################################
sub StatusCodes {if ($status eq ''){$status='Could Not Connect';}
open (TEXT, '>>linkcheck.txt') || die "Can't open linkcheck.txt!\n";
print TEXT "$URL\t\t$protocol\t\t$status\t\t$StatusCode{$status}\n\n";
close(TEXT);}
######################################################################
###   PURPOSE: HANDLE CONNECT ERROR CODES                          ###
######################################################################
sub ConnectCodes {$status=$ErrorCodes{shift @_}; }
######################################################################
###   PURPOSE: DEFINE STATUS CODE ARRAY                            ###
######################################################################
sub Initialize {%StatusCode=( "200", "OK",
		  "201", "A New Resource Has Been Created",		  "202", "Request Accepted",
		  "203", "Partial Information",		  "204", "No New Content",
		  "300", "Multiple Choices, Prefered Location Not Determined",
		  "301", "Found, But Moved",
		  "302", "Found, But Data Resides Under a Different URL",
		  "303", "Incorrect Method, Try Get",		  "304", "Not Modified",
		  "400", "Bad Request",		  "401", "Unauthorized",
		  "402", "Payment Required",		  "403", "Forbidden",		  "404", "Not Found",
		  "405", "Method Not Allowed",		  "406", "None Acceptable",
		  "407", "Proxy Authentication Required",		  "408", "Request Timeout",
		  "409", "Resource Conflict",		  "410", "Gone",
		  "411", "Authorization Refused",		  "500", "Internal Error",
		  "501", "Not Implemented",		  "502", "Service Temporarily Overloaded",
		  "503", "Service Unavailable",		  "504", "Gateway Timeout",
		  "600", "Bad Request",		  "601", "Not Implemented",
		  "602", "Connection Failed",		  "603", "Timed Out");
%ErrorCodes=("0", "Could Not Look Up Server",		 "1", "Could Not Open Socket", 
		 "2", "Could Not Bind Socket",		 "3", "Could Not Connect");
} 


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

Date: Thu, 22 Jan 1998 16:25:01 -0600
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
Subject: Re: Problem running perl script
Message-Id: <34C7C73D.FDE3D13D@houston.Geco-Prakla.slb.com>

ryoung wrote:
> 
> Hello,
> 
> I'm having the strange problem of my scripts not  being executed when
> they're being called, but rather displayed.  That is, the contents of the
> .pl file are displayed in the browser
Sounds rather normal, to me.

> rather than being executed through the
> perl interpreter.  Has anyone seen this and know what causes this?
> 
Sure.  How are you getting to the script?  Are you pointing your browser
to it?

If the answer is yes, you're doing it wrong.  The browser displays text
(a.k.a. HTML, etc.).  Since it doesn't know anything about Perl (or C or
C++ or ...), it sees what appears to be a plain text file, and displays
it as such.

You need to look into running www server software, and using SSI (Server
Side Includes).

HTH.

Dave
> Thanks,
> 
> Richard

-- 
"Security through obscurity is no security at all."
		-comp.lang.perl.misc newsgroup posting

------------------------------------------------------------------------
* Dave Barnett               U.S.: barnett@houston.Geco-Prakla.slb.com *
* DAPD Software Support Eng  U.K.: barnett@gatwick.Geco-Prakla.slb.com *
------------------------------------------------------------------------


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

Date: Thu, 22 Jan 1998 16:40:27 -0500
From: Jason Moore <junk@sober.com>
Subject: Q: How to view NT groups? (Win32::NetAdmin)
Message-Id: <34C7BCCB.2EFFFF38@sober.com>

hi,

I've been looking at Win32::NetAdmin and Win32::AdminMisc but I have not
found a way to list NT groups.  You can check if a user is in a group
(and you can indirectly test the existence of a group by creating it and
if it fails then the group exists) but no way to list all groups.

Anyone know a workaround?

:jason








-- 
 ....................................................................
jason moore                                             416.595.5232   
Internet Applications Developer                   Inform Interactive
jmoore@informinteractive.com        http://www.informinteractive.com


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

Date: Thu, 22 Jan 1998 16:40:41 -0500
From: Jason Moore <junk@sober.com>
Subject: Q: How to view NT groups? (Win32::NetAdmin)
Message-Id: <34C7BCD9.19799449@sober.com>

hi,

I've been looking at Win32::NetAdmin and Win32::AdminMisc but I have not
found a way to list NT groups.  You can check if a user is in a group
(and you can indirectly test the existence of a group by creating it and
if it fails then the group exists) but no way to list all groups.

Anyone know a workaround?

:jason


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

Date: Thu, 22 Jan 1998 16:45:38 -0500
From: Jason Moore <junk@sober.com>
To: cbo@informatik.tu-chemnitz.de
Subject: Re: re-route the standard-out from NT into Perl?
Message-Id: <34C7BE02.5C70F150@sober.com>

Christian Bobber wrote:
> 
> I would call an  .EXE-program (NT) from my perl-script and analyse it
> later in this calling perl-script.
> 
> Now I use the system()-call and re-route the .EXE-output with the '>'
> into a file. Then I open, analyse, close and delete this file.
> 
> Is there a better way to analyse the output from a called EXE-program?
> 

my favorite is:

open(EXE, "c:/foo.exe |");
@lines_from_foo = <EXE>;

if your exe dumps output to STDERR you can redirect it to STDOUT with:

c:/foo.exe 2>&1

its unix-y but amazingly enough works on nt.

:jason


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

Date: Thu, 22 Jan 1998 16:29:33 -0500
From: John Porter <jdporter@min.net>
Subject: Re: Reg Expression, can it be improved?
Message-Id: <34C7BA3D.53FC@min.net>

#!/usr/bin/perl -w

for (
  'This is  a TEST  "Sammy 1st Birthday" and "SUZZY"  ABCdef019Ab',
  '"From" Just Another "New York" Perl Hacker ("N""Y.P""M" -- jaNYph)'
) {
  my @a = split /"/;
  $_ = join '"', map { $_ % 2 ? lc($a[$_]) : $a[$_] } 0..$#a;
  print;
}


John Porter


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

Date: Thu, 22 Jan 1998 13:08:14 -0600
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Reverse of ReadParse
Message-Id: <34C7991E.430602CA@gpu.srv.ualberta.ca>

J T wrote:
!
!        Gosh this is embarassing (diminishing regexp skills)...I
! am simply trying to do the reverse of the hex-encoding in
! cgi-lib.pl's ReadParse.  For example:
! 
!         Have    "abc!123 +"
! 
!         Then I should get back:
! 
!         abc%21123%20@2b
[snip]

! _know_ this can be done in an one-liner...my failed attempt:
! 
!         $foo = "abc!123 +";
!         $foo =~ s/[^a-zA-Z0-9]/'%'.unpack("H2",$1)/ge;
!         ...I know it's                         ^^ this part
! that's not working because I get back:
!         
!         "abc%123%%"...
! 
!         ...but what am I doing wrong!?

well, you'll have actually put in capturing parentheses
in the regex if you want to use $1 and friends in the
replacement part :-)
$foo =~ s/([^a-zA-Z0-9])/'%'.unpack("H2",$1)/ge;

had you used -w you'd have gotten an 'uninitialized' warning
which might have helped ... hmmm we know $foo is initialized,
the only other variable is $1... doh!

regards
andrew


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

Date: Thu, 22 Jan 1998 16:24:11 -0500
From: Kevin Scott <scottj@mthcsc.wfu.edu>
Subject: Re: Reverse of ReadParse
Message-Id: <34C7B8FB.E1B5AF4A@mthcsc.wfu.edu>

J T wrote:

--snip--

>         $foo = "abc!123 +";
>         $foo =~ s/[^a-zA-Z0-9]/'%'.unpack("H2",$1)/ge;
>         ...I know it's                         ^^ this part
> that's not working because I get back:
> 
>         "abc%123%%"...
> 
>         ...but what am I doing wrong!?

--snip--

Try using

	$foo =~ s/([^a-zA-Z0-9])/'%'.unpack("H2",$1)/ge;

$1 is bound to the string matching the first PARENTHESIZED
subexpression.

Good luck.
Kevin.

******  Kevin Scott
********  Department of Mathematics & Computer Science
********  Wake Forest University
*******  scottj@mthcsc.wfu.edu


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

Date: Thu, 22 Jan 1998 16:38:58 -0500
From: John Porter <jdporter@min.net>
Subject: Re: space searching?
Message-Id: <34C7BC72.5BE8@min.net>

Steven M. O'Neill wrote:
> 
> Eli the Bearded  <*@qz.to> wrote:
> >Correct. <sarcasm> Who would ever have an email address with numbers in
> >it or periods or hypens and pluses or even something as absurd as
> >"*@qz.to"? </sarcasm>
> 
> * (how does one address you anyway?):
> 
> Please be aware thah using html tags in usenet posts is poor form if not
> out and out poor taste.  And besides, the <sarcasm> tag isn't even
> supported by lynx.
> 
> :s
> --
> and you spelled "hyphens" wrong
> --
> steveo@panix.com

Hey, I think you forgot your <facetious>,</facetious> tags.

John Porter


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

Date: 22 Jan 1998 21:24:31 GMT
From: ehood@medusa.acs.uci.edu (Earl Hood)
Subject: Re: Trouble with a regex
Message-Id: <6a8def$8n8@news.service.uci.edu>

In article <6a5h0h$t6k@newsops.execpc.com>,
Mike Hammernik  <mhammer@execpc.com> wrote:
>I have a list of ip addresses that I'm trying to pull out the ones that
>contain a particular range in the last digits.  A list of
>192.168.120.101
>192.168.116.94
>192.168.133.10
>192.168.121.30
>etc
>
>I would like to obtain only the group of ip address that in the last
>field contain numbers from 01 to 30.

Try:

    if ($ip =~ /\.(\d+)$/ and ($1 >= 1) and ($1 <= 30)) {
	...
    }

	--ewh
-- 
             Earl Hood              | University of California: Irvine
      ehood@medusa.acs.uci.edu      |      Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME


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

Date: Thu, 22 Jan 1998 13:01:17 -0500
From: "Eddy Viscous" <ev@kzed.com>
Subject: Unkown Error
Message-Id: <6a81hl$lga@news-central.tiac.net>

Hi,
Can someone help with an error message I am getting.
[22/Jan/1998:12:46:45] catastrophe: for host 152.163.232.25 trying to POST
/employer_db/job_post.cgi, send-cgi reports: could not import pipes into
security lib (No such file or directory)

Any help would be greatly appreciated.

EV




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

Date: Thu, 22 Jan 1998 15:03:05 -0600
From: "Scott Norris" <snorris@post.cis.smu.edu>
Subject: Wierd error messages??!!
Message-Id: <6a8c28$qnb$1@hermes.seas.smu.edu>

I get some wierd errors on the following script.

-string found where operator expected, line 11
-literal @6 now requires backslash, line 11
-Unrecognized character \310 ignored, line 11
-syntax error at line 16, near "}"

I don't understand any of this. Help!!


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

#  delete.pl
#  deletes the textbook with ID as entered by the user
#  form submits the ID with name "IDno"

&getdata

open LIST, "+>>/textbook/booklist.csv";
while (<LIST>) {
  if /$form{IDno}/ {
    s/<LIST>// or die "Can't delete record";
    $success = 1;
    last;
  }
}





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

Date: Thu, 22 Jan 1998 16:39:04 -0600
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: Wierd error messages??!!
Message-Id: <34C7CA88.1DD147D4@gpu.srv.ualberta.ca>

Scott Norris wrote:
> 
> I get some wierd errors on the following script.
> 
> -string found where operator expected, line 11
> -literal @6 now requires backslash, line 11
> -Unrecognized character \310 ignored, line 11
> -syntax error at line 16, near "}"
> 
> I don't understand any of this. Help!!
> 
> ----------------------------------------------------------------------
> #!/usr/bin/perl
> 
> #  delete.pl
> #  deletes the textbook with ID as entered by the user
> #  form submits the ID with name "IDno"
> 
> &getdata
> 
> open LIST, "+>>/textbook/booklist.csv";
> while (<LIST>) {
>   if /$form{IDno}/ {
>     s/<LIST>// or die "Can't delete record";
>     $success = 1;
>     last;
>   }
> }

hmm, when I run it under -cw the first warning/error I get
is:
syntax error at xxx line 9, near "open "

followed by more ... aside from not checking the return value
of your open() function there is no syntax error near open on
line 9, but looking up one statement we see there is no final
semi-colon   fix that, run again under -cw:

first error is:
syntax error at xxx line 11, near "if /$form{IDno}/"

hmm, no parentheses on the conditional, fix it to be
if (/$form{IDno}/) {

run again under -cw and we are left with two warnings:
Name "main::form" used only once: possible typo at xxx line 11.
Name "main::success" used only once: possible typo at xxx line 13.
xxx syntax OK
maybe you want to declare those?

morals...always use -w ... always fix problems one at a time
from the first problem ... always use -w ... if the error
says the problem is on line xx but you see no error there, look
again, then look up a line for missing semi-colons or unbalanced
quotes/brackets/parentheses etc (repeat as necessary)
 ... always use -w

I don't think I want to know what the &getdata routine does :-)
but maybe you want to use CGI.pm

also, what is it that you think the while loop
is actually going to do?

"Learning Perl" by Randal Schwartz and Tom Christiansen
is a good book.

hope it helps
regards
andrew


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

Date: 22 Jan 1998 16:01:55 -0500
From: charlot@CAM.ORG (Richard Bellavance)
Subject: Re: win32:ftp
Message-Id: <6a8c43$q26@ocean.CAM.ORG>

In article <34c7ae51.5769475@nntp.netcomplete>,
Michael Hartley <michael@hartleym.force9.co.uk> wrote:
>Hi,
>
>does anyone know if there are any win32:ftp modules freely available?
>I just need the ability to ftp to a unix server and get a single file,
>then shutdown.
>
>Help very much appreciated.
>

Well, there's no Win32-specific FTP module, but there is Net::FTP.  Look
for it on the CPAN (http://www.perl.com/CPAN).

Richard.
-- 
Richard Bellavance -- charlot@cam.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: 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 1706
**************************************

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