[15579] in Perl-Users-Digest
Perl-Users Digest, Issue: 2992 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 9 14:10:42 2000
Date: Tue, 9 May 2000 11:10:29 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <957895828-v9-i2992@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 9 May 2000 Volume: 9 Number: 2992
Today's topics:
Is Perl the right solution? <dtranche@rascom.com>
Re: Is Perl the right solution? <rrindels@arkansas.net>
Re: Is Perl the right solution? nobull@mail.com
Re: is there an easy way to use colours in stdout? <tina@streetmail.com>
Re: methods reading in external file bluesrift@aol.com
Re: methods reading in external file (M.J.T. Guy)
Re: methods reading in external file <lr@hpl.hp.com>
Re: Net::SMTP module question <iltzu@sci.invalid>
Pattern Matching <lum0509@hotmail.com>
Re: Pattern Matching <rootbeer@redcat.com>
Re: Pattern Matching <jeff@vpservices.com>
Re: Perl code to check for broken links <erick.jensen@unisys.com>
Re: Perl code to check for broken links (Randal L. Schwartz)
Re: Perl code to check for broken links <erick.jensen@unisys.com>
Re: Perl code to check for broken links (Jerome O'Neil)
Re: Perl code to check for broken links (Bart Lateur)
Re: Perl code to check for broken links <jeff@vpservices.com>
Re: Perl code to check for broken links <flavell@mail.cern.ch>
Re: Perl code to check for broken links <lr@hpl.hp.com>
Re: Please help cannot display REMOTE_HOST variable <joydip_chaklader@my-deja.com>
Please help me on displaying REMOTE_HOST through gethos <joydip_chaklader@my-deja.com>
Re: Please help me on displaying REMOTE_HOST through ge nobull@mail.com
please help me to display REMOTE_HOST variable by getho <joydip_chaklader@my-deja.com>
Re: Printing Arrays <lr@hpl.hp.com>
semaphores under perl <cslewis@mobilecom.com>
Re: semaphores under perl nobull@mail.com
Re: signal trapper <andy@u2me3.com>
Re: vec and bitwise or ? <rootbeer@redcat.com>
Re: vec and bitwise or ? (Bart Lateur)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 9 May 2000 11:10:59 -0400
From: "DTranche" <dtranche@rascom.com>
Subject: Is Perl the right solution?
Message-Id: <39183617.0@newsfeed.vitts.com>
I need to be able to create scripts easily to test a system. The main code
is written in C, and would execute the scripts. I was looking at lex & yacc
but the flow control seems much easier in perl.
There would only be a couple of functions, imported from a library, that the
scripts would call. Is Perl the right solution for this problem, or would I
be better off using lex & yacc or writing my own interpreter.
Thanks
------------------------------
Date: Tue, 9 May 2000 11:25:20 -0500
From: "Rodney Rindels" <rrindels@arkansas.net>
Subject: Re: Is Perl the right solution?
Message-Id: <IYWR4.21024$Lx.3597434@news-west.usenetserver.com>
I think you need to expand the details a little more.
As well as the platform
Rodney
DTranche <dtranche@rascom.com> wrote in message
news:39183617.0@newsfeed.vitts.com...
> I need to be able to create scripts easily to test a system. The main
code
> is written in C, and would execute the scripts. I was looking at lex &
yacc
> but the flow control seems much easier in perl.
>
> There would only be a couple of functions, imported from a library, that
the
> scripts would call. Is Perl the right solution for this problem, or would
I
> be better off using lex & yacc or writing my own interpreter.
>
> Thanks
>
>
------------------------------
Date: 09 May 2000 18:32:19 +0100
From: nobull@mail.com
Subject: Re: Is Perl the right solution?
Message-Id: <u9k8h3iq8s.fsf@wcl-l.bham.ac.uk>
"DTranche" <dtranche@rascom.com> writes:
> I need to be able to create scripts easily to test a system. The main code
> is written in C, and would execute the scripts. I was looking at lex & yacc
> but the flow control seems much easier in perl.
>
> There would only be a couple of functions, imported from a library, that the
> scripts would call. Is Perl the right solution for this problem, or would I
> be better off using lex & yacc or writing my own interpreter.
To add scripting support to an application writing your own
interpreter using yacc or lex is probably way down the list below
Perl, Python and TCL. TCL was originally invented for this purpose!
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 09 May 2000 13:53:11 -0400
From: Tina Mueller <tina@streetmail.com>
Subject: Re: is there an easy way to use colours in stdout?
Message-Id: <8f9j9t$aaeic$1@fu-berlin.de>
hi,
R1CH wrote:
> This may seem like a simple question, but is there any simple/easy way
> to output colored/bold text to stdout? I have looked at some Terminal.pm
> (I think it was that) and that had no mention of color... any ideas?
perldoc -q color terminal
gives me the following answer:
----------------
=head2 How do I print something out in color?
In general, you don't, because you don't know whether
the recipient has a color-aware display device. If you
know that they have an ANSI terminal that understands
color, you can use the Term::ANSIColor module from CPAN:
use Term::ANSIColor;
print color("red"), "Stop!\n", color("reset");
print color("green"), "Go!\n", color("reset");
Or like this:
use Term::ANSIColor qw(:constants);
print RED, "Stop!\n", RESET;
print GREEN, "Go!\n", RESET;
-------------
tina
--
--- ICQ #73179850 --- | _ enter the
http://user.berlin.de/~tina.mueller | __| |___ ___ _ _ ___
---- tina's moviedatabase ----| / _` / _ \/ _ \ '_(_-< of
--search & add comments or reviews--| \__,_\___/\___/_| /__/ perception
------------------------------
Date: Tue, 09 May 2000 15:35:59 GMT
From: bluesrift@aol.com
Subject: Re: methods reading in external file
Message-Id: <8f9b8u$ajk$1@nnrp1.deja.com>
In article <8f8q7d$ha4$4@slb0.atl.mindspring.net>,
ebohlman@netcom.com (Eric Bohlman) wrote:
> You could do it that way, but I'd suggest doing:
>
> my $content=do {local $/;<FILE>};
>
> This confines the change to $/ to the enclosing block; upon exit from
the
> block the old value is automatically restored. The localization
> automagically sets $/ to undef after saving the old value.
I like this for readabilty because I do not need to create a
(physically separated in the code) named subroutine block merely to
localize $/. Correct? After reading PerlMan pages regarding "do" I
just want to be certain that a do {block} has the same variable
isolation potential as a named subroutine {block}.
Thanks!
Rob Bell
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 9 May 2000 16:50:14 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: methods reading in external file
Message-Id: <8f9fk6$a5d$1@pegasus.csx.cam.ac.uk>
Bart Lateur <bart.lateur@skynet.be> wrote:
>Ilja wrote:
>
>>But I'd suggest to use 'local $/ = undef' in a block,
>>so the old value will be restored automatically.
>
>You don't need to assign anything to $/ when localizing it. undef is the
>default value if you don't assign anything.
>
> {
> local $/;
> $content = <FILE>;
> }
>
>I propose localizing *FILE too, or possibly use a Filehandle (?) object
>to prevent stepping on it's use in other, outer, places.
>
> local *FILE;
And the seriously pedantic will want to localise $. as well.
Mike Guy
------------------------------
Date: Tue, 9 May 2000 10:09:21 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: methods reading in external file
Message-Id: <MPG.1381e61f2eed546b98aa29@nntp.hpl.hp.com>
In article <957878907.7742@itz.pp.sci.fi> on 9 May 2000 13:38:05 GMT,
Ilmari Karonen <iltzu@sci.invalid> says...
> In article <8f8b0b$72c$1@nnrp1.deja.com>, bluesrift@aol.com wrote:
> >Thanks for the info! After having read the perldoc discussion of $/ I
> >can see how efficient it is to use the technique above. However, I
> >remain uncertain exactly how to set $/ back to the default newline
> >afterwards. Is it as simple as $/ = "\n";
>
> A common idiom for this is:
>
> my $file = do {local $/; <FILE>};
>
> The "local" limits the scope of the change to the surrounding block.
> Since we give no explicit local value for $/, it defaults to undef.
>
> If the filehandle is known to be a regular file, the following idiom
> has been found to be even more efficient:
>
> read FILE, my $file, -s FILE;
>
> In practice, both ways are very fast, and while the second approach
> IMHO looks more readable, the first does have the advantage of working
> even for streams of unknown length.
A review of the previouslyposted analysis will show that the do{}
approach requires an extra copy of the value from within the block to
outside the block. So despite the neatness of that form, the following
is faster:
my $file;
{ local $/; $file = <FILE> }
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 9 May 2000 16:14:31 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Net::SMTP module question
Message-Id: <957888533.26145@itz.pp.sci.fi>
In article <39180aa1$0$25107@wodc7nh1.news.uu.net>, spurcell wrote:
>
>1. Does Net::SMTP allow for file attachments?
"Does this highway allow for sports utility vehicles?"
>2. And if it does, where do I find the documentation for doing it?
http://search.cpan.org/doc/ERYQ/MIME-Lite-1.144/lib/MIME/Lite.pm
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla and its pseudonyms - do not feed the troll.
------------------------------
Date: Tue, 09 May 2000 15:07:40 GMT
From: michelle <lum0509@hotmail.com>
Subject: Pattern Matching
Message-Id: <8f99je$8fq$1@nnrp1.deja.com>
This is sample codes that I've been struggling with:
#!perl
my ($label);
$label="60 Minutes II,60 Minutes II,Domestic,RealMedia 500
Kbps,ABC,English,The Americas,United States,North
America,3480,3600,7080,3600";
#$label="Minutes 60 II,Minutes 60 II,Domestic,RealMedia 500
Kbps,ABC,English,The Americas,United States,North
America,3480,3600,7080,3600";
if ( $label == /(.),(.),(.),(.),(.),(.),(.),(.),(.),(.),(.),(.),(.)/ )
{
print "match\n";
}
else
{
print "Not match\n";
}
1. I've got the output "Not match" for $label="60 Minutes..,...,..."
How should I modify my pattern matching expression so that it'll output
"match" for $label="60 Minutes...,...,..." ?
2. I've tried with $label = "Minutes 60,...,..." and it prints "match".
Thanks in advance for your help
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 9 May 2000 08:35:29 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Pattern Matching
Message-Id: <Pine.GSO.4.10.10005090830030.3921-100000@user2.teleport.com>
On Tue, 9 May 2000, michelle wrote:
> $label="60 Minutes II,60 Minutes II,Domestic,RealMedia 500
> Kbps,ABC,English,The Americas,United States,North
> America,3480,3600,7080,3600";
I think that that was probably one long (long!) line in your original
code.
> if ( $label == /(.),(.),(.),(.),(.),(.),(.),(.),(.),(.),(.),(.),(.)/ )
You don't want '==' in there. I'm pretty sure you meant '=~' instead. See
the perlop manpage.
That's a pretty ugly pattern - and since patterns are all ugly, that's
saying a lot! :-)
Perhaps you would be better off using split than that pattern, but it
really depends upon what you're trying to do.
Of course, '.' matches just one character at a time; to match more than
one, use a quantifier. The most common quantifiers are '+' and '*'.
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 09 May 2000 08:35:28 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Pattern Matching
Message-Id: <39183040.F8FE417C@vpservices.com>
michelle wrote:
>
> #$label="Minutes 60 II,Minutes 60 II,Domestic,RealMedia 500
> Kbps,ABC,English,The Americas,United States,North
> America,3480,3600,7080,3600";
>
> if ( $label == /(.),(.),(.),(.),(.),(.),(.),(.),(.),(.),(.),(.),(.)/ )
> {
> print "match\n";
> }
The == operator is for comparing numbers, I think you might mean =~
instead.
> 1. I've got the output "Not match" for $label="60 Minutes..,...,..."
> How should I modify my pattern matching expression so that it'll output
> "match" for $label="60 Minutes...,...,..." ?
Sorry, it's unclear to me what you are trying to do. You want to match
somthing that has a certain number of commas in it? Or match something
that starts with "60 Minutes" but not with "Minutes 60", or something
that contains either of those? You need to specify what you want in
English before we can help you specify it in Perl.
That label is in a standard format called CSV (Comma Separated Values)
format and there are many ways of dealing with it. If it is true CSV
then there may be some fields that have commas inside them, as well as
fields that have commas in between them. If you might have that
situation, then look in the section in perlfaq4 on that topic, or use
one of the modules aimed at handling that format of data
(Text::ParseWords, or DBD::CSV, or DBD::RAM).
If the data is always as simple as you show it, with no embedded commas,
then what you probabaly want is the split() function, not a regular
expression as you are trying. The split function takes a string and
turns it into an array.
my @array = split( /,/, $label); # creates an array from your string
print $#array; # tells how many fields are in the
array
print $ary[3]; # prints the fourth element in the
array
If this isn't helpful, ask again.
--
Jeff
------------------------------
Date: Tue, 9 May 2000 11:04:55 -0400
From: "Erick Jensen" <erick.jensen@unisys.com>
Subject: Re: Perl code to check for broken links
Message-Id: <8f99eo$l8e$1@mail.pl.unisys.com>
> Good idea. Ignore what the author of three of the top books on Perl has
> said is the proper way to go about it and invent something of your own
> without thinking about the consequences because thinking about the
> consequences is "too complicated". You will go far, my boy.
You again? You're comments are much appreciated. I'm glad we have people
like you helping us out. Newsgroups are helping people with problems, not
your personal commentary. If I wanted one of your idiot savant pearls of
wisdom, I'd ask for it.
Maybe "the author of three of the top books on Perl" should take a course of
commenting his code and using meaningful variable names (e.g., Hungarian
notation). Not to mention the use of jump labels. Ugly. Maybe then people
could follow it.
I just wanted something that would return whether a link is accesible or
not. LWP::Simple get() does that for me.
-Erick Jensen
"Jeff Zucker" <jeff@vpservices.com> wrote in message
news:3918255C.316D8FC4@vpservices.com...
>
> Erick Jensen wrote:
>
> > "Tom Phoenix" <rootbeer@redcat.com> wrote in message
> > news:Pine.GSO.4.10.10005081913530.3921-100000@user2.teleport.com...
> > >
> > > Randal has several, a few with some amazing features.
> > >
> > > http://www.stonehenge.com/merlyn/WebTechniques/
> > >
> >
> > Too complicated. I found something a lot easier:
>
> Good idea. Ignore what the author of three of the top books on Perl has
> said is the proper way to go about it and invent something of your own
> without thinking about the consequences because thinking about the
> consequences is "too complicated". You will go far, my boy.
>
> --
> Jeff
------------------------------
Date: 09 May 2000 08:22:37 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Perl code to check for broken links
Message-Id: <m1u2g7lpdu.fsf@halfdome.holdit.com>
>>>>> "Erick" == Erick Jensen <erick.jensen@unisys.com> writes:
Erick> Maybe "the author of three of the top books on Perl" should
Erick> take a course of commenting his code and using meaningful
Erick> variable names (e.g., Hungarian notation).
I've not written anything for public consumption that wasn't
extensively commented; for example, the code for all my columns comes
with (duh!) a column that extensively documents what each line does.
Perl variables are already strongly typed: you cannot store a hash in
an array, or an array in a scalar, so they have built-in Hungarian
notation.
Erick> Not to mention the use of jump labels. Ugly. Maybe then
Erick> people could follow it.
What do you mean "jump labels". Perl doesn't have "jumps".
But really, what was the purpose of your paragraph? Are you angry at
something? Someone? At me? What did you hope to accomplish by
saying that? Are you trying to vent so that you are no longer
obligated to feel the feelings you have? Or are you trying to attack
me? Or the original poster? If so, what is the purpose in that?
Curious. Wondering why the dynamics of this newsgroup work this way.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Tue, 9 May 2000 11:47:22 -0400
From: "Erick Jensen" <erick.jensen@unisys.com>
Subject: Re: Perl code to check for broken links
Message-Id: <8f9buc$nr6$1@mail.pl.unisys.com>
I'm sorry if I offended you. That wasn't my intention. It saddens me that
there are people out there who go into newsgroups just to look for people to
cut on (like the guy I replied to) rather than help people out. This
newsgroup seems to be plagued with people like that. I guess the internet
is not the place to look for civility.
My original post was for finding a simple function that returned whether a
link was good or if it returns a 404 Not found. I have a links database,
and something like this comes in real handy to test for dead links. 100
lines of code to execute for each of my 500+ links is not feasible.
By the way, I may be wrong but the following smells like a goto (jump)
statement:
MAINLOOP:
...
next MAINLOOP;
...
next MAINLOOP;
...
next MAINLOOP if $response->is_success; # ok
Perl is an ugly language to begin with, which is why I prefer to use
ASP/VBScript as do most large companies (have you noticed the asp extension
on a lot of your bookmarks?). I hope this little bit of truth doesn't
offend anyone.
No hard feelings.
-Erick Jensen
"Randal L. Schwartz" <merlyn@stonehenge.com> wrote in message
news:m1u2g7lpdu.fsf@halfdome.holdit.com...
> >>>>> "Erick" == Erick Jensen <erick.jensen@unisys.com> writes:
>
> Erick> Maybe "the author of three of the top books on Perl" should
> Erick> take a course of commenting his code and using meaningful
> Erick> variable names (e.g., Hungarian notation).
>
> I've not written anything for public consumption that wasn't
> extensively commented; for example, the code for all my columns comes
> with (duh!) a column that extensively documents what each line does.
>
> Perl variables are already strongly typed: you cannot store a hash in
> an array, or an array in a scalar, so they have built-in Hungarian
> notation.
>
> Erick> Not to mention the use of jump labels. Ugly. Maybe then
> Erick> people could follow it.
>
> What do you mean "jump labels". Perl doesn't have "jumps".
>
> But really, what was the purpose of your paragraph? Are you angry at
> something? Someone? At me? What did you hope to accomplish by
> saying that? Are you trying to vent so that you are no longer
> obligated to feel the feelings you have? Or are you trying to attack
> me? Or the original poster? If so, what is the purpose in that?
>
> Curious. Wondering why the dynamics of this newsgroup work this way.
>
> --
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777
0095
> <merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
> See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl
training!
------------------------------
Date: Tue, 09 May 2000 16:01:52 GMT
From: jerome@activeindexing.com (Jerome O'Neil)
Subject: Re: Perl code to check for broken links
Message-Id: <QDWR4.75$94.11735@news.uswest.net>
In article <8f9buc$nr6$1@mail.pl.unisys.com>,
"Erick Jensen" <erick.jensen@unisys.com> writes:
> Perl is an ugly language to begin with, which is why I prefer to use
> ASP/VBScript as do most large companies (have you noticed the asp extension
> on a lot of your bookmarks?).
To quote...
*boggle*
VB isn't ugly? Perl is quite an elegant language, IMO. VB looks to me
like a design by committee, where no one could agree on anything.
>I hope this little bit of truth doesn't
> offend anyone.
>
> No hard feelings.
------------------------------
Date: Tue, 09 May 2000 16:20:54 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Perl code to check for broken links
Message-Id: <391d3a28.26949335@news.skynet.be>
Erick Jensen wrote:
>I just wanted something that would return whether a link is accesible or
>not. LWP::Simple get() does that for me.
It will do more: it will fetch the entire page for you.
At least, try using LWP::Simple's Head() instead.
--
Bart.
------------------------------
Date: Tue, 09 May 2000 09:31:35 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Perl code to check for broken links
Message-Id: <39183D67.27DEDCB2@vpservices.com>
Erick Jensen wrote:
>
> It saddens me that
> there are people out there who go into newsgroups just to look for people to
> cut on (like the guy I replied to) rather than help people out.
I'm sorry if my response to you seemed snide. It wasn't, however, meant
to simply "cut on" you. You posted code which you claimed solved a
given problem. Your code overlooked many parts of the problem and
claimed to be just as good as the other solution that was posted. It is
not doing you or anyone else who might read your message a favor to
pretend that your choice was a wise one.
> I guess the internet is not the place to look for civility.
Well, I'd imagine that anywhere you go and tell people they "have a bug
up their ass" or address them as "Mr. Perl Guru" when they correct your
mistakes is not a good place to look for civility. I apologize for
responding in kind. I don't apologize for pointing out your mistakes
and I hope someday you can do the same for me. I make lots of mistakes
and one of the reasons I post in this newsgroup is so that people with
more experience than me can help spot them.
--
Jeff
------------------------------
Date: Tue, 9 May 2000 18:47:18 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Perl code to check for broken links
Message-Id: <Pine.GHP.4.21.0005091845270.2402-100000@hpplus03.cern.ch>
On Tue, 9 May 2000, Jerome O'Neil quotes a now-killfiled member of
the purltroll consortium saying:
> > Perl is an ugly language to begin with,
[...]
> >I hope this little bit of truth doesn't
> > offend anyone.
I'm glad that little bit of offence didn't have much truth in it.
------------------------------
Date: Tue, 9 May 2000 10:29:53 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Perl code to check for broken links
Message-Id: <MPG.1381eaefe0b1df4598aa2c@nntp.hpl.hp.com>
In article <391d3a28.26949335@news.skynet.be> on Tue, 09 May 2000
16:20:54 GMT, Bart Lateur <bart.lateur@skynet.be> says...
> Erick Jensen wrote:
>
> >I just wanted something that would return whether a link is accesible or
> >not. LWP::Simple get() does that for me.
>
> It will do more: it will fetch the entire page for you.
>
> At least, try using LWP::Simple's Head() instead.
With the understanding that -- if that fails -- you still have to try
the GET, because some servers won't respond to HEAD requests.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 09 May 2000 16:50:57 GMT
From: Joydip Chakladar <joydip_chaklader@my-deja.com>
Subject: Re: Please help cannot display REMOTE_HOST variable
Message-Id: <8f9fl9$fls$1@nnrp1.deja.com>
Thank you bart
I applied gethostbyaddr() to turn the IP Addresses in
domain name of Remote Host .
@bytes= split(/\./, $ENV{'REMOTE_ADDR'});
$packAddress=pack("C4",@bytes);
($temp1,$temp2,$temp3,$temp4)
=gethostbyaddr($packAddress,2);
print"<tr><td>REMOTE_ADDR</td><td><B>
$temp1,$temp2,$temp3,$temp4.
$ENV{'REMOTE_ADDR'}.</B></td></tr>";
this programme in the proxy is working fine and
turning the IP address 127.0.0.1 into localhost but it was not working
in my server .It is giving me blank values .
The online programme is
http://www.hitostat.com/cgi-bin/hit.pl
The programme content is in
http://www.hitostat.com/hit.html
Can anybody help me in this regard?
Thanks in advance
In article <391867b6.4746508@news.skynet.be>,
bart.lateur@skynet.be (Bart Lateur) wrote:
> joydip_chaklader@my-deja.com wrote:
>
> >I think server may not be configured to set the REMOTE_HOST variable
> >(it's a real drain on system resources to do a reverse DNS lookup for
> >every request). Now I am trying to use the REMOTE_ADDR variable
> >instead.
>
> Do the DNS lookup yourself. Perl even has a primitive for it:
> gethostbyaddr(). This one expects the address to be in packed format,
I
> think (a string of 4 bytes).
>
> --
> Bart.
>
--
Joydip Chakladar
http://www.allindialive.com
From India to world
A meeting place of surfers and webmasters
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 09 May 2000 16:39:44 GMT
From: Joydip Chakladar <joydip_chaklader@my-deja.com>
Subject: Please help me on displaying REMOTE_HOST through gethostaddr()
Message-Id: <8f9f0e$etp$1@nnrp1.deja.com>
I am just trying to display the REMOTE_HOST variable for my hit
statistics programme.Though the other enviroment variables are
displayed REMOTE_HOST is showing blank. By the suggestion of this
newsgroup I got a function
gethostbyaddr()
I applied it to turn the IP Addresses in domain name of Remote Host .
@bytes= split(/\./, $ENV{'REMOTE_ADDR'});
$packAddress=pack("C4",@bytes);
($temp1,$temp2,$temp3,$temp4) =gethostbyaddr($packAddress,2);
print"<tr><td>REMOTE_ADDR</td><td><B>
$temp1,$temp2,$temp3,$temp4. $ENV{'REMOTE_ADDR'}.</B></td></tr>";
this programme in the proxy is working fine and turning the IP address
127.0.0.1 into localhost but it was not working in my server .It is
giving me blank values .
My online programme is in
http://www.hitostat.com/cgi-bin/hit.pl
and the programme content is in
http://www.hitostat.com/hit.html
Can anybody help me in this regard?
Thanks in advance
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 09 May 2000 18:26:15 +0100
From: nobull@mail.com
Subject: Re: Please help me on displaying REMOTE_HOST through gethostaddr()
Message-Id: <u9ln1jiqiw.fsf@wcl-l.bham.ac.uk>
Joydip Chakladar <joydip_chaklader@my-deja.com> writes:
> I am just trying to display the REMOTE_HOST variable for my hit
> statistics programme.Though the other enviroment variables are
> displayed REMOTE_HOST is showing blank. By the suggestion of this
> newsgroup I got a function
>
> gethostbyaddr()
>
> I applied it to turn the IP Addresses in domain name of Remote Host .
>
> @bytes= split(/\./, $ENV{'REMOTE_ADDR'});
> $packAddress=pack("C4",@bytes);
> ($temp1,$temp2,$temp3,$temp4) =gethostbyaddr($packAddress,2);
It is more elegnt to use inet_aton() and AF_INET from the Socket
module as perl the documentation on gethostbyaddr().
It costs nothing to give your variables mnemonic names rather than
$temp1 and so on. Why are you doing a list assignment anyhow. Call
gethostbyaddr() in a scalar contect and you get just the name.
Always my() varables in the smallest sensible scope.
use Socket;
my $name = gethostbyaddr(inet_aton($ENV{'REMOTE_ADDR'}),AF_INET);
> this programme in the proxy is working fine and turning the IP address
> 127.0.0.1 into localhost but it was not working in my server .It is
> giving me blank values .
>
> My online programme is in
>
> http://www.hitostat.com/cgi-bin/hit.pl
Works fine for me when I connect to it.
Are you sure the problem is not simply that you are connecting from a
a host with no name listed in rDNS?
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 09 May 2000 17:00:13 GMT
From: Joydip Chakladar <joydip_chaklader@my-deja.com>
Subject: please help me to display REMOTE_HOST variable by gethostbyaddr
Message-Id: <8f9g6g$gbe$1@nnrp1.deja.com>
I am just trying to display the REMOTE_HOST variable for my hit
statistics programme.Though the other enviroment variables are
displayed REMOTE_HOST is showing blank. By the suggestion of this
newsgroup I got a
function
gethostbyaddr()
I applied it to turn the IP Addresses in domain name of Remote Host .
@bytes= split(/\./, $ENV{'REMOTE_ADDR'});
$packAddress=pack("C4",@bytes);
($temp1,$temp2,$temp3,$temp4) =gethostbyaddr($packAddress,2);
print"<tr><td>REMOTE_ADDR</td><td><B> $temp1,$temp2,$temp3,$temp4.
$ENV{'REMOTE_ADDR'}.</B></td></tr>";
this programme in the proxy is working fine and turning the IP address
127.0.0.1 into localhost
but it was not working in my server .It is giving me blank values .
My online programme is in
http://www.hitostat.com/cgi-bin/hit.pl
and the programme content is in
http://www.hitostat.com/hit.html
Can anybody help me in this regard?
Thanks in advance
Sent via Deja.com http://www.deja.com/
Before you buy.
--
Joydip Chakladar
http://www.allindialive.com
From India to world
A meeting place of surfers and webmasters
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 9 May 2000 10:15:51 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Printing Arrays
Message-Id: <MPG.1381e7a7b5fe36fe98aa2a@nntp.hpl.hp.com>
In article <8f8lag$i4a$1@nnrp1.deja.com> on Tue, 09 May 2000 09:21:30
GMT, Ilja <billy@arnis-bsl.com> says...
...
> Hm-m, why you need loop to print an array ?
>
> $, = "\n";
> print @block;
To produce the same output as the other attempts, that should be:
print @block, "\n";
And $, should be localized.
Yet another way:
{ local $" = "\n"; print "@block\n" }
That might be less efficient, though, because an implicit join() is
performed before calling print().
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 9 May 2000 13:29:56 -0400
From: "Cary Lewis" <cslewis@mobilecom.com>
Subject: semaphores under perl
Message-Id: <jMXR4.4568$Ip.152142@cac1.rdr.news.psi.ca>
I am trying to execute the following code:
#!/usr/bin/perl
use IPC::SysV qw(IPC_PRIVATE S_IRWXU IPC_CREAT IPC_NOWAIT);
use IPC::Semaphore;
$sem = new IPC::Semaphore(IPC_PRIVATE, 10, S_IRWXU | IPC_CREAT);
I am getting the following error:
semget not implemented at /usr/local/lib/perl5/5.00502/IPC/Semaphore.pm line
38.
Can someone suggest why that is?
------------------------------
Date: 09 May 2000 18:41:45 +0100
From: nobull@mail.com
Subject: Re: semaphores under perl
Message-Id: <u9itwnipt2.fsf@wcl-l.bham.ac.uk>
"Cary Lewis" <cslewis@mobilecom.com> writes:
> I am getting the following error:
>
> semget not implemented at /usr/local/lib/perl5/5.00502/IPC/Semaphore.pm line
> 38.
>
> Can someone suggest why that is?
Have you eleiminated the obvious i.e. your OS doesn't implement SysV
Semaphores?
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 9 May 2000 18:41:25 +0100
From: "Andy Chantrill" <andy@u2me3.com>
Subject: Re: signal trapper
Message-Id: <8f9ijh$gv7$1@neptunium.btinternet.com>
Nope -- the "Sorry, Dave, I can't do that.\n"; message has to be in its own
sub-routine ... that's mandatory :o)
I've been playing around with signal trapping for ages, and I've never been
able to get it work properly the way I'd like in a modular structure (see my
example). What I really need is a goto function that can leap out of the
signal_trapper sub-routine into the status sub-routine ...
Thanks, Andy.
andy@u2me3.com
------------------------------
Date: Tue, 9 May 2000 08:19:05 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: vec and bitwise or ?
Message-Id: <Pine.GSO.4.10.10005090811110.3921-100000@user2.teleport.com>
On Tue, 9 May 2000, Gerd Meier wrote:
> $rin = $win = $ein = 0;
> vec($rin,0,1) = 1;
> vec($win,1,1) = 1;
That's not the recommended way to use vec() - it works on bitstrings, not
on integers. You probably meant to initialize those three to the empty
string, not to the string "0".
> $ein = $rin | $win;
> print "$rin $win $ein\n";
This may be a bug in perl; I'm not sure. Maybe I'm overlooking something.
It looks to me as if vec() failed to clear out the (now-invalid) numeric
value of $rin and $win. That means that perl thinks that you're doing a
numeric (rather than bitwise) 'or' there. Worse, it's using the old values
of 0 for both.
If this still happens with 5.6.0, file a bug report with perlbug. Thanks!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 09 May 2000 16:13:09 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: vec and bitwise or ?
Message-Id: <391c384f.26476047@news.skynet.be>
Ala Qumsieh wrote:
>I think it's a bug. I can reproduce it with 5.005_03.
>If you manually set $rin to 1 and $win to 2, then $ein will be 3, as
>expected.
>
>Anybody have a better explanation?
I'd even say more: if I explicitely set $rin and $win AS STRINGS, it
still set $ein to 3 (or rather, to "3").
--
Bart.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 2992
**************************************