[28454] in Perl-Users-Digest
Perl-Users Digest, Issue: 9818 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Oct 7 14:10:19 2006
Date: Sat, 7 Oct 2006 11:10:09 -0700 (PDT)
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, 7 Oct 2006 Volume: 10 Number: 9818
Today's topics:
Re: Regex help for URL <tadmc@augustmail.com>
Re: Regex help for URL <solive@gmail.com>
Re: Script that shows IP address of a server. <nobull67@gmail.com>
Re: Script that shows IP address of a server. yankeeinexile@gmail.com
Re: Script that shows IP address of a server. <stan@invalid.blz/hmrprint/com.com>
Re: Script that shows IP address of a server. <stan@invalid.blz/hmrprint/com.com>
Re: Unique in-depth problem <notvalid@email.com>
unpack with offset (skip, X) won't work <wahab@chemie.uni-halle.de>
Re: unpack with offset (skip, X) won't work (reading news)
Re: unpack with offset (skip, X) won't work <wahab@chemie.uni-halle.de>
Re: Usenet and charsets (was: Re: LWP and Unicode) <bart@nijlen.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 7 Oct 2006 07:39:27 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Regex help for URL
Message-Id: <slrneif7vv.89h.tadmc@magna.augustmail.com>
Seb <solive@gmail.com> wrote:
> I am trying to find the right regular expression which would only
> validate a URL with a given number of folders.
> Basically, any URL not made of 4 slahes would be invalid.
A regular expression is not the Right Tool for counting characters,
tr/// is better for that (tr does NOT use any regular expressions).
print "$url is invalid\n" unless $url =~ tr#/## == 4; # untested
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 7 Oct 2006 10:35:29 -0700
From: "Seb" <solive@gmail.com>
Subject: Re: Regex help for URL
Message-Id: <1160242529.692540.13860@m73g2000cwd.googlegroups.com>
Thanks. I do need to use a regular expression since it is the only
mechanism I can use in the search engine I am using to enter a valid
exclusion.
Tad McClellan wrote:
> Seb <solive@gmail.com> wrote:
>
> > I am trying to find the right regular expression which would only
> > validate a URL with a given number of folders.
>
>
> > Basically, any URL not made of 4 slahes would be invalid.
>
>
> A regular expression is not the Right Tool for counting characters,
> tr/// is better for that (tr does NOT use any regular expressions).
>
> print "$url is invalid\n" unless $url =~ tr#/## == 4; # untested
>
>
> --
> Tad McClellan SGML consulting
> tadmc@augustmail.com Perl programming
> Fort Worth, Texas
------------------------------
Date: 7 Oct 2006 06:53:58 -0700
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: Script that shows IP address of a server.
Message-Id: <1160229238.042835.248000@m73g2000cwd.googlegroups.com>
On Oct 7, 1:34 pm, Blue <superb...@myjaring.net> wrote:
> Sorry about the confusion. I found the solution with PHP.
Oh, so your question wasn't related to Perl.
When an HTTP server executes server-side code (either embedded in a
templating system or standalone like GCI) then the contextual
information that the web server passes to the executable code typically
will incude the IP addresses of the local and remote ends of the TCP/IP
connection on which the HTTP request was received.
For example the GCI interface will populate environment variables.
Ob-perl: in Perl envirnment variables are presented as the hash %ENV.
However it is very hard to think of a use for this particular bit of
information other than perhaps in debugging some particularly obscure
networking issues. Given your apparent level of understanding I doubt
you are doing this.
So, I'm curious, what value do you think this information will be to
you?
------------------------------
Date: 07 Oct 2006 09:17:03 -0500
From: yankeeinexile@gmail.com
Subject: Re: Script that shows IP address of a server.
Message-Id: <87ac4843ds.fsf@gmail.com>
"Brian McCauley" <nobull67@gmail.com> writes:
> On Oct 7, 1:34 pm, Blue <superb...@myjaring.net> wrote:
>
> > Sorry about the confusion. I found the solution with PHP.
>
> Oh, so your question wasn't related to Perl.
>
> When an HTTP server executes server-side code (either embedded in a
> templating system or standalone like GCI) then the contextual
> information that the web server passes to the executable code typically
> will incude the IP addresses of the local and remote ends of the TCP/IP
> connection on which the HTTP request was received.
>
At the foundation, the OP's question was even more broken than
originally thought. He asked (looking upthread a few steps),
"I need a simple script that show the IP address of the server (where
the script is residing)"
At no point in the question did he mention any of the the clue words
"Web, HTTP, Apache, or CGI" which would have led to the (indeed
simple) solution he was looking for.
What he REALLY wanted to say was:
"I need to know the IP address of the server-side socket for a live
HTTP connection to a web server."
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Lawrence Statton - lawrenabae@abaluon.abaom s/aba/c/g
Computer software consists of only two components: ones and
zeros, in roughly equal proportions. All that is required is to
sort them into the correct order.
------------------------------
Date: Sat, 7 Oct 2006 09:36:20 -0700
From: "Stan R." <stan@invalid.blz/hmrprint/com.com>
Subject: Re: Script that shows IP address of a server.
Message-Id: <eg8l1v01e3j@news4.newsguy.com>
Brian McCauley wrote:
> On Oct 7, 1:34 pm, Blue <superb...@myjaring.net> wrote:
>
>> Sorry about the confusion. I found the solution with PHP.
>
> Oh, so your question wasn't related to Perl.
>
> When an HTTP server executes server-side code (either embedded in a
> templating system or standalone like GCI) then the contextual
> information that the web server passes to the executable code
> typically will incude the IP addresses of the local and remote ends
> of the TCP/IP connection on which the HTTP request was received.
>
> For example the GCI interface will populate environment variables.
>
> Ob-perl: in Perl envirnment variables are presented as the hash %ENV.
>
> However it is very hard to think of a use for this particular bit of
> information other than perhaps in debugging some particularly obscure
> networking issues. Given your apparent level of understanding I doubt
> you are doing this.
>
> So, I'm curious, what value do you think this information will be to
> you?
s/GCI/CGI/g; ?
--
Stan
------------------------------
Date: Sat, 7 Oct 2006 09:40:49 -0700
From: "Stan R." <stan@invalid.blz/hmrprint/com.com>
Subject: Re: Script that shows IP address of a server.
Message-Id: <eg8lab01efj@news4.newsguy.com>
yankeeinexile@gmail.com wrote:
> "Brian McCauley" <nobull67@gmail.com> writes:
>> On Oct 7, 1:34 pm, Blue <superb...@myjaring.net> wrote:
>>
>>> Sorry about the confusion. I found the solution with PHP.
>>
>> Oh, so your question wasn't related to Perl.
>>
>> When an HTTP server executes server-side code (either embedded in a
>> templating system or standalone like GCI) then the contextual
>> information that the web server passes to the executable code
>> typically will incude the IP addresses of the local and remote ends
>> of the TCP/IP connection on which the HTTP request was received.
>>
>
> At the foundation, the OP's question was even more broken than
> originally thought. He asked (looking upthread a few steps),
>
> "I need a simple script that show the IP address of the server (where
> the script is residing)"
>
> At no point in the question did he mention any of the the clue words
> "Web, HTTP, Apache, or CGI" which would have led to the (indeed
> simple) solution he was looking for.
>
> What he REALLY wanted to say was:
>
> "I need to know the IP address of the server-side socket for a live
> HTTP connection to a web server."
Actually, while he said he's used PHP in the end, PHP /is/ capable of
running outside of a web server, though I suppose in such case the
$SERVER variable wouldn't be valid anymore? Even so, I think this was a
little too "rush to judgment" esque, albeit not without reason.
--
Stan
------------------------------
Date: Sat, 07 Oct 2006 15:52:43 GMT
From: Ala Qumsieh <notvalid@email.com>
Subject: Re: Unique in-depth problem
Message-Id: <f3QVg.10579$e66.3840@newssvr13.news.prodigy.com>
Idgarad wrote:
> I originally did this via tables with colspans etc. but complicated
> entries with 800+ events in a month (I was only rendering a single
> year) could take up to 3 hours to display on a browser. SVG or Flash is
> gonna be needed.
Or javascript. Think of google maps.
--Ala
------------------------------
Date: Sat, 07 Oct 2006 18:51:18 +0200
From: Mirco Wahab <wahab@chemie.uni-halle.de>
Subject: unpack with offset (skip, X) won't work
Message-Id: <eg8m6r$jaq$1@mlucom4.urz.uni-halle.de>
Hi,
I try to extract NV from a binary string
which I created before. If I'm using the
same pack format as I used in the 'pack'
function, all works fine.
What I try to do is to get an offset
into the data vector by the 'X' modifier.
Myaybe thats not supported this way
and I have to use 'vec'?
Thanks
M.
==>
use strict;
use warnings;
# prepare a binary data block [ i j k l]
my $binstr = pack 'F7', 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0;
my ($a, $b, $c, $e, $f, $g, $h) = unpack 'F7', $binstr;
print "$a, $b, $c, $e, $f, $g, $h\n"; # <== o.k., fine
# try to skip the first three NV's from $binstr,
# and try to get the offsett to '4.0'
my ($i, $j, $k, $l) = unpack 'FX3F4', $binstr;
print "$i, $j, $k, $l\n"; # <= won't work!
------------------------------
Date: Sat, 07 Oct 2006 17:24:33 GMT
From: "Mumia W. (reading news)" <paduille.4059.mumia.w@earthlink.net>
Subject: Re: unpack with offset (skip, X) won't work
Message-Id: <lpRVg.6169$Y24.1287@newsread4.news.pas.earthlink.net>
On 10/07/2006 11:51 AM, Mirco Wahab wrote:
> Hi,
>
> I try to extract NV from a binary string
> which I created before. If I'm using the
> same pack format as I used in the 'pack'
> function, all works fine.
>
> What I try to do is to get an offset
> into the data vector by the 'X' modifier.
>
> Myaybe thats not supported this way
> and I have to use 'vec'?
>
> Thanks
>
> M.
>
> ==>
> use strict;
> use warnings;
>
> # prepare a binary data block [ i j k l]
> my $binstr = pack 'F7', 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0;
>
> my ($a, $b, $c, $e, $f, $g, $h) = unpack 'F7', $binstr;
> print "$a, $b, $c, $e, $f, $g, $h\n"; # <== o.k., fine
>
> # try to skip the first three NV's from $binstr,
> # and try to get the offsett to '4.0'
> my ($i, $j, $k, $l) = unpack 'FX3F4', $binstr;
my ($i, $j, $k, $l) = unpack 'x[F3]F4', $binstr;
> print "$i, $j, $k, $l\n"; # <= won't work!
The string "x[F3]" allows you to skip the number of bytes that would
make up three native floats.
--
Mumia W.
paduille.4059.mumia.w@earthlink.net
This is a temporary e-mail to help me catch some s-p*á/m.
------------------------------
Date: Sat, 07 Oct 2006 19:38:24 +0200
From: Mirco Wahab <wahab@chemie.uni-halle.de>
Subject: Re: unpack with offset (skip, X) won't work
Message-Id: <eg8ov6$k1c$1@mlucom4.urz.uni-halle.de>
Thus spoke Mumia W. (reading news) (on 2006-10-07 19:24):
> On 10/07/2006 11:51 AM, Mirco Wahab wrote:
>> my ($i, $j, $k, $l) = unpack 'FX3F4', $binstr;
>
> my ($i, $j, $k, $l) = unpack 'x[F3]F4', $binstr;
Thanks for your fast and correct response. Actually,
I read the perlpacktut and had already figured:
my ($i, $j, $k, $l) = unpack 'X[F3]F4', $binstr; # wrong try
(with a large 'X') and it, of course, didn't work and
so I dropped this strategy and throwed the gun away ...
> The string "x[F3]" allows you to skip the number of
> bytes that would make up three native floats.
Nice, now after I know that from you, I can
find the place where it is said in perlpacktut ... :-)
Regards & Thanks
Mirco
------------------------------
Date: 7 Oct 2006 08:10:37 -0700
From: "Bart Van der Donck" <bart@nijlen.com>
Subject: Re: Usenet and charsets (was: Re: LWP and Unicode)
Message-Id: <1160233837.748037.247220@e3g2000cwe.googlegroups.com>
Dr.Ruud wrote:
> [...]
> In practice there is no problem with headers like
> "Content-Type: text/plain; charset=ISO-8859-1"
> because most readers deal with them as expected.
>
> Henry Spencer once (1994) created the Son-of-RFC-1036:
> http://www.chemie.fu-berlin.de/outerspace/netnews/son-of-1036.html
> to document the state of that moment, and stated MIME as relevant for
> news articles.
>
> See also USEFOR, the Grandson-of-RFC-1036:
> http://www.ietf.org/html.charters/usefor-charter.html
> ("an urgent need has been identified to formalize and document
> many of the current and proposed extensions to the Usenet
> Article format")
I think the current situation is about like this:
One can safely use ASCII on Usenet with or without a charset header.
One can safely use ISO-8859-1, but only when specifying it in the
header.
Other charsets work when supported, but should be used carefully
depending on the circumstances. For example, on a Russian discussion
group it's reasonable to use KOI8-R. But one should obviously always
specify the charset in such cases.
I think one should not rely on any Unicode charset on Usenet (yet).
Google Groups deals with this issue as follows:
(1) Default to ISO-8859-1 when possible, yes even with plain ASCII.
(2) Use custom charset if the offered characters can unambiguously be
represented in that charset and if ISO-8859-1 is too narrow; perhaps
also considering browser settings/preferences.
(3) Use UTF-8 if the above fails; I suppose mostly in charset
combinations, 'tricky' replies or really exotic stuff.
A good policy, IMO.
--
Bart
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 V10 Issue 9818
***************************************