[12154] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5754 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 22 21:07:16 1999

Date: Sat, 22 May 99 18:00:15 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 22 May 1999     Volume: 8 Number: 5754

Today's topics:
    Re: Execute a command from perl... tvn007@my-dejanews.com
    Re: Execute a command from perl... <uri@sysarch.com>
    Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Pe finsol@ts.co.nz
    Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Pe finsol@ts.co.nz
    Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Pe <tchrist@mox.perl.com>
    Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Pe <uri@sysarch.com>
    Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Pe <tchrist@mox.perl.com>
    Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Pe <tchrist@mox.perl.com>
    Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Pe <revjack@radix.net>
    Re: FAQ 8.1: How do I find out which operating system I <mds-resource@mediaone.net>
    Re: File Upload using CGI.pm (Bob Trieger)
        Got a flavor to ask... <brad@wcubed.net>
    Re: Help with text formatting --- Please! <uri@sysarch.com>
        Parsing User Mail File - Sanity Check... <Anthony@Baratta.com>
    Re: using gethostbyaddr? (Chuck Bearden)
        Why empty file ? tvn007@my-dejanews.com
    Re: Why empty file ? <uri@sysarch.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Sat, 22 May 1999 22:56:43 GMT
From: tvn007@my-dejanews.com
Subject: Re: Execute a command from perl...
Message-Id: <7i7cnb$7v1$1@nnrp1.deja.com>

Try this:

# to remove file_name using Unix command rm
system ("rm file_name" );

Tim


n article <3746f3e9@cs.colorado.edu>,
  tchrist@mox.perl.com (Tom Christiansen) wrote:
>  [courtesy cc of this posting sent to cited author via email]
>
> In comp.lang.perl.misc, <denny@chuang.com> writes:
> :How do I execute a unix command from perl?
>
> Get a firing squad?
>
> :Are there any examples to check out?
>
> It's difficult to conceive of a more basic function that this one.
> Well, length of a string, I guess.
>
> Did you someone miss the perlfunc manpage?  What about the FAQ?
>
> --tom
> --
>     I'm sure that that could be indented more readably, but I'm scared
of
>     the awk parser.             --Larry Wall in
<6849@jpl-devvax.JPL.NASA.GOV>
>


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


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

Date: 22 May 1999 19:41:33 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Execute a command from perl...
Message-Id: <x7g14o7jv6.fsf@home.sysarch.com>

>>>>> "t" == tvn007  <tvn007@my-dejanews.com> writes:

  t> Try this:
  t> # to remove file_name using Unix command rm
  t> system ("rm file_name" );

now i am sorry i just answered your previous post. that is a very silly
thing to do. perl has the unlink op to remove files. no need to call
unix's rm command (which is unportable to boot but i could care less
about uncle bill's crap).

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Sat, 22 May 1999 23:04:08 GMT
From: finsol@ts.co.nz
Subject: Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Perl Y2K compliant?
Message-Id: <7i7d58$89i$1@nnrp1.deja.com>


>     Perl is just as Y2K compliant as your pencil--no more, and no
less.
>     Can you use your pencil to write a non-Y2K-compliant memo? Of
>     course you can. Is that the pencil's fault? Of course it isn't.

Unfortunately, many of the Y2K problems in Perl applications *is* the
fault of the language.

For those of you wanting to know more about the Perl Y2K booby-trap code
problem, check out:

http://www.y2kinfo.com/journal/features/0499_amona.html

You may also be interested in reading about just how stupidly defensive
many programmers can be on this subject - this newsgroup has provided
some excellent examples for my article which can be accessed at URL:

http://www.y2kinfo.com/journal/features/0599_amon.html

I was informed that Perl wasn't used for anything critical anyway and
that the worst that can be expected is a year value of 19100 instead of
2000 on a web page, unlike C and Java which are used for more important
applications.  Because of this I had stopped debating this issue on this
newsgroup and havn't posted anything hereb since last year.  However,
the arguments are still raging and it seems that some programmers are
using Perl for more important functions.

Unfortunately, C and Java also have the Y2K booby-trap problem.

Jocelyn Amon
--
Financial Solutions Limited
http://www.ts.co.nz/~finsol/


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


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

Date: Sat, 22 May 1999 23:07:50 GMT
From: finsol@ts.co.nz
Subject: Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Perl Y2K compliant?
Message-Id: <7i7dc6$8bq$1@nnrp1.deja.com>


>     Perl is just as Y2K compliant as your pencil--no more, and no
less.
>     Can you use your pencil to write a non-Y2K-compliant memo? Of
>     course you can. Is that the pencil's fault? Of course it isn't.

Unfortunately, many of the Y2K problems in Perl applications *is* the
fault of the language.

For those of you wanting to know more about the Perl Y2K booby-trap code
problem, check out:

http://www.y2kinfo.com/journal/features/0499_amona.html

You may also be interested in reading about just how stupidly defensive
many programmers can be on this subject - the Perl newsgroup has
provided some excellent examples for my article which can be accessed at
URL:

http://www.y2kinfo.com/journal/features/0599_amon.html

I was informed that Perl wasn't used for anything critical anyway and
that the worst that can be expected is a year value of 19100 instead of
2000 on a web page, unlike C and Java which are used for more important
applications.  Because of this I had stopped debating this issue on the
Perl newsgroup so havn't posted anything since last year.  However,
the arguments are still raging and it seems that some programmers are
using Perl for more important functions.

Unfortunately, C and Java also have the Y2K booby-trap problem.

Jocelyn Amon
--
Financial Solutions Limited
http://www.ts.co.nz/~finsol/


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


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

Date: 22 May 1999 17:53:08 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Perl Y2K compliant?
Message-Id: <37474364@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

Cursed by that miserable piece of crap, Mozilla/4.05 [en] (Win95; I)
finsol@ts.co.nz writes in comp.lang.perl.misc:

:Unfortunately, many of the Y2K problems in Perl applications *is* the
:fault of the language.

Thanks for spreading Fear and Ugliness and Deception.  Scare tactics
like these are great for media coverage, but will get get you laughed
out of the profession.

There are stupid people everywhere.  There are stupid pencils everywhere.
If you don't read the fine manpage, then you shall suffer.  

:For those of you wanting to know more about the Perl Y2K booby-trap code
:problem, check out:
:
:http://www.y2kinfo.com/journal/features/0499_amona.html

You expect us to take seriously a document that refers to "CGI" as a
language and goes on to claim this CGI language's localtime function
has a problem?  Oh please.

:http://www.y2kinfo.com/journal/features/0599_amon.html

That isn't HTML -- it's a vicious lie.  Watch:

   Whether or not they do or don?t create Y2K problems, time will tell.

    * it?s up to testers to find the problems. 

    * the system designers didn?t tell us to take the years beyond 1999
    into consideration.

You've mean moronised!  Please read these three links that may help you
fix this idiocy:

1.  +----------------------------------------------------+
    | Perl Script to Fix These Problems Automagically    |
    |     http://language.perl.com/misc/demoroniser.html |
    +----------------------------------------------------+

2.  +---------------------------------------------------------------+
    | Explanation of Why MS-HTML Is a Nefarious and Despicable Plot |
    |     http://language.perl.com/misc/ms-ascii.html               |
    +---------------------------------------------------------------+

3.  +--------------------------------------------------+
    | Webpage Design Tips for Maximizing Accessibility |
    |     http://language.perl.com/misc/div-www.html   |
    +--------------------------------------------------+

:I was informed that Perl wasn't used for anything critical anyway 

Define "critical".

:and
:that the worst that can be expected is a year value of 19100 instead of
:2000 on a web page, unlike C and Java which are used for more important
:applications.  

I'm dying of laugher.  You know not of what you speak, but I don't
imagine telling you this will help you.

--tom
-- 
     This is UNIX; if you can't get the sources, it isn't freeware.
     --Peter Salus


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

Date: 22 May 1999 19:57:32 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Perl Y2K compliant?
Message-Id: <x7btfc7j4j.fsf@home.sysarch.com>

>>>>> "f" == finsol  <finsol@ts.co.nz> writes:

  >> Perl is just as Y2K compliant as your pencil--no more, and no
  f> less.
  >> Can you use your pencil to write a non-Y2K-compliant memo? Of
  >> course you can. Is that the pencil's fault? Of course it isn't.

  f> Unfortunately, many of the Y2K problems in Perl applications *is* the
  f> fault of the language.

perl has nothing to do with it. it is defined by the struct tm in the
libc library. perl just follows that convention. if you can't read the
man pages, get out of the programming pool.

you don't get the separation of the language from the application do
you? the language can't be not y2k compliant since it just returns a
well defined value for the year which can be properly converted to a 4
digit year. the application (written by an idiot) is broken. so stop
spreading fud about this.

  f> http://www.y2kinfo.com/journal/features/0499_amona.html

your article is useless. it mentions tutorials which are mostly
crap. there is no booby trap, only booby programmers. the year value is
correctly documents in the libc man pages where you should be reading if
you use that localtime function.

  f> You may also be interested in reading about just how stupidly defensive
  f> many programmers can be on this subject - the Perl newsgroup has
  f> provided some excellent examples for my article which can be accessed at
  f> URL:

  f> http://www.y2kinfo.com/journal/features/0599_amon.html

stay in new zealand. your fud is more helpful there. your examples are
not even real quotes, just your edited fud. 

  f> I was informed that Perl wasn't used for anything critical anyway and
  f> that the worst that can be expected is a year value of 19100 instead of
  f> 2000 on a web page, unlike C and Java which are used for more important
  f> applications.  Because of this I had stopped debating this issue on the
  f> Perl newsgroup so havn't posted anything since last year.  However,
  f> the arguments are still raging and it seems that some programmers are
  f> using Perl for more important functions.

perl is used for many critical projects and the y2k nature is dependent
on the programmer, not the language. don't you get that? this is not
shuffling the blame but understanding the cause. you flame about elitism
but that is the issue. those who rtfm grok the year value. those who
don't are doomed by y2k.

i hope you are not using perl for anything since that would ruin my
sense of elitism. if you can use my language than either it is too easy
for you or i am not that much a better programmer. since i know you
don't understand y2k at all and i do, it must be you don't use perl
which is fine with me. so stay out of this newsgroup and spread fun in
some redmondware group where that practice is allowed.

  f> Unfortunately, C and Java also have the Y2K booby-trap problem.

so doeas every language that use c like libraries. so does any language
with a moron using it (like most newbies out there). so do you. so does
everyone. y2k is as much a human problem as a programming problem.

  f> --== Sent via Deja.com http://www.deja.com/ ==--
  f> ---Share what you know. Learn what you don't.---

well you didn't share what you know. you just showed us what you don't.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: 22 May 1999 18:03:15 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Perl Y2K compliant?
Message-Id: <374745c3@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]


Cursed by that miserable piece of crap, Mozilla/4.05 [en] (Win95; I),
finsol@ts.co.nz writes in comp.lang.perl.misc:

In comp.lang.perl.misc, finsol@ts.co.nz writes:
:
:>     Perl is just as Y2K compliant as your pencil--no more, and no
:less.  [YOUR NEWSREADER MISWRAPPED THIS.  STOP IT!]
:>     Can you use your pencil to write a non-Y2K-compliant memo? Of
:>     course you can. Is that the pencil's fault? Of course it isn't.
:
:Unfortunately, many of the Y2K problems in Perl applications *is* the
:fault of the language.

Oh great -- I've got deja lu, and get to read about Fear and Ugliness and
Deception for the second time.  Either your newsreader, your newsserver,
or your wetware is broken.  Or some combination of these.

You appear to have accidentally re-posted the same article more than once.
If this was intentional, I don't know why you did that.  If it wasn't
intentional, this was probably because of a bug in the news posting
software.  Web browsers masquerading as lame excuses for real newsreaders
are notoriously bad in the area.  Netscape 2.0 had claimed to have fixed
it, but folks continued to see problems from it, and further fixes were
applied for the 3.0 version.  If you used Netscape to post this article
and it was version 3.0 or later, I suggest you report the bug to them.
Otherwise, I would try to get that version.  While using an "internet
browser" as though it were a newsreader is a lose-lose siutation, Netscape
has done far more right than any other browser, especially lately.

In the best of all possible worlds, I would urge you to contact the
author or vendor of the software you used to post your message and
explain to them that they're sending out duplicate messages.  If I knew
their email address, I would even do it myself.  I surely hope you paid
no money for this thing.

You may well wish to cancel your spurious extra posting(s).  If you
don't know how to do this, you shouldn't be using Usenet at all.

--tom
-- 
    X-Windows: The Cutting Edge of Obsolescence.
	--Jamie Zawinski


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

Date: 22 May 1999 18:06:02 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Perl Y2K compliant?
Message-Id: <3747466a@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, Uri Guttman <uri@sysarch.com> writes:
:perl has nothing to do with it. it is defined by the struct tm in the
:libc library. perl just follows that convention. if you can't read the
:man pages, get out of the programming pool.

She obviously can't.  She calls "CGI" a programming language.  And she
reposts duplicate articles -- see her duplicate posting for my reply.
And she uses MS-HTML, which is illegal from the point of view of any
standards body.  I call that three strikes.

She's a FUD monger, although this time it's not just Fear, Uncertainty,
and Doubt -- it's also Fear, Ugliness, and Deception.

--tom
-- 
"If Dennis Ritchie were the man who developed Modula-2 then C would be long forgotten."
    --Tarjei Jensen


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

Date: 23 May 1999 00:56:48 GMT
From: Dietrich Wells <revjack@radix.net>
Subject: Re: FAQ 4.16: Does Perl have a year 2000 problem? Is Perl Y2K compliant?
Message-Id: <7i7jog$j07$1@news1.Radix.Net>
Keywords: Hexapodia as the key insight

I'm surprised that this troll wasn't xposted to alt.religion.kibology. :)

-- 
  /~\  indenture implementation soundproof cog backlash ebullient blas
 C oo  poop Cleveland stimulant peripatetic Gilbertson heckle graduate
 _( ^) 1 , 0 0 0 , 0 0 0   m o n k e y s   c a n ' t   b e   w r o n g
/___~\ http://www.radix.net/~revjack/mnj             revjack@radix.net


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

Date: Sat, 22 May 1999 18:58:28 -0500
From: "Michael D. Schleif" <mds-resource@mediaone.net>
Subject: Re: FAQ 8.1: How do I find out which operating system I'm running under?
Message-Id: <374744A4.6012A5D0@mediaone.net>

I know; but, a guy can hope, can't he?

Jonathan Stowe wrote:
> 
> On Thu, 20 May 1999 20:08:01 -0500 Michael D. Schleif wrote:
> > But, please, the OS version or release number?
> >
> > I've struggled with this, off and on, due to running in a very
> > heterogeneous environment.  Often, I need to decide which system binary
> > to call, based on *both* OS and version.
> >
> 
> There is no way I know of in Perl but once you know the OS then you
> can start to do some OS specific stuff like:
> 
> #!/usr/bin/perl -w
> 
> use strict;
> 
> my $release;
> 
> if ( $^O =~ /Linux/i )
>   {
>    chomp($release = `/usr/bin/uname -r`);
>   }
> 
> print $release,"\n";
> 
> /J\
> --
> Jonathan Stowe <jns@gellyfish.com>
> Some of your questions answered:
> <URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
> Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>

-- 

Best Regards,

mds
mds resource
888.250.3987

"Dare to fix things before they break . . . "

"Our capacity for understanding is inversely proportional to how much we
think we know.  The more I know, the more I know I don't know . . . "


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

Date: Sun, 23 May 1999 00:39:40 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: File Upload using CGI.pm
Message-Id: <7i7h6t$i2a$1@oak.prod.itd.earthlink.net>

[ courtesy cc sent by mail if address not munged ]
     
news@harvest-lodge.demon.co.uk wrote:
>I am trying to write a script which will allow users to upload a file
>via the <INPUT type="file"......> html page.
>
>Can anyone let me have an example of both the html and corresponding
>perl to modify.
>
>I have CGI.pm installed and available but have so far not managed to
>find the file which I think is being uploaded.

The example that comes with CGI.pm could not be any clearer!

Did you bother to check it out?

perldoc CGI



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

Date: Sat, 22 May 1999 17:17:22 -0600
From: Brad Waite <brad@wcubed.net>
Subject: Got a flavor to ask...
Message-Id: <37473B02.E4FAC0E@wcubed.net>

Could someone please try to store and retrieve a GD::Image object to a
file via the FreezeThaw or Storable packages?

I can store/retrieve hashes and scalars just fine, but when I try a
GD::Image it dumps core.

Tanks fer the help.

-- 
Brad Waite
W Cubed - The World Wide Web Company


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

Date: 22 May 1999 19:33:38 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Help with text formatting --- Please!
Message-Id: <x7ogjc7k8d.fsf@home.sysarch.com>

>>>>> "LB" == Larry Buchanan <Larry@buchanan.com> writes:

  LB> I have a project (handed to me on Friday) that I must have
  LB> completed by Monday as the VC's are coming in to meet with my boss
  LB> first thing Monday am. I was asked to have this perl rutine
  LB> running and fully tested by Monday am. Here's the problem...

then why didn't he hire someone who knows perl? i feel very odd about a
boss who deals with vc money who won't hire a perl contractor to get
such a simple job done if it has to be done right under a
deadline. asking for help here for this shows some chutzpah. usenet is
free and not necessarily timely.

  LB> I can FTP the file with my current script, no problem. I then need
  LB> to read the file and format the data properly. Here's a sample of
  LB> the file...

i hope you are using the Net::FTP module and not rolling your own.

  LB> time date stamp <cr>   <--- cr = carridge return <----- I need this stamp
  LB> <cr>
  LB> <cr>
  LB> name1: begining of paragraph message <cr>
  LB> continued message <cr>
  LB> continued message <cr>
  LB> continued message <cr>
  LB> continued message <cr>
  LB> <cr>
  LB> <cr>
  LB> name2: begining of paragraph message <cr>
  LB> continued message <cr>
  LB> continued message <cr>
  LB> continued message <cr>
  LB> continued message <cr>
  LB> <cr>
  LB> <cr>
  LB> EOF <---- Actually a blank line

that description is very poor. does each line end in only CR or CR/LF?
then what is a blank line for EOF but another CR?

is the timestamp only in the first line?

if you are using the ftp module to handle this, you should have the
file in memory. if not you could slurp it in in paragraph mode. either
way you should end up with a list of paragraphs (which were separated by
multiple CRs). then you can take the first and parse out the time
stamp. then loop over the rest and translate the single CRs to blank or
something useful. then it is simple to parse out the name: part with
split or a regex or index on : (more than one way to do it).

for any more work on my part i expect equity as i can save the day for
the vc visit!

good luck.

uri


-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Sat, 22 May 1999 17:49:14 -0700
From: Anthony Baratta <Anthony@Baratta.com>
Subject: Parsing User Mail File - Sanity Check...
Message-Id: <3747508A.98F19474@Baratta.com>

Howdy...

I just need a sanity check that I'm approaching this solution correctly:

I am receiving MIME encoded messages in my UNIX mail account that I am
parsing out and "massaging" before import into an mSQL database. I've
already coded the scripts that copy the mail file over (e.g.
/var/spool/mail/foo) to a temp location and 'play with it'. I then
manually delete the target emails using mail/mailx.

What I want to do now (and need the sanity check on) is to "move" the
file to a temp location, 'cut out' the messages and return the mail file
back to the mail spool directory minus the target messages. (e.g.
automating the deletes of the target messages.)

I know that before I move the mail file back I should see if a new mail
file exists, and if so - cat them together. If no file exists, just copy
the neutered file back. Am I playing with fire here? Is there a mail
lock file I should be looking for? (we are using sendmail) Should I ask
this question on the sendmail list?

Thanks in advance!!
-- 
Anthony Baratta
President
KeyBoard Jockeys
                    South Park Speaks Version 3 is here!!!
                       http://www.baratta.com/southpark
                              Powered by Tsunami


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

Date: 22 May 1999 23:15:41 GMT
From: cbearden@hal-pc.org (Chuck Bearden)
Subject: Re: using gethostbyaddr?
Message-Id: <slrn7keekq.2aa.cbearden@calvin.home>

On Tue, 18 May 1999 20:41:12 -0700, Larry Rosler <lr@hpl.hp.com> wrote:
>[Posted and a courtesy copy sent.]
>
>In article <3741E75B.7F6E41C4@infonet.ee> on Wed, 19 May 1999 01:19:07 
>+0300, Gleb Ekker <globus@infonet.ee> says...
>> I use free hosting service where CGI/Perl is allowed but they do not
>> give $ENV{REMOTE_HOST}, it is empty.  I have only $ENV{REMOTE_ADDR} with
>> numerical address, but I need to have server's name too.
>> 
>> I heared that it is possible to modify it by using gethostbyaddr, to
>> resolve the host address into a host name. Please give me an example how
>> I can do this thing.
>
>There is an example in the Perl documentation of the function.
>
>perldoc -f gethostbyaddr
>
>If you can't get a short test program o run correctly, come back here 
>with the code and the symptoms.
>
>-- 
>(Just Another Larry) Rosler
>Hewlett-Packard Company
>http://www.hpl.hp.com/personal/Larry_Rosler/
>lr@hpl.hp.com

This is a timely posting, as I'm having trouble making 'gethostbyaddr' 
work, and unfortunately, 'perldoc -f gethostbyaddr' does not include 
an example on my system (RH Linux 5.2, perl-5.004m4-1.src.rpm).  I am 
downloading the updated RPM as I compose this message.

I can gethostbyname just fine:

  $name = "www.hal-pc.org";
  $addr = gethostbyname $name;
  print length($addr), "\n";
  exit;
  @addr = unpack('C4', $addr);
  print join('.', @addr), "\n";

yields '204.52.135.1' as I'd hoped.

However, the inverse doesn't seem to work:

  $addr = "204.52.135.1";
  @addr = split(/\./, $addr);
  $addr = pack('C4', @addr);
  #print length($addr), "\n";
  $name = gethostbyaddr($addr, AF_INET);

gives an error:

  Argument "AF_INET" isn't numeric in ghbyaddr at ./getbyaddr line 7.
  Use of uninitialized value at ./getbyaddr line 9.

This puzzles me, because acc. to the man pages, _Programming_Perl_, and 
_Perl_in_a_Nutshell_, 'gethostbyaddr' takes two arguments, 'addr' and 
'addrtype', with the second being optional.

I know no C, and I've never done network programming before, so 
please forgive me if this is a bonehead question.

Chuck Bearden
Electronic Resources Librarian, Rice University
HAL-PC Member


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

Date: Sat, 22 May 1999 22:53:36 GMT
From: tvn007@my-dejanews.com
Subject: Why empty file ?
Message-Id: <7i7chg$7sv$1@nnrp1.deja.com>

Hi,
Would someone help me please ?

Why file "REPORT_OUTPUTS" is empty even I tried to print something
("CHECKING") and ("$_") to it ???
######Below is a the code ######################
$output_file = "REPORT_OUTPUTS";

unless (open(OUTFILE, ">$output_file")){
	die("cannot open output file $output_file\n");
print OUTFILE ("CHECKING\n");

foreach (@NAME) {

print ("$_\n");
}

close OUTFILE;
}

##########end of code ######################

Thanks for your help,


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


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

Date: 22 May 1999 19:39:12 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Why empty file ?
Message-Id: <x7k8u07jz3.fsf@home.sysarch.com>

>>>>> "t" == tvn007  <tvn007@my-dejanews.com> writes:

  t> Why file "REPORT_OUTPUTS" is empty even I tried to print something
  t> ("CHECKING") and ("$_") to it ???

this is some of the poorer formatting i have seen in a while. do proper
indenting and you will save yourself some major bugs.


  t> unless (open(OUTFILE, ">$output_file")){
  t> 	die("cannot open output file $output_file\n");
  t> print OUTFILE ("CHECKING\n");

i have never seen this idiom before. maybe because it is broken. unless
is a negative test. if the file is opened, the entire block is
skipped. no file is opened or written to.

  t> foreach (@NAME) {

  t> print ("$_\n");
  t> }

this would print to STDOUT and not OUTFILE (if this code ever executed)

  t> close OUTFILE;
  t> }


i think you want something more like this:

open( OUTFILE, ">$output_file" ) || die
				"cannot open output file $output_file $!\n" ;


foreach (@NAME) {

	print OUTFILE "$_\n" ;
}

close OUTFILE;


uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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