[28116] in Perl-Users-Digest
Perl-Users Digest, Issue: 9480 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jul 16 11:05:49 2006
Date: Sun, 16 Jul 2006 08:05:05 -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 Sun, 16 Jul 2006 Volume: 10 Number: 9480
Today's topics:
A simply regex question <franzl.wisseworst@mailinator.net>
Re: A simply regex question <mritty@gmail.com>
Re: A simply regex question <rvtol+news@isolution.nl>
Re: A simply regex question <franzl.wisseworst@mailinator.net>
Re: A simply regex question <franzl.wisseworst@mailinator.net>
Re: A simply regex question <jurgenex@hotmail.com>
About 2D array? <zhushenli@gmail.com>
Re: About 2D array? <anfi@onet.eu>
Re: About 2D array? <mritty@gmail.com>
Can I compare array with array? <zhushenli@gmail.com>
Re: Can I compare array with array? <mritty@gmail.com>
Re: Can I compare array with array? <bart@nijlen.com>
Re: Can I compare array with array? <1usa@llenroc.ude.invalid>
Re: Can I compare array with array? <jurgenex@hotmail.com>
Re: How get UTF-8 from urlencoded web form <ynleder@nspark.org>
Re: How get UTF-8 from urlencoded web form <ynleder@nspark.org>
Re: How get UTF-8 from urlencoded web form <bart@nijlen.com>
Re: How get UTF-8 from urlencoded web form <bart@nijlen.com>
Re: How get UTF-8 from urlencoded web form <1usa@llenroc.ude.invalid>
How to local-ly close a handle? <socyl@987jk.com.invalid>
how to sort a array? roland.yan@gmail.com
Re: how to sort a array? <mritty@gmail.com>
Re: how to sort a array? <rvtol+news@isolution.nl>
Re: how to sort a array? <jurgenex@hotmail.com>
Perl equivalent of this script? <george.varsamopoulos@gmail.com>
Re: Perl equivalent of this script? <1usa@llenroc.ude.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 16 Jul 2006 13:11:26 +0200
From: Franzl Wisseworst <franzl.wisseworst@mailinator.net>
Subject: A simply regex question
Message-Id: <e9d7pb$dlt$02$1@news.t-online.com>
How can I figure if my DOCUMENT_URI contains a substring, eg.:
if ($ENV{"DOCUMENT_URI"} contains string "mein.totenkopf.de"){
do something...;
}
And is there a way to ignore case, so the substring could be
"mein.totenkopf.de" or "MEIN.TOTENKOPF.DE" for example?
The purpose is to identify if the only the base domain or sub-domain is
being accessed. The reason I'd like to utilise DOCUMENT_URI rather than
REMOTE_HOST or some other domain specific string is because it should work
on a local machine too, where all content is mirorred, but where
REMOTE_HOST is always localhost. This should work in both environments
because the full domain substring exist as a directory name in both cases.
Many thanks for any tips.
------------------------------
Date: 16 Jul 2006 04:51:25 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: A simply regex question
Message-Id: <1153050685.826559.255420@i42g2000cwa.googlegroups.com>
Franzl Wisseworst wrote:
> How can I figure if my DOCUMENT_URI contains a substring, eg.:
>
> if ($ENV{"DOCUMENT_URI"} contains string "mein.totenkopf.de"){
> do something...;
> }
>
> And is there a way to ignore case, so the substring could be
> "mein.totenkopf.de" or "MEIN.TOTENKOPF.DE" for example?
This is not meant to sound rude, but if you have to ask this question,
then you haven't read even a decent tutorial on Perl yet. You should
do so. Open a command line, and type "perldoc perlintro".
Pay attention to the part on "pattern matching" and/or "regular
expressions".
Paul Lalli
------------------------------
Date: Sun, 16 Jul 2006 14:00:19 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: A simply regex question
Message-Id: <e9dgq7.1c8.1@news.isolution.nl>
Franzl Wisseworst schreef:
Your subject has no quality. Please come up with something like
"How to detect substring?"
> How can I figure if my DOCUMENT_URI contains a substring
perldoc -f index
> And is there a way to ignore case
perldoc -f lc
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: Sun, 16 Jul 2006 14:26:35 +0200
From: Franzl Wisseworst <franzl.wisseworst@mailinator.net>
Subject: Re: A simply regex question
Message-Id: <e9dc67$3fi$01$1@news.t-online.com>
[..]
> This is not meant to sound rude, but if you have to ask this question,
Too true, and not rude at all.
> then you haven't read even a decent tutorial on Perl yet. You should
I have, but forgotten ....
------------------------------
Date: Sun, 16 Jul 2006 14:28:24 +0200
From: Franzl Wisseworst <franzl.wisseworst@mailinator.net>
Subject: Re: A simply regex question
Message-Id: <e9dc9l$3fi$01$2@news.t-online.com>
Dr.Ruud wrote:
[..]
> perldoc -f lc
Thanks for those tips.
------------------------------
Date: Sun, 16 Jul 2006 14:11:50 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: A simply regex question
Message-Id: <GOrug.5127$k31.4695@trnddc06>
Franzl Wisseworst wrote:
[Subject: A simply regex question]
Your task can better be solved without using a RE.
> How can I figure if my DOCUMENT_URI contains a substring, eg.:
perldoc -f index
> And is there a way to ignore case, so the substring could be
> "mein.totenkopf.de" or "MEIN.TOTENKOPF.DE" for example?
You normalize both strings before searching, e.g. make both all lower-case,
see
perldoc -f lc
jue
------------------------------
Date: 16 Jul 2006 04:29:52 -0700
From: "Davy" <zhushenli@gmail.com>
Subject: About 2D array?
Message-Id: <1153049392.655017.206460@75g2000cwc.googlegroups.com>
Hi,
I want to use 2D array in Perl.
For example, @a = (1,2,3); @b = (1,2,4,5);
When I use @c = (@a,@b); @c is stored as a 1D array.
But I want a array can be accessed by $c[i][j],
Can I do 2D array in Perl?
Thanks!
Davy
------------------------------
Date: Sun, 16 Jul 2006 13:42:23 +0200
From: Andrzej Adam Filip <anfi@onet.eu>
Subject: Re: About 2D array?
Message-Id: <8764hx93og.fsf@anfi.homeunix.net>
"Davy" <zhushenli@gmail.com> writes:
> Hi,
>
> I want to use 2D array in Perl.
> For example, @a = (1,2,3); @b = (1,2,4,5);
> When I use @c = (@a,@b); @c is stored as a 1D array.
>
> But I want a array can be accessed by $c[i][j],
> Can I do 2D array in Perl?
Keep references to arrays in @a.
@a = (1,2,3); @b = (1,2,4,5);
@c = ([@a],[@b]);
print $c[1][3];
--
[pl2en: Andrew] Andrzej Adam Filip : anfi@priv.onet.pl : anfi@xl.wp.pl
http://anfi.homeunix.net/
------------------------------
Date: 16 Jul 2006 04:57:22 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: About 2D array?
Message-Id: <1153051042.825578.216880@s13g2000cwa.googlegroups.com>
Davy wrote:
> I want to use 2D array in Perl.
Technically, Perl doesn't have two-dimensional arrays. What it does
have is arrays of array references, which function much like 2d arrays
in other languages.
> For example, @a = (1,2,3); @b = (1,2,4,5);
> When I use @c = (@a,@b); @c is stored as a 1D array.
Yes it is, just as the documentation (perldoc perldata) says will
happen.
> But I want a array can be accessed by $c[i][j],
> Can I do 2D array in Perl?
You can simulate it, using array references. Please read:
perldoc perlreftut
perldoc perllol
Paul Lalli
------------------------------
Date: 16 Jul 2006 04:30:48 -0700
From: "Davy" <zhushenli@gmail.com>
Subject: Can I compare array with array?
Message-Id: <1153049448.843547.320130@h48g2000cwc.googlegroups.com>
Hi,
If I have two array, like @a = (1,2,3); @b = (1,2,4);
Can I use if(@a==@b) directly?
Thanks!
Davy
------------------------------
Date: 16 Jul 2006 04:49:33 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Can I compare array with array?
Message-Id: <1153050573.577885.310280@m73g2000cwd.googlegroups.com>
Davy wrote:
> If I have two array, like @a = (1,2,3); @b = (1,2,4);
> Can I use if(@a==@b) directly?
What happened when you tried it?
You may be interested in the Array::Compare module on CPAN:
http://search.cpan.org/~davecross/Array-Compare-1.13/lib/Array/Compare.pm
Paul Lalli
------------------------------
Date: 16 Jul 2006 07:48:20 -0700
From: "Bart Van der Donck" <bart@nijlen.com>
Subject: Re: Can I compare array with array?
Message-Id: <1153061300.577609.326490@m79g2000cwm.googlegroups.com>
Davy wrote:
> If I have two array, like @a = (1,2,3); @b = (1,2,4);
> Can I use if(@a==@b) directly?
You can use that check only to find out whether the number of elements
in both arrays are the same, and _not_ whether their values match.
But it's better practice to do
if ( $#a == $#b ) { ... }
(and better practice to not use $a and $b as variable names, because
they could have a special meaning)
Hope this helps,
--
Bart
------------------------------
Date: Sun, 16 Jul 2006 14:56:23 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Can I compare array with array?
Message-Id: <Xns98026F61EC2B7asu1cornelledu@127.0.0.1>
"Bart Van der Donck" <bart@nijlen.com> wrote in
news:1153061300.577609.326490@m79g2000cwm.googlegroups.com:
> Davy wrote:
>
>> If I have two array, like @a = (1,2,3); @b = (1,2,4);
>> Can I use if(@a==@b) directly?
>
> You can use that check only to find out whether the number of elements
> in both arrays are the same, and _not_ whether their values match.
>
> But it's better practice to do
>
> if ( $#a == $#b ) { ... }
Why?
> (and better practice to not use $a and $b as variable names,
But he is not using those names.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: Sun, 16 Jul 2006 14:59:30 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Can I compare array with array?
Message-Id: <mvsug.3652$A8.3506@trnddc02>
Bart Van der Donck wrote:
> Davy wrote:
>
>> If I have two array, like @a = (1,2,3); @b = (1,2,4);
>> Can I use if(@a==@b) directly?
[...]
> But it's better practice to do
>
> if ( $#a == $#b ) { ... }
I disagree. Why should that be better?
Ususally the $# notation should be used when you are explicitely looking for
the index while scalar() should be used when you are looking for the size.
> (and better practice to not use $a and $b as variable names, because
> they could have a special meaning)
But he's using @a and @b, which have nothing to do with $a and $b
jue
------------------------------
Date: Sun, 16 Jul 2006 13:17:33 +0200
From: Yohan N. Leder <ynleder@nspark.org>
Subject: Re: How get UTF-8 from urlencoded web form
Message-Id: <MPG.1f243eb6507c521198988c@news.tiscali.fr>
In article <4ht6euF16u6mU1@individual.net>, noreply@gunnar.cc says...
> Excellent learning approach.
Thanks. Better than taking everything as an eternal mysterious box in my
mind.
> The browser automatically URI escapes 'unsafe' characters when you make
> a GET or an x-www-form-urlencoded POST request. Hence those characters
> need to be unescaped by the web server. CGI.pm as well as other modules
> for parsing CGI data takes care of that.
>
Hm, understood !
> You can study the docs for the Perl module URI::Escape for a better
> explanation.
I'll do it for sure ;-)
------------------------------
Date: Sun, 16 Jul 2006 13:19:13 +0200
From: Yohan N. Leder <ynleder@nspark.org>
Subject: Re: How get UTF-8 from urlencoded web form
Message-Id: <MPG.1f243f1ea06569db98988d@news.tiscali.fr>
In article <1153042906.092292.33600@m73g2000cwd.googlegroups.com>,
bart@nijlen.com says...
> That shouldn't be particularly mysterious. You're specifying the page's
> charset as UTF-8 in its header (where you say "Content-type: text/html;
> charset=UTF-8"), causing the 'é'- character to be sent as Unicode's
> literal 'é'
>
Effectively what I want. However the gunnar explanation show the key of
the problem : URI escaping when *urlencoded* enctype for form.
------------------------------
Date: 16 Jul 2006 04:47:43 -0700
From: "Bart Van der Donck" <bart@nijlen.com>
Subject: Re: How get UTF-8 from urlencoded web form
Message-Id: <1153050463.349171.239300@i42g2000cwa.googlegroups.com>
Yohan N. Leder wrote:
> In article <1153042906.092292.33600@m73g2000cwd.googlegroups.com>,
> bart@nijlen.com says...
> > That shouldn't be particularly mysterious. You're specifying the page's
> > charset as UTF-8 in its header (where you say "Content-type: text/html;
> > charset=3DUTF-8"), causing the '=E9'- character to be sent as Unicode's
> > literal '=C3=A9'
>
> Effectively what I want. However the gunnar explanation show the key of
> the problem : URI escaping when *urlencoded* enctype for form.
Yes, the URL encoding is done at the browser's side by default, before
and apart from the sendout of the name/value pairs. This behaviour can
be altered by adding enctype=3D"multipart/form-data" as an extra argument
to <form method=3D"post">. The main reason for this feature to exist, is
the transfer of (binary) files to the gateway software on the server.
Thus, if you want to send '=E9', the browser will pass it as "%E9" by
default. It's up to your Perl script to decode it back to '=E9'. In the
multipart/form-data encoding type, '=E9' is just passed as '=E9'. In
UTF-8 sets, the browser looks for the literal equivalent of '=E9', and
then passes the URL-encoded value of that literal equivalent.
--=20
Bart
------------------------------
Date: 16 Jul 2006 07:26:37 -0700
From: "Bart Van der Donck" <bart@nijlen.com>
Subject: Re: How get UTF-8 from urlencoded web form
Message-Id: <1153059997.107490.105260@m73g2000cwd.googlegroups.com>
Gunnar Hjalmarsson wrote:
> [...]
> The browser automatically URI escapes 'unsafe' characters when you make
> a GET or an x-www-form-urlencoded POST request. Hence those characters
> need to be unescaped by the web server. CGI.pm as well as other modules
> for parsing CGI data takes care of that.
#!/usr/bin/pedant
I think the correct terminology is actually URL-encoding here (or
percent-encoding) in stead of URI-escaping
(http://en.wikipedia.org/wiki/URL_encoding).
--
Bart
------------------------------
Date: Sun, 16 Jul 2006 14:45:30 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: How get UTF-8 from urlencoded web form
Message-Id: <Xns98026D8902A44asu1cornelledu@127.0.0.1>
"Bart Van der Donck" <bart@nijlen.com> wrote in
news:1153059997.107490.105260@m73g2000cwd.googlegroups.com:
> Gunnar Hjalmarsson wrote:
>
>> [...]
>> The browser automatically URI escapes 'unsafe' characters when you
>> make a GET or an x-www-form-urlencoded POST request. Hence those
>> characters need to be unescaped by the web server. CGI.pm as well as
>> other modules for parsing CGI data takes care of that.
>
> #!/usr/bin/pedant
> I think the correct terminology is actually URL-encoding here (or
> percent-encoding) in stead of URI-escaping
> (http://en.wikipedia.org/wiki/URL_encoding).
Escaping is a general method of changing the meaning of the characters
following a designated special character. In this case, % is the special
character, and it changes the meaning of the characters following it.
Characters not allowed in URIs are replaced with these escape sequences.
See also http://search.cpan.org/dist/URI/URI/Escape.pm
The usage of 'escape' in this context is well established enough that a
'correction' does not seem warranted.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: Sun, 16 Jul 2006 13:57:29 +0000 (UTC)
From: kj <socyl@987jk.com.invalid>
Subject: How to local-ly close a handle?
Message-Id: <e9dgk9$r2r$1@reader2.panix.com>
One would think that one of the few good uses left for the keyword
"local" would be to "local-ly" close an open handle, like this:
my $status;
{
local *STDERR;
$status = system 'crazystuff';
}
die "can't do crazystuff!: $?" unless $status == 0;
But NOOOOO! The above fails to silence STDERR. If one attempts
a "close STDERR" after the "plain" local statement shown above,
one gets an error about attempting to close an unopened handle.
If then one tries this:
my $status;
{
local *STDERR = *STDERR; close STDERR;
$status = system 'crazystuff';
}
die "can't do crazystuff!: $?" unless $status == 0;
...then STDERR *is* finally silenced, but it *remains* silenced outside
of the block (e.g. the message from the die statement doesn't show);
i.e. the closing is not localized.
I know of ways to temporarily silence STDERR that actually work,
but none of them begins to approach the simplicity of any of the
examples above. Any suggestions?
TIA!
kj
--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
------------------------------
Date: 16 Jul 2006 03:57:20 -0700
From: roland.yan@gmail.com
Subject: how to sort a array?
Message-Id: <1153047440.313985.55780@m73g2000cwd.googlegroups.com>
Dear Perl friend,
I have a string array, for example @SampleArray, with the date and time
stamp included.
X2819460047100D,13/07/2006 23:50:39,OK,MC8775,R0-0-9,0.983,
X2819460016100D,13/07/2006 21:4:2,OK,MC8775,R0-0-9,0.672,
X2819460027100D,13/07/2006 23:52:39,OK,MC8775,R0-0-9,0.736,
X2819460072100D,13/07/2006 23:54:35,OK,MC8775,R0-0-9,0.825,
X2819460072100D,13/07/2006 23:56:37,OK,MC8775,R0-0-9,0.952,
.......
.......
Two question I have.
1. How to sort the array based on the date and time stamp.
2. then check the occurence based on the first field, like
'X2819460047100D'.
then push the first occurence into @1stOcc and push second occurance
into @2ndOcc.
not sure is it clear?
Appreciate your help.
Roland
------------------------------
Date: 16 Jul 2006 04:55:10 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: how to sort a array?
Message-Id: <1153050910.835111.316700@75g2000cwc.googlegroups.com>
roland.yan@gmail.com wrote:
> I have a string array, for example @SampleArray, with the date and time
> stamp included.
>
> X2819460047100D,13/07/2006 23:50:39,OK,MC8775,R0-0-9,0.983,
> X2819460016100D,13/07/2006 21:4:2,OK,MC8775,R0-0-9,0.672,
> X2819460027100D,13/07/2006 23:52:39,OK,MC8775,R0-0-9,0.736,
> X2819460072100D,13/07/2006 23:54:35,OK,MC8775,R0-0-9,0.825,
> X2819460072100D,13/07/2006 23:56:37,OK,MC8775,R0-0-9,0.952,
> .......
> .......
>
>
> Two question I have.
> 1. How to sort the array based on the date and time stamp.
What have you tried so far? Have you checked the Perl FAQ?
$ perldoc -q sort
Found in /software/perl-5.8.5-0/pkg/lib/5.8.5/pod/perlfaq4.pod
How do I sort an array by (anything)?
You may also be interested in CPAN modules like Date::Manip or
Regexp::Common::time
> 2. then check the occurence based on the first field, like
> 'X2819460047100D'.
> then push the first occurence into @1stOcc and push second occurance
> into @2ndOcc.
>
> not sure is it clear?
No, it's not. So if you're not sure it's clear, why didn't you make it
clear to begin with? The first occurrence of *what*? You've posted
your sample input. That's good. But why not make it clear by also
posting your desired output? Also, please include your best attempt at
solving your problem, so we can help you correct it.
Paul Lalli
------------------------------
Date: Sun, 16 Jul 2006 14:25:22 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: how to sort a array?
Message-Id: <e9diei.ic.1@news.isolution.nl>
roland.yan@gmail.com schreef:
"How to sort an array?" See `perldoc -f sort`.
> I have a string array, for example @SampleArray, with the date and
> time stamp included.
>
> X2819460047100D,13/07/2006 23:50:39,OK,MC8775,R0-0-9,0.983,
> X2819460016100D,13/07/2006 21:4:2,OK,MC8775,R0-0-9,0.672,
> X2819460027100D,13/07/2006 23:52:39,OK,MC8775,R0-0-9,0.736,
> X2819460072100D,13/07/2006 23:54:35,OK,MC8775,R0-0-9,0.825,
> X2819460072100D,13/07/2006 23:56:37,OK,MC8775,R0-0-9,0.952,
You effectively want to isolate the first two of a group. For an
undisclosed reason you have decided that you want to use an array for
that.
You need to sort the data, on column 1+2, but your column 2 contains
strange time value representations, so you better fix those first.
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: Sun, 16 Jul 2006 14:18:43 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: how to sort a array?
Message-Id: <7Vrug.5129$k31.4174@trnddc06>
roland.yan@gmail.com wrote:
> Dear Perl friend,
> I have a string array, for example @SampleArray, with the date and
> time stamp included.
>
> X2819460047100D,13/07/2006 23:50:39,OK,MC8775,R0-0-9,0.983,
> X2819460016100D,13/07/2006 21:4:2,OK,MC8775,R0-0-9,0.672,
> X2819460027100D,13/07/2006 23:52:39,OK,MC8775,R0-0-9,0.736,
> X2819460072100D,13/07/2006 23:54:35,OK,MC8775,R0-0-9,0.825,
> X2819460072100D,13/07/2006 23:56:37,OK,MC8775,R0-0-9,0.952,
> .......
> .......
>
>
> Two question I have.
> 1. How to sort the array based on the date and time stamp.
You use the Perl sort() function, see perldoc -f sort.
> 2. then check the occurence based on the first field, like
> 'X2819460047100D'.
> then push the first occurence into @1stOcc and push second occurance
> into @2ndOcc. not sure is it clear?
No, it is not, at least not to me.
jue
------------------------------
Date: 16 Jul 2006 07:38:43 -0700
From: "george.varsamopoulos@gmail.com" <george.varsamopoulos@gmail.com>
Subject: Perl equivalent of this script?
Message-Id: <1153060723.189213.297850@35g2000cwc.googlegroups.com>
I have a collection of perl scripts to manipulate HTML documents and
extract information.
However, i didn't find any short and easy way in Perl to download a
HTML file and save it locally.
For that reason I use the following php script:
<?php
$url = "http://yes.yes.yes/?arg=".$argv[1];
if (($ff = fopen($url, "r"))==NULL) exit();
while (!feof($ff)){
$line = fgets($ff,512);
printf("%s", $line);
}
fclose($ff);
?>
The ease with php is that I can fopen a URL, read it and save it (or
print it to stdout)
like a regular file.
the QUESTION is:
## Is there a short Perl script to replace this PHP script? ##
Any suggestions are welcome
-- George
P.S. I am mainly asking because this is the only part of the script
collection not written in Perl;
using a perl version I could compact the scripts into one.
------------------------------
Date: Sun, 16 Jul 2006 14:55:25 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Perl equivalent of this script?
Message-Id: <Xns98026F37D4C06asu1cornelledu@127.0.0.1>
"george.varsamopoulos@gmail.com" <george.varsamopoulos@gmail.com> wrote
in news:1153060723.189213.297850@35g2000cwc.googlegroups.com:
> For that reason I use the following php script:
>
> <?php
> $url = "http://yes.yes.yes/?arg=".$argv[1];
> if (($ff = fopen($url, "r"))==NULL) exit();
> while (!feof($ff)){
> $line = fgets($ff,512);
> printf("%s", $line);
> }
> fclose($ff);
> ?>
First, as in C, it looks like using feof in the while condition is not a
good idea:
http://us2.php.net/manual/en/function.feof.php
The comp.lang.c FAQ list explains it better:
http://c-faq.com/stdio/feof.html
> The ease with php is that I can fopen a URL, read it and save it (or
> print it to stdout) like a regular file.
I'll take your word for it.
> the QUESTION is:
> ## Is there a short Perl script to replace this PHP script? ##
perldoc -q "How do I fetch an HTML file?"
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
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 9480
***************************************