[6263] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 885 Volume: 7

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Feb 2 23:17:21 1997

Date: Sun, 2 Feb 97 20:00:21 -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           Sun, 2 Feb 1997     Volume: 7 Number: 885

Today's topics:
     Re: AIX, perl5, dynamic loading probs (Jens-Uwe Mager)
     Re: Color coding perl (Brian L. Matthews)
     Re: Creation time and date of file (Petr Prikryl)
     Getting Input <stevej@wco.com>
     Re: Getting Input (Nathan V. Patwardhan)
     Re: Grabbing Html via perl from the web <tchrist@mox.perl.com>
     Re: How to use perl <ezarrabi@direct.ca>
     Inverse Letters <stevej@wco.com>
     Re: Inverse Letters (Nathan V. Patwardhan)
     Re: Inverse Letters (Nathan V. Patwardhan)
     Is the system command supported in Windows? (Olson Collin K)
     Re: Is the system command supported in Windows? (Nathan V. Patwardhan)
     Re: mod_perl (was perl-mod) on apache giving errors <robh@imdb.com>
     Re: msgsnd() and pack() -- message type <rootbeer@teleport.com>
     Re: msgsnd() and pack() -- message type (Billy Chambless)
     Patch to add threads to Perl5.003 (Eric Arnold Anderson)
     Re: pattern matching of sorts <tchrist@mox.perl.com>
     Re: Perl 5.003 and BSD 2.1 (libwww-perl-5.0x) (Gary Liefer)
     Q: gethostbyaddr in Perl 5.003 buggy ??? <elkner@irb.cs.uni-magdeburg.de>
     Re: Q: gethostbyaddr in Perl 5.003 buggy ??? <rootbeer@teleport.com>
     Re: Question <rootbeer@teleport.com>
     Re: Reading comma delimited file? (Efigenio Ataide)
     Re: Reading numbers from file.. <rootbeer@teleport.com>
     Re: regular expressions <mgjv@comdyn.com.au>
     Re: subprocess help <rootbeer@teleport.com>
     Re: URL Encoding <aas@bergen.sn.no>
     Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)

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

Date: Sun, 2 Feb 1997 23:15:14 GMT
From: jum@anubis.han.de (Jens-Uwe Mager)
Subject: Re: AIX, perl5, dynamic loading probs
Message-Id: <jum-ya02408000R0302970015140001@baghira.han.de>

In article <wihohe4rgk5.fsf@panix.com>, rocky@panix.com (R. Bernstein) wrote:

> 1. Fix up dl_aix.xs. I guess there'd have to be a separate file for
>    AIX 3 and one for AIX 4.

No there is no need for a seperate one. The dl_aix.xs included with perl is
a very old one where I made a mistake regarding how symbols are zero
terminated or not, the problem only surfaced with the linker in AIX 4.
Using the newer dlfcn emulation routines from the file
<ftp://anubis.han.de/pub/aix/dlfcn.shar> should let perl work under either
AIX 3 or 4.
_______________________________________________________________________
Jens-Uwe Mager                  jum@anubis.han.de
30177 Hannover                  jum@helios.de
Brahmsstr. 3                    Tel.: +49 511 660238


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

Date: 2 Feb 1997 23:11:24 GMT
From: blm@chinook.halcyon.com (Brian L. Matthews)
Subject: Re: Color coding perl
Message-Id: <5d36us$d67$1@brokaw.wa.com>

In article <erich-0202970901450001@ppp-207-104-16-33.snrf01.pacbell.net>,
Eric Harley <erich@powerwareintl.com> wrote:
|BBEdit from BareBones Software (www.barebones.com)is a a great editor the
|automaticly colors text for 20+ languages.

While I like BBEdit, it's perl coloring needs some work. Right off
hand, it doesn't recognize perl5 syntax, doesn't treat here docs
as strings, and gets confused about paren counting. While there are
lots of reasons to recommend BBEdit, if you absolutely gotta have
perl coloring, I wouldn't recommend it. It's coloring can be
misleading, which is worse than just coloring everything black. :-)

Brian
--
Brian L. Matthews				Illustration Works, Inc.
	For top quality, stock commercial illustration, visit:
		  http://www.halcyon.com/artstock


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

Date: 2 Feb 1997 17:12:57 GMT
From: prikryl@dcse.fee.vutbr.cz (Petr Prikryl)
Subject: Re: Creation time and date of file
Message-Id: <5d2hup$6lh@boco.fee.vutbr.cz>

Petr Prikryl (prikryl@dcse.fee.vutbr.cz) wrote:
>Parmeshta Jain (jain@bcstec.ca.boeing.com) wrote:
>>I need to be able to print out the creation time and date of a file in
>>the following format.  Can someone help me with this?
>>The format is: 24 JAN 1997 AT 00:02:10 AM

>I would recommend stat() and localtime() functions. The stat() function
>takes the name of the file and returns also time of the creation; however,
>usage of "time of modification" is more useful, in my opinion (also
>returned by stat()). The time is in seconds from 1 Jan 1970. You can
>pass this to localtime() to convert it to year, day, month, hour, minute, 
>sec... (basicaly the numbers). Then it is quite easy to convert the 
>numbers into strings like JAN, etc.

Oops! Tad McClellan is right in this thread. There is nothing like
creation time. The ctime is "inode change time". My fault.
Nevertheless, Parmeshta Jain definitely wants "modification time" ;-)

Petr

--
Petr Prikryl (prikryl@dcse.fee.vutbr.cz)   http://www.fee.vutbr.cz/~prikryl/
TU of Brno, Dept. of Computer Sci. & Engineering;     tel. +42-(0)5-7275 218


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

Date: 3 Feb 1997 01:53:41 GMT
From: Steve Johnson <stevej@wco.com>
Subject: Getting Input
Message-Id: <5d3gf5$tg@news.wco.com>



Ok The way I understand it is this

to get a line of input from standard in you do this

$input=<STDIN>;

Simple enough.   But i dont want a whole line of input I only want 1 chr.
 kinda like the old basic rout get a$  is there a way JUST to get 1 key
stroke with perl?

Oh another thing I want to do is be able to home the curser to the top of
the screen  with out clearing the screen.. is there an easy way to do
this.. Basicly Im writing a menu program that uses curser keys to move up
and down a highlighted bar on the menu.  Any help would be apreciated.




-Steve



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

Date: 3 Feb 1997 03:06:42 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Getting Input
Message-Id: <5d3ko2$pd5@fridge-nf0.shore.net>

Steve Johnson (stevej@wco.com) wrote:

: Oh another thing I want to do is be able to home the curser to the top of
: the screen  with out clearing the screen.. is there an easy way to do
: this.. Basicly Im writing a menu program that uses curser keys to move up
: and down a highlighted bar on the menu.  Any help would be apreciated.

oooo.  Sounds like you're entering the wonderful realm of curses, and
are looking for the menu.pl package.  Clearing the screen is system-specific.
You might want to pursue Curses.pm available at a CPAN near you (if you're
using a Unix)!

--
N Patwardhan
nvp@shore.net
[news:alt.fan.jwz]


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

Date: 3 Feb 1997 00:12:12 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Grabbing Html via perl from the web
Message-Id: <5d3ags$rvl$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    Theo Van Dinter <felicity@eclectic.kluge.net> writes:
:-----BEGIN PGP SIGNED MESSAGE-----
:
:Nathan V. Patwardhan <nvp@shore.net> wrote:
:> : Yeah simple right? Just wondering before I reinvent the wheel,  has
:> : someone- somewhere done this before.  If not *any* suggestions on how to
:> : do this?
:
:I wrote a program called GetURL (see http://www.kluge.net/NES/) to do this
:for me.
:
: ---------------------------------------------------------------------------
: Theo Van Dinter			www: http://www.kluge.net/~felicity/
: (Vice)President WPI Lens and Lights	      Active Member in SocComm Films
: Member of WPI ACM			      AME for the Masque C-Term Show
:
:             Everywhere is walking distance if you have the time.
: ---------------------------------------------------------------------------
:
:-----BEGIN PGP SIGNATURE-----
:Version: 2.6.2
:
:iQB1AwUBMvEG/m46V+hEhqEhAQFTSQL/YPPkRc6/S5xGUpxtfnq8RwoBOKMAZ2hp
:U4e/kQvMoqhz/cyPwHzWPb/JO/y5rQ3ntAT2D7woST2Gxk9e86nxuhVAbO2ihg6J
:qyBgTNRTCnNRtS2H2Gh2coxpViWJOBM8
:=8/GP
:-----END PGP SIGNATURE-----

I've overquoted this to make a point: you have posted 
25 lines of body, and only 2 lines of content.  That's
ridiculous.  Please consider changing your posting style. 
PGP is nice for some thing, but stoopid here.  

--tom
-- 
Tom Christiansen      Perl Consultant, Gamer, Hiker      tchrist@mox.perl.com


Fine, let them give me the endless crap.   --Andrew Hume


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

Date: Sun, 02 Feb 1997 18:02:07 -0800
From: ehsan zarrabi <ezarrabi@direct.ca>
Subject: Re: How to use perl
Message-Id: <32F5471F.407D@direct.ca>

Nathan V. Patwardhan wrote:
> 
> ehsan zarrabi (ezarrabi@direct.ca) wrote:
> : How do I use a perl script? I have downloaded a perl script but I don't
> : know how to use it, I mean how to call it. Do I have to add a line in my
> : web page so it goes and runs the perl script or what?
> 
> (1) What platform are you using (A Unix, Mac, PC)?
> (2) What's the script supposed to do?
> (3) What are you trying to do / what have you done?
> (4) Talk to your sysadmin about executing CGI scripts.
> 
> With the vagueness of your posting, it's really difficult to give you
> any advice.
> 
> --
> N Patwardhan
> nvp@shore.net
> "Lane, this is pure snow!
> Do you have any idea what
> the street value of this mountain is?"
>         --Charles Demar from _Better Off Dead_
Thanks for answering.
1) It is a PC
2) The script is supposed to show different banner ads everytime you go
to the page.
3) There is a folder called CGI-BIN on the server

Thanks


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

Date: 3 Feb 1997 01:29:33 GMT
From: Steve Johnson <stevej@wco.com>
Subject: Inverse Letters
Message-Id: <5d3f1t$el@news.wco.com>



How do I print inverse letters in a print statement?



-Steve



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

Date: 3 Feb 1997 03:03:59 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Inverse Letters
Message-Id: <5d3kiv$pd5@fridge-nf0.shore.net>

Steve Johnson (stevej@wco.com) wrote:
: How do I print inverse letters in a print statement?

If you mean print drow instead of word, try: reverse()

--
N Patwardhan
nvp@shore.net
[news:alt.fan.jwz]


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

Date: 3 Feb 1997 03:08:37 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Inverse Letters
Message-Id: <5d3krl$pd5@fridge-nf0.shore.net>

Nathan V. Patwardhan (nvp@shore.net) wrote:
: Steve Johnson (stevej@wco.com) wrote:
: : How do I print inverse letters in a print statement?

: If you mean print drow instead of word, try: reverse()

Forgot to mention it (after reading your other posting), but if you
mean making the letters appear "highlighted," you might want the Curses
package available at a CPAN near you!

--
N Patwardhan
nvp@shore.net
[news:alt.fan.jwz]


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

Date: 2 Feb 97 23:24:30 GMT
From: olsonco@ucsu.Colorado.EDU (Olson Collin K)
Subject: Is the system command supported in Windows?
Message-Id: <olsonco.854925870@ucsu.Colorado.EDU>
Keywords: system Windows

None of my Perl references mention that the system or exec command are unsupported in Windows; however, I cannot seem to make them work.   
-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Collin Olson                                        (303) 492-4784
University of Colorado                   collin.olson@colorado.edu
Department of Economics          http://ucsu.colorado.edu/~olsonco


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

Date: 3 Feb 1997 02:24:27 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Is the system command supported in Windows?
Message-Id: <5d3i8r$lr2@fridge-nf0.shore.net>

Olson Collin K (olsonco@ucsu.Colorado.EDU) wrote:
: None of my Perl references mention that the system or exec command are unsupported in Windows; however, I cannot seem to make them work.   
: -- 

The system() command is supported in NTPerl.  I'm not sure about exec.

--
N Patwardhan
nvp@shore.net
[news:alt.fan.jwz]


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

Date: Sun, 02 Feb 1997 23:20:18 +0000
From: Rob Hartill <robh@imdb.com>
Subject: Re: mod_perl (was perl-mod) on apache giving errors
Message-Id: <32F52132.41C67EA6@imdb.com>

Matthew Ahrens wrote:
> 
> I am using perl-mod on Apache v1.2b4, with perl 5.003.

You should first grab the latest versions of both Apache (1.2b6)
and mod_perl (0.93)

> It seems that
> whenever my perl script that runs through perl-mod exits, (the script seems
> to work fine) it logs this message to the error-log:
> 
> [Fri Jan 31 23:53:41 1997] httpd: caught SIGSEGV, dumping core
> 
> Note: SIGSEGV means 'segment violation', whatever that means

calling "exit" will cause trouble. You need to call mod_perl's version
of exit. If "$r" is your reference to the Apache request, then this
should
work:

	$r->connection->close;
	$r->exit;

You should probably take another look at why you need to call exit in
the first place. There are some cases where it is needed but more often
than not there's more to be gained from keeping the process alive to
serve more requests.

> however, I can not find a core dump. I made sure that I am closing the
> connection properly with '$c->close;'. I also tried closing the connection
> with '$c->close; exit;' but that did not seem to make a difference.
> 
> Please let me know (cc: my email) if you have any idea what is going wrong

You should probably join the mod_perl mailing list. Doug MacEachern
is usually quick to help people out and point them in the right
direction.

>From the README:

  For comments, questions, bug-reports, announcements, etc., send mail
  to majordomo@listproc.itribe.net with the string "subscribe modperl"
  in the body.  (Thanks to Mark A. Imbriaco <mark@itribe.net>)

  Thanks to James Cooper <pixel@tiger.coe.missouri.edu>,
  there is a hypermail archive for this list at:
 
  http://www.coe.missouri.edu/~faq/lists/modperl/

  Patrick Kane <modus@enews.com> maintains the mod_perl FAQ available
at:
  http://chaos.dc.enews.com/mod_perl/


_______________________________________________________________________
Rob Hartill.       Internet Movie Database Ltd.    http://www.imdb.com/
CGI ? how quaint.


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

Date: Sun, 2 Feb 1997 19:11:57 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Billy Chambless <billy@cast.msstate.edu>
Subject: Re: msgsnd() and pack() -- message type
Message-Id: <Pine.GSO.3.95.970202190828.11608H-100000@linda.teleport.com>

On 2 Feb 1997, Billy Chambless wrote:

> #!/usr/local/bin/perl

Why aren't you using -w if you're having troubles?

> $queue = msgget(1234, IPC_CREAT | 0666);

Did you forget to set IPC_CREAT to some useful value?

> $msg = join(@rest);

Surely you mean join("", @rest), or maybe join(" ", @rest), don't you?

Hope this helps!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: 3 Feb 1997 03:49:02 GMT
From: billy@cast.msstate.edu (Billy Chambless)
To: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: msgsnd() and pack() -- message type
Message-Id: <5d3n7e$5gr@NNTP.MsState.Edu>

In article <Pine.GSO.3.95.970202190828.11608H-100000@linda.teleport.com>, Tom Phoenix <rootbeer@teleport.com> writes:
|> On 2 Feb 1997, Billy Chambless wrote:
 
|> > #!/usr/local/bin/perl
 
|> Why aren't you using -w if you're having troubles?

Because, uh....well, that is...

|> > $queue = msgget(1234, IPC_CREAT | 0666);
 
|> Did you forget to set IPC_CREAT to some useful value?

*bonks self on head*

Doh!

Uh-huh, that's the problem.

*deep sigh*

Problem solved, life goes on.

Thanks, Tom.


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

Date: 3 Feb 1997 02:33:26 GMT
From: eanders@u98.CS.Berkeley.EDU (Eric Arnold Anderson)
Subject: Patch to add threads to Perl5.003
Message-Id: <5d3ipm$cpn$1@nadine.teleport.com>
Keywords: Perl, Threads

I've created a patch that adds threads to Perl5.003; since this
requires that the interpreter and any extensions are recompiled, and
since it hasn't been extensively tested, I haven't submitted it yet to
CPAN, and am just making it available from a web page.  The web page
is: <http://www.cs.berkeley.edu/~eanders/thrperl/>; since we've been
having some trouble with file servers, you may also try the reference
<http://now.cs.berkeley.edu/~eanders/thrperl/>.  The release notes
from the patch are included below.
	-Eric

Release Notes: This patch file adds threading to perl5.003; it creates
threading V0.2 Two modifications need to be made to config.sh files
from the ones used to build the normal version of perl. 1)
-DWITH_THREADING needs to be added to the ccflags= line in config.sh;
2) Thread needs to be added to the dynamic_ext and extensions liens in
config.sh. ***IMPORTANT*** Threading turns on the multiplicity option
in the interpreter.  This means that threaded perl is incompatible
with any extensions you may have already compiled (they have to be
recompiled) Furthermore, threading produces some slight performance
hit when threading is turned off, and a more substantial (but as yet
unquantified) performance hit when you use threads.  The reasons are
documented in the Threads manpage.  This patch file can be applied by
cd'ing into a perl5.003 directory and typing patch -p1 <patch_file_name
-- 
**************************************************
1996 is the Year of the Rat; people born in the Year of 
the Rat are smart and diligent, previous years were
1984,1972, ...




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

Date: 3 Feb 1997 00:26:35 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: pattern matching of sorts
Message-Id: <5d3bbr$sa4$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, Gisle Aas <aas@bergen.sn.no> writes:
:Randal's solution does not work well with locales.  

Forgive him -- he's only a monoglot. :-)

--tom
-- 
Tom Christiansen      Perl Consultant, Gamer, Hiker      tchrist@mox.perl.com
: There may be 2 or three ways to perform a particular task, but there will
: not be 10,000 as there are in perl.
I think you may be exaggerating slightly.  Perl isn't that good yet.


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

Date: 2 Feb 1997 18:54:35 -0800
From: gary@lscruz.scf.lmms.lmco.com (Gary Liefer)
Subject: Re: Perl 5.003 and BSD 2.1 (libwww-perl-5.0x)
Message-Id: <5d3k1b$rqh$1@lscruz.scf.lmms.lmco.com>

In article <32ee65fc.336138651@news.charm.net>,
Sean Rolinson <snowdog@charm.net> wrote:
>I've recently compiled perl5.003 and libwww-perl-5.06.  Both installed
>okay and testing fine, but when running GET, here is what message I
[ ... ]
>Bad free() ignored at /usr/local/lib/perl5/DynaLoader.pm line 140.
>Bad free() ignored at /usr/local/lib/perl5/DynaLoader.pm line 140.
[ ... ]
><H1>An Error Occurred</h1>
>501 - Can't load
>'/usr/local/lib/perl5/i386-bsdos/5.003/auto/Socket/Socket.o' for
>module Socket: can't resolve undefined symbols: Inappropriate file
>type or format.
[ ... ]
>Does anyone have any suggestions as to what might be causing the
>problem?  All the necessary modules have been installed and to the
>best of my knowledge (which is limited), GET should be working fine.

- I tracked this problem to the the BSDI dynamic load library (libdl.a).
The problem crops up when the executable is invoked without an absolute
path.  Function dlopen needs to read the symbol table but it has to search
for the a.out file.  The "Bad free()" error seems to occur when a different
version of perl (with the same name) is found somewhere in the path before
the one that's actually running.

- The "inappropriate file type" happens if the perl executable or any
of the link modules have been stripped (no symbol table).

- Setting the environment variable LD_LIBRARY_PATH appropriately seems
to be what's supposed to fix the problem.  I haven't actually tried this
myself though -- I just absolute-ized everything.

- Side note, Apache:  1.2b2 (anyhow) strips off the path before exec'ing
the CGI handler.  Is this good?  Some kind of security bollux?

-- 
-------------
Gary Liefer   gary@oetl1.scf.lmsc.lockheed.com


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

Date: 03 Feb 1997 00:20:27 +0100
From: Jens Elkner <elkner@irb.cs.uni-magdeburg.de>
Subject: Q: gethostbyaddr in Perl 5.003 buggy ???
Message-Id: <vct20ayre10.fsf@irb.cs.uni-magdeburg.de>

Hi,

gethostbyaddr (perl, version 5.003 with EMBED built under solaris 2.5)
is driving me nuts: It returns other results than nslookup (i.e. no
FQDN) and I can't find out why :-((((.

E.g.:

==============================================================================
#!/usr/local/bin/perl
$Host="194.95.210.135";
if ( $Host =~ m#^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$#o ) {
        ($a,$b,$c,$d)=($1,$2,$3,$4);
        $IPN=pack('C4',$a,$b,$c,$d);
        ($name,$aliases,$addrtype,$length,@addrs)=gethostbyaddr($IPN,$AF_INET);
        $name = "Unknown" if (! $name);
        print "Host name for $Host: $name\n";
}
==============================================================================

returns:

Host name for 194.95.210.135: Unknown


and nslookup 194.95.210.135 returns:

Server:  wotan.cs.uni-magdeburg.de
Address:  141.44.25.1

Name:    chlothar.bamberg.baynet.de
Address:  194.95.210.135


So my questiton: Is it a perl bug or do I use this function not
properly ???

BTW: When I try 130.149.27.89 sometimes gethostbyaddr returns the
     correct result (heavymetal.cs.tu-berlin.de) and sometimes nothing!
     May be gethostbyaddr is more a randomizer than a lookup funktion
     :-( ?

Does anybody know a reliable function for doing reverse lookups of IP
addr. ? 

Thanx,
Jens. 
-- 
+--------------------------------------------------------------------------+
| Jens Elkner                   | Otto-von-Guericke-Universitaet Magdeburg |
|                               +==========================================|
| Am Uniplatz 5                     elkner@irb.cs.uni-magdeburg.de         |
| WH 4   PF 310                     elkner@sunpool.cs.uni-magdeburg.de     |
| 39106 Magdeburg   GERMANY       http://irb.cs.uni-magdeburg.de/~elkner   |
+--------------------------------------------------------------------------+


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

Date: Sun, 2 Feb 1997 18:52:18 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Jens Elkner <elkner@irb.cs.uni-magdeburg.de>
Subject: Re: Q: gethostbyaddr in Perl 5.003 buggy ???
Message-Id: <Pine.GSO.3.95.970202184533.11608F-100000@linda.teleport.com>

On 3 Feb 1997, Jens Elkner wrote:

> gethostbyaddr (perl, version 5.003 with EMBED built under solaris 2.5)
> is driving me nuts: 

> #!/usr/local/bin/perl
> $Host="194.95.210.135";
> if ( $Host =~ m#^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$#o ) {
>         ($a,$b,$c,$d)=($1,$2,$3,$4);
>         $IPN=pack('C4',$a,$b,$c,$d);
>         ($name,$aliases,$addrtype,$length,@addrs)=gethostbyaddr($IPN,$AF_INET);
>         $name = "Unknown" if (! $name);
>         print "Host name for $Host: $name\n";
> }

This is a good case for using -w to turn on warnings. When you do, this
script tells you that you're using an uninitialized value. A little
detective work quickly shows that $AF_INET was never set to anything. A
little more experimenting confirms that once you set $AF_INET to two near
the start of the script, the script works on my system.

Note that if you want only the name, you may simply call gethostbyaddr in
a scalar context. Hope this helps! 

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/




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

Date: Sun, 2 Feb 1997 18:14:15 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Triantafyllos Marakis <ceetm@cee.hw.ac.uk>
Subject: Re: Question
Message-Id: <Pine.GSO.3.95.970202181008.11608C-100000@linda.teleport.com>

On Sat, 1 Feb 1997, Triantafyllos Marakis wrote:

> Subject: Question

You would benefit from reading the frequent posting about choosing good
subject lines.

> Is it possible to query remotely a CGI script (A search engine CGI
> script) and get the results automatically on a file? 

Yes, it is.

> P.S. I have just starting programming with perl so please do not use
> extreme perl terminology. 

Then I won't tell you that you can do it easily with LWP in CPAN. :-)

   http://www.perl.com/CPAN/modules/by-module/LWP/

I will say that purchasing and reading the Llama book followed by the
Camel book wouldn't be a bad way to get used to extreme Perl terminology.
Hope this helps! 

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: Sun, 02 Feb 1997 23:29:55 GMT
From: ataide@planetarium.com.br (Efigenio Ataide)
Subject: Re: Reading comma delimited file?
Message-Id: <32f522c2.9846229@newsfeed.pnl.gov>

Try Sprite version 3.1
(http://www.perl.com/CPAN/authors/Shishir_Gundavaram/).

max@cup.hp.com (Franck Borghino) wrote:

>I wrote:
>| Does anyone out there have a good fast way to read in
>| the fields in a comma delimited file...
>
>Oops, it's in the FAQ.  Missed it first time.
>Guess that's why no-one answered - hehheh - quite right too.



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

Date: Sun, 2 Feb 1997 18:07:55 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Juha Hartikainen ia201 <jhartika@orion.pspt.fi>
Subject: Re: Reading numbers from file..
Message-Id: <Pine.GSO.3.95.970202180546.11608B-100000@linda.teleport.com>

On 1 Feb 1997, Juha Hartikainen ia201 wrote:

> I have a huge database which is on my own format. It haves strings, which 
> are easy to read with Perl. It haves also MANY floating point numbers. 
> How can I read these Intel double numbers and convert 'em to string??
> double is 8 bytes long floating point number.

It sounds as if you want to convert them from strings to numeric, probably
using unpack. Hope this helps!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: Mon, 03 Feb 1997 11:37:21 +1100
From: Martien Verbruggen <mgjv@comdyn.com.au>
To: David Waters <przec@westminster.ac.uk>
Subject: Re: regular expressions
Message-Id: <32F53341.3ECE@comdyn.com.au>

David Waters wrote:
> 
> Hi all,
> Bsically Im looking for a regular expression that
> will add a trailing zero to a numeric string where necessary.

Your example numbers suggest that all input numbers will have at least
one digit after a decimal ., and at least one digit in front of it. If
that's true, you can do this:

#!/usr/local/bin/perl5 -w
use strict;
my @stuff = ( 89.9, 45.50, 1234.56, "123.0" );
 
foreach (@stuff) { 
    print "$_ -> ";
    s/^(\d+\.\d)$/${1}0/;
    print "$_\n"; 
}

OUTPUT:
89.9 -> 89.90
45.5 -> 45.50
1234.56 -> 1234.56
123.0 -> 123.00

You'll notice the quotes around 123.0.. Because perl will interpret them
as numbers, without the quotes, 123.0 would evaluate to 123, which
wouldn't be picked up by the subst. You could change it to:

    s/^(\d+\.\d)$/${1}0/;
    s/^(\d+)$/${1}.00/;

or even to

    s/^(\d+)(\.\d)*$/($2)?$1.$2.'0':$1.'.00'/e;

This last one will look for any number of digits at the start (storing
that in $1), and then, possibly, a decimal point followed by a digit
(storing that in $2). The right side will be evaluated as a perl
expression (thanks to the e option) basically substituting the first
thing if $2 is set, and the second part if $2 isn't set.

It still will only work for numbers without a decimal point, or number
with a decimal point followed by exactly one digit. negatives are not
allowed.

You will be able to work from this, no doubt.

-- 
Martien Verbruggen

Webmaster www.tradingpost.com.au
Commercial Dynamics Pty Ltd, N.S.W., Australia


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

Date: Sun, 2 Feb 1997 18:36:14 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: "D. M. Johnson" <ez045864@peseta.ucdavis.edu>
Subject: Re: subprocess help
Message-Id: <Pine.GSO.3.95.970202181512.11608D-100000@linda.teleport.com>

On Sun, 2 Feb 1997, D. M. Johnson wrote:

> I need to run spell from inside a program, passing it the contents of
> $var1.  Everytime I try I get an empty variable as the return, even if
> the word is mispelled. 

Well, the open question is, what are you sending to spell? Here's one way
to find out. 

Instead of running spell with whatever arguments and input you're giving
it, run this little script - call it 'noisy'. It should show you whatever
it's seeing. 

    #!/usr/bin/perl
    print STDERR "$0: My args were ",
	join(', ', map "'$_'", @ARGV), ".\n"; 
    print STDERR "$0: My input was:\n";
    while (<STDIN>) { print STDERR "(Input to $0) $_" }
    print STDERR "\n$0: That's all!\n";
    exit;

Now you'll be able to see just what you're asking spell to do. If you're
asking it the wrong thing, you should see that right away. If you're
asking it the right thing but it's giving you the wrong answer, that's
between you and spell - we Perl folks can't help there! If it's giving you
the right answer, but the answer isn't getting back to your script, try
_this_ little script - call it 'fakespell' - and see whether its word goes
where it's supposed to.

    #!/usr/bin/perl
    print "mispelled\n";
    exit 1;

Of course, if you can cut your program down to a sample of just a few
lines which try and fail to get spell to work, you can post it to
c.l.p.misc and we might have an easier time helping you debug it. Good
luck!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: 03 Feb 1997 00:22:24 +0100
From: Gisle Aas <aas@bergen.sn.no>
Subject: Re: URL Encoding
Message-Id: <hvi8aaj4f.fsf@bergen.sn.no>

jfriedl@tubby.nff.ncl.omron.co.jp (Jeffrey) writes:

> Neal Kaiser <icculus@student.umass.edu> wrote:
> |> How would I ENCODE a URL, much like the way netscape does when your
> |> form input type is GET??
> |
> |> But, I can't seem to reverse this to encode it.  I know how to reverse
> |> the first step, but the second one is giving me problems.
> 
> I use:
>     $text =~ s/([^\w])/sprintf("%%%02x", ord($1))/ge;
> 
> It's a bit overzealous in that it encodes things that don't need to be, but
> it doesn't hurt.

It might hurt.  Some URL chars are reserved.  A "/" is not the same as
a "%2F".  A "?" is not the same as a "%3F".  I recommend that you use
the URI::URL module.

-- 
Gisle Aas <aas@sn.no>


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

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

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 V7 Issue 885
*************************************

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