[16893] in Perl-Users-Digest
Perl-Users Digest, Issue: 4305 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 12 21:10:35 2000
Date: Tue, 12 Sep 2000 18:10:21 -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: <968807421-v9-i4305@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 12 Sep 2000 Volume: 9 Number: 4305
Today's topics:
Re: Passing hashes to a function <g.soper@soundhouse.co.uk>
Re: Perl substraction weird result <mischief@motion.net>
Re: Perl vs. Java or C++ <mischief@motion.net>
Re: Please help me with my shotty code... <epost1@my-deja.com>
Re: Problem getting unix "jobs" output with backticks <garry@zvolve.com>
Re: problem with hashes (Abigail)
Re: Qualifications for new Perl programmer????? (Eric Bohlman)
Re: Qualifications for new Perl programmer????? <elephant@squirrelgroup.com>
returning a tied variable <thomharp@flash.net>
Re: Running external programs and grabbing the output tltt@my-deja.com
Re: Running external programs and grabbing the output <elephant@squirrelgroup.com>
Re: Running external programs and grabbing the output (Gwyn Judd)
Silly grep tricks <kj0@mailcity.com>
Re: Silly grep tricks <jeffp@crusoe.net>
Re: Silly grep tricks <elephant@squirrelgroup.com>
Re: Test Your Perl Skills (Tony L. Svanstrom)
Re: timeout (Charles DeRykus)
Re: Where Doesn't this work? <godzilla@stomp.stomp.tokyo>
Re: Where Doesn't this work? <Cheng3@email.msn.com>
Re: Where Doesn't this work? <newsposter@cthulhu.demon.nl>
Re: Where Doesn't this work? <Cheng3@email.msn.com>
Re: Where Doesn't this work? <Cheng3@email.msn.com>
Re: Where Doesn't this work? <jeffp@crusoe.net>
Re: Where Doesn't this work? <All@n.Due.net>
Re: Where Doesn't this work? <elephant@squirrelgroup.com>
Re: Where Doesn't this work? <godzilla@stomp.stomp.tokyo>
Re: Where Doesn't this work? (Gwyn Judd)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 12 Sep 2000 23:41:12 +0100
From: Geoff Soper <g.soper@soundhouse.co.uk>
Subject: Re: Passing hashes to a function
Message-Id: <49fd16910dg.soper@soundhouse.co.uk>
In article <39be76fe@news.victoria.tc.ca>,
Malcolm Dew-Jones <yf110@vtn1.victoria.tc.ca> wrote:
> recommended reading
> perldoc perlsub (DESCRIPTION para. 2)
> and
> perldoc perlref
> You need to use something like
> print_edit_form("ammend",\%mod_users,\%old_users);
> (note the \'s)
> and then inside the function the hashes must use the $hash-> notation
> (sometimes you might have to add braces as well as adding a -> )
OK, I've read the relavent chapter in "Programming Perl" (there's little
in "Learning Perl") but I feel don't really understand the concept of
references. What do I do in my case to the hashes inside the function i.e.
in the four different occurances of the %form_data hash as illustrated in
the four extracts below?
my ($action,%form_data,%hidden_form_data)= @_;
foreach $user ( keys %form_data ) {
if ($form_data{$user}{"status"} eq "live") {
<input type="hidden" name="data:$user:user"
value="$form_data{$user}{"user"}">$user</td>
I hope this makes sense!
Thanks in advance!
--
Geoff Soper
g.soper@soundhouse.co.uk
Take a look at the Soundhouse page http://www.soundhouse.co.uk/
------------------------------
Date: Tue, 12 Sep 2000 17:17:30 -0500
From: "Chris Stith" <mischief@motion.net>
Subject: Re: Perl substraction weird result
Message-Id: <srtapg6ict6135@corp.supernews.com>
"Randy" <randy_734@my-deja.com> wrote in message
news:39bd1b78.15554046@207.126.101.100...
> This doesn't have anything to do with Perl, any computer language
> would do the same. It is a result of how the data is stored in the
> computer.
Sorry to kick the dead horse and also to pick nits, but more accurately, any
computer language that uses the hardware representation for floating-point
numbers on a twos-complement machine (consequently, any machine in common
use) would do the same.
There are more exact ways of representing base-10 fractions in a language.
Perl doesn't use them, for a number of reasons. These could include speed,
compatibility with C/C++, smoother implementation, etc. There are languages
that do arbitrary precision mathematics, and I believe (although I've never
needed to use them) that there are modules for Perl to handle
arbitrary-precision mathematics, too - or at least much more precise number
representations than the machine supports in hardware.
Chris
--
Chris Stith
mischief@pikenet.net
------------------------------
Date: Tue, 12 Sep 2000 18:04:51 -0500
From: "Chris Stith" <mischief@motion.net>
Subject: Re: Perl vs. Java or C++
Message-Id: <srtdhs3vct6183@corp.supernews.com>
<rathmore@tierceron.com> wrote in message
news:8pm3gv$clj$1@nnrp1.deja.com...
> I'm at an important decision in my career. I need to decide where to
> focus my learning as far as languages go. I took 2 years of C++ in
[snip]
Don't make a narrow decision. Learn several languages. You'll be glad you
did. You'll be a better programmer for it.
> My question is, should I continue to learn Perl? Is the demand for Perl
> programmers high? Higher than Java or C++? What types of projects could
> a good Perl program look forward to working on, vs. those for Java or
> C++ programmers?
I haven't had oodles of luck finding permanent jobs for programming in Perl
alone, although the freelance and consulting market for Perl programmers
seems strong.
You will probably find, though, that many - probably most - jobs listed for
C/C++ or Java programmers want you to also know at least some Perl and maybe
even one or more shell languages. You may even be asked to know sed or awk.
I've found that many programming ads ask that you know some
(Perl or ((csh or bash or ksh) and (sed and awk))), even if they are asking
for another language as the primary skill.
> If you have an opinion on this and wouldn't mind sharing, I'd love to
> read what everyone thinks.
Perl is still becoming increasingly popular. I don't foresee Python or Ruby
stealing much thunder from Perl. They don't have the same level of
documentation, they don't have the same NT support (although ActiveState's
site now mentions ActivePython, so this may change), and they don't have
CPAN. Therefore, anything that is best handled by a language similar to Perl
is just as well handled in Perl as with any other language with a similar
problem domain. (I'm still considering learning Ruby and Python, just for
the reason that I stated earlier about knowledge of more languages makes you
an all-round better programmer.)
Chris
---
Chris Stith
mischief@pikenet.net mischief@motion.net
------------------------------
Date: Tue, 12 Sep 2000 22:24:32 GMT
From: Ethan Post <epost1@my-deja.com>
Subject: Re: Please help me with my shotty code...
Message-Id: <8pmae9$l8v$1@nnrp1.deja.com>
Thanks for all the tips, I literally just opened a Perl book and wrote
the script, luckily I'm not getting paid to code Perl at the moment.
-Ethan
In article <7a1yypqri5.fsf@merlin.hyperchip.com>,
Ala Qumsieh <aqumsieh@hyperchip.com> wrote:
>
> Ethan Post <epost1@my-deja.com> writes:
>
> Here are a few pointers for your code:
>
> > open(METRIC, @ARGV[0]);
>
> @ARGV[0] is a list of one element that happens to be the first element
> of @ARGV. It is NOT the first element of @ARGV. Check out perlfaq4:
>
> What is the difference between $array[1] and @array[1]?
>
> open METRIC, $ARGV[0] or die $!;
>
> > while (<METRIC>) {
> >
> > ($ival, $utim, $nam) = split(/\|/);
> > $nam == chop $nam;
>
> What is this supposed to do? == is a comparison operator, not an
> assignment operator. And, chop() returns the last character chopped,
> which most probably is a newline.
>
> Just change this to:
>
> chomp $nam;
>
> or better still, why don't you chomp() the line just after you read
it,
> and before the split()?
>
> > if ($nam eq @ARGV[1]) {
>
> Again, @ARGV[1] is a list of one element. It is not a scalar. Use
> $ARGV[1] instead.
>
> > print($ival,"\r\n","0","\r\n",$utim,"\r\n", $nam,"\r\n");
>
> You don't need the \r's.
>
> >
> > }
> >
> > }
> >
> > close(METRIC);
>
> close METRIC or warn $!;
>
> --Ala
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 12 Sep 2000 20:44:42 -0400
From: "Garry T. Williams" <garry@zvolve.com>
Subject: Re: Problem getting unix "jobs" output with backticks
Message-Id: <Pine.SOL.4.21.0009122024240.26638-100000@ifr>
On Tue, 12 Sep 2000, Roger Rasmussen wrote:
> Hello,
>
> I'm trying to get Unix job information using backticks, but it's not
> working.
You should review the qx// operator in perlop. The qx// operator invokes
/bin/sh to run your command.
> Basically in my code I do:
>
> my $jobstuff = `jobs -l`;
> print "$jobstuff\n";
>
> For some reason $jobstuff is always empty, even when there are
> background jobs running. If I enter 'jobs -l' at the command line under
> this same terminal, it returns results.
What shell are you using? I bet it's not /bin/sh, but perl *is* using
/bin/sh.
Look at this:
$ jobs -l
[1] + 26749 Stopped (SIGTSTP) tail -f /var/adm/messages
$ /bin/sh jobs -l
jobs: jobs: cannot open
$ /bin/sh -c jobs -l
-l: jobs: no job control
$
(The output that the sub-shell does emit is all on stderr, hence nothing
gets returned from the qx// operator.)
My shell is /bin/ksh, but /bin/sh doesn't have a clue about my /bin/ksh
jobs. Also, /bin/sh doesn't even have job control enabled by default, if
it's not invoked interactively (as would be the case with qx// and as is
the case here). See sh(1).
Furthermore, the concept of "jobs" is one that the shell creates for
you. If you run another shell, even if it's your regular shell, it won't
know about "jobs" in the first shell.
I'd say your approach is broken. I'm not exactly sure how you'd go about
doing what you seem to want to do. You might try consulting Stevens,
_Advanced Programming in the UNIX Environment_. But the foregoing should
explain why your solution isn't working and why it cannot work.
-Garry Williams
------------------------------
Date: 12 Sep 2000 22:33:42 GMT
From: abigail@foad.org (Abigail)
Subject: Re: problem with hashes
Message-Id: <slrn8rtbo7.pg4.abigail@alexandra.foad.org>
Christopher M. Jones (christopher_j@uswest.net) wrote on MMDLXIX
September MCMXCIII in <URL:news:nUuv5.269$Xt4.221419@news.uswest.net>:
[]
[] <pratima@my-deja.com> wrote:
[] > how do i delete a particular key from a hash
[]
[]
[] Sometimes ya gotta wonder about these self answering questions.
There must be a reason my score file contains:
[*]
Score:: -9999
From: my-deja\.com
From: my-dejanews\.com
Message-ID: deja\.com
NNTP-Posting-Host: dejanews\.com
X-MyDeja-Info: .
X-DejaID: .
Abigail
--
$_ = "\nrekcaH lreP rehtona tsuJ"; my $chop; $chop = sub {print chop; $chop};
$chop -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()
-> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()
------------------------------
Date: 12 Sep 2000 22:18:35 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Qualifications for new Perl programmer?????
Message-Id: <8pma3r$qdb$1@slb6.atl.mindspring.net>
jason (elephant@squirrelgroup.com) wrote:
: so .. the point was not to get the answers right .. the mistakes tell me
: a lot about someone's Perl experience .. for example - the majority of
: people who tried the above question wrote answers with glaring syntax
: errors in them
In particular, the *kinds* of mistakes someone makes can tell you a great
deal about someone's experience with the language, or with programming in
general. It's one thing to get a detail wrong in an arbitrary sort of
way and make a "braino." It's something else entirely to make a mistake
that shows that either one doesn't have a mental model of a particular
aspect of the language, or worse, that one has an *incorrect* mental
model of something important. As Weinberg noted, if one person is asked
to evaluate 25-16 and answers 19, and another person answers 41, they've
both given incorrect answers, but for different reasons.
------------------------------
Date: Wed, 13 Sep 2000 09:53:19 +1100
From: jason <elephant@squirrelgroup.com>
Subject: Re: Qualifications for new Perl programmer?????
Message-Id: <MPG.142950d8b8268b1c989791@localhost>
[ I hate this sort of post in usenet .. but I can't escape it here :]
Eric Bohlman <ebohlman@netcom.com> wrote ..
>jason (elephant@squirrelgroup.com) wrote:
>: so .. the point was not to get the answers right .. the mistakes tell me
>: a lot about someone's Perl experience .. for example - the majority of
>: people who tried the above question wrote answers with glaring syntax
>: errors in them
>
>In particular, the *kinds* of mistakes someone makes can tell you a great
>deal about someone's experience with the language, or with programming in
>general. It's one thing to get a detail wrong in an arbitrary sort of
>way and make a "braino." It's something else entirely to make a mistake
>that shows that either one doesn't have a mental model of a particular
>aspect of the language, or worse, that one has an *incorrect* mental
>model of something important. As Weinberg noted, if one person is asked
>to evaluate 25-16 and answers 19, and another person answers 41, they've
>both given incorrect answers, but for different reasons.
exactly
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Tue, 12 Sep 2000 18:24:06 -0400
From: Thom Harp <thomharp@flash.net>
Subject: returning a tied variable
Message-Id: <39BEAD06.AFFB34DF@flash.net>
How can I create a variable in a subroutine, tie it to some class and
return the tied variable?
What I'd *like* to do is something like:
sub tie_variable {
tie $foo, 'SomeClass';
return $foo;
}
$bar = tie_variable;
But that doesn't seem to work. It compiles just fine but $bar isn't
actually tied.
thanks for the help...
------------------------------
Date: Tue, 12 Sep 2000 22:14:22 GMT
From: tltt@my-deja.com
Subject: Re: Running external programs and grabbing the output
Message-Id: <8pm9rb$khu$1@nnrp1.deja.com>
"Someperson" wrote:
> To be perfectly honest, yes, it seemed far too obvious and hence my
posted
> question.
I don't get it: it seemed too obvious to you to do "perldoc -f system"
to find out how (and if) you can capture the output of a program, so you
posted here instead. Well, if you want to make it harder for yourself to
find answers in the future you are definitely on the right track!
>
> But I can see that you are a professional troll (domain and
everything!) so
> a smartass reply at my expense was to be expected. Thanks for filling
that
> role.
So you can determine whether someone is a troll just from their domain.
You are my hero! Can you teach me how to do that?
btw what does that make you
Someperson(nothinghere!complainaboutthat!!!)?
I have noticed that people in CLPM can be a bit abrupt sometimes, but
after reading your post I understand them a lot better.
tltt
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 13 Sep 2000 10:47:45 +1100
From: jason <elephant@squirrelgroup.com>
Subject: Re: Running external programs and grabbing the output
Message-Id: <MPG.14295d9ebfb68e63989796@localhost>
"Someidiot" wrote ..
>"Abigail" <abigail@foad.org> wrote in message
>news:slrn8rqu95.pg4.abigail@alexandra.foad.org...
>> Someperson (nothinghere!complainaboutthat!!!) wrote on MMDLXIX September
>> MCMXCIII in <URL:news:srqti06rct6164@news.supernews.com>:
>> %% Hi
>> %%
>> %% I am trying to figure out where to start here. I have an NT command
>line
>> %% utility that I want to grab the output from and send input to. It runs
>by
>> %% passing it one string of args, and the output is one string.
>> %%
>> %% I assume something like this:
>> %%
>> %% system "myprogram.exe -arg1 -arg2";
>> %% $output = <STDOUT>;
>> %% print $output;
>> %%
>> %% ....would not work.
>> %%
>> %% Any idea where I should look for some instruction on this?
>>
>>
>> How about the Perl manual? For instance, starting by what the manual
>> has to say about *drumroll* system?
>>
>> Or would that just be too obvious?
>
>To be perfectly honest, yes, it seemed far too obvious and hence my posted
>question.
don't be an idiot .. put your tail between your legs and run along ..
look in the documentation - it has the answer that you're looking for
>But I can see that you are a professional troll (domain and everything!) so
>a smartass reply at my expense was to be expected. Thanks for filling that
>role.
bzzt - thanks for playing .. Abigail is one of the best contributors to
this forum - and you'd do well to heed her advice - for while it might
be a little caustic - it's accurate and would actually help you
>To think I named my dog Abigail....
hmm .. surely supernews have a clause about being over 18 ?
[ jeopardectomy ]
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Wed, 13 Sep 2000 00:27:26 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Running external programs and grabbing the output
Message-Id: <slrn8rtifb.id4.tjla@thislove.dyndns.org>
I was shocked! How could Someperson <nothinghere!complainaboutthat!!!>
say such a terrible thing:
>To be perfectly honest, yes, it seemed far too obvious and hence my posted
>question.
>
>But I can see that you are a professional troll (domain and everything!) so
>a smartass reply at my expense was to be expected. Thanks for filling that
>role.
>
>To think I named my dog Abigail....
Uncalled for. Her answer was correct and concise. We aren't paid to be
here so is it any wonder we sometimes like to have a joke at someone
else's expense, particularly when their question shows they haven't
bothered to a) read the documentation or b) read the newsgroup for a
while since this question is an FAQ. Score duly adjusted.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
We are ready for an unforseen event that may or may not occur.
-Dan Quayle, US Vice President
------------------------------
Date: 12 Sep 2000 18:55:26 -0400
From: kj0 <kj0@mailcity.com>
Subject: Silly grep tricks
Message-Id: <8pmc8u$qp6$1@panix3.panix.com>
Is there a way to get grep to return only the first item (if any) in a
list for which the test is true?
------------------------------
Date: Tue, 12 Sep 2000 19:36:40 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: Silly grep tricks
Message-Id: <Pine.GSO.4.21.0009121934350.10747-100000@crusoe.crusoe.net>
[posted & mailed]
On Sep 12, kj0 said:
>Is there a way to get grep to return only the first item (if any) in a
>list for which the test is true?
jeffp@friday [7:36pm] ~ #1245> perldoc -q first | grep '^=head'
=head1 Found in /usr/local/lib/perl5/5.00502/pod/perlfaq4.pod
=head2 How can I access/change the first N letters of a string?
=head2 How do I find the first array element for which a condition is
true?
--
Jeff "japhy" Pinyan japhy@pobox.com http://www.pobox.com/~japhy/
PerlMonth - An Online Perl Magazine http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc. http://www.perlarchive.com/
CPAN - #1 Perl Resource (my id: PINYAN) http://search.cpan.org/
------------------------------
Date: Wed, 13 Sep 2000 11:31:08 +1100
From: jason <elephant@squirrelgroup.com>
Subject: Re: Silly grep tricks
Message-Id: <MPG.142967c4e26ba40298979a@localhost>
Jeff Pinyan <jeffp@crusoe.net> wrote ..
>[posted & mailed]
>
>On Sep 12, kj0 said:
>
>>Is there a way to get grep to return only the first item (if any) in a
>>list for which the test is true?
>
>jeffp@friday [7:36pm] ~ #1245> perldoc -q first | grep '^=head'
>=head1 Found in /usr/local/lib/perl5/5.00502/pod/perlfaq4.pod
>=head2 How can I access/change the first N letters of a string?
>=head2 How do I find the first array element for which a condition is
>true?
doesn't actually address the question asked very well
kj0 .. no you can't .. grep will iterate over all the elements of the
LIST that it is passed .. you can't break out of it .. what you want is
something more like a for loop (but not a regular for loop - because it
localises the elements and you can't see them when the loop is over)
#!/usr/bin/perl -w
use strict;
sub sillyGrep (&@)
{
my $sub = shift;
for (@_)
{
# add a debug print here to show that we get out on the first one
return $_ if &$sub;
}
}
my @array = qw/abc def ghi def/;
my $x = sillyGrep { /def/ } @array;
print "x: $x\n";
__END__
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Wed, 13 Sep 2000 02:24:07 +0200
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: Test Your Perl Skills
Message-Id: <1egvla1.1qvy1w32z1f9yN%tony@svanstrom.com>
Uri Guttman <uri@sysarch.com> wrote:
> >>>>> "cr" == cd root <cd_root@my-deja.com> writes:
>
> cr> Network Essentials Inc hosts "Get Certified!", dedicated to helping
> cr> build the knowledge base required to demonstrate technological skills.
> cr> We are pleased to announce our newest database of questions for perl.
>
> get lost. certification is for those who don't know how to tell if
> someone knows anything.
Which is why managers love it and only hire people with papers that says
that they know something, without bothering to even look at people that
really knows it.
/Tony
--
/\___/\ Who would you like to read your messages today? /\___/\
\_@ @_/ Protect your privacy: <http://www.pgpi.com/> \_@ @_/
--oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
on the verge of frenzy - i think my mask of sanity is about to slip
---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
\O/ \O/ ©99-00 <http://www.svanstrom.com/?ref=news> \O/ \O/
------------------------------
Date: Wed, 13 Sep 2000 00:08:13 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: timeout
Message-Id: <G0stpp.34L@news.boeing.com>
In article <cRVu5.55497$d9.388311@typhoon.kc.rr.com>,
Ryan McKillen <ryruns@aol.com> wrote:
>I am working on a perl script right now and wondered if I could get some
>help. The script is attached. This script uses LWP::Simple to check links
>and make sure they work. I would like for it to timeout and consider a link
>not working if it can't be validated in 20 seconds or less. Does anyone
>know how to use perl's alarm() function to make this happen?
>
>
>begin 666 links.cgi
>M(R$O=7-R+V)I;B]P97)L#0H-"G5S92!,5U Z.E-I;7!L93L-"G5S92!$0DD[
>M#0H-"B1D8E]D871A8F%S92 ](")M<#-D8B([#0HD9&)?=6ED(" @/2 B<F]O
>M="([#0HD9&)?<'=D(#T@(FAN,&9S=&9U(CL-"@T*)&1B:" ]($1"22T^8V]N
>M;F5C=" H(D1"23IM>7-Q;#HD9&)?9&%T86)A<V4B+B1M>7-Q;'-O8VLL("1D
>M8E]U:60L("1D8E]P=V0I(&]R(&1I92@B8V]U;&0@;F]T(&-O;FYE8W0@=&\@
>M9&)<;B(I.PT*)'-T:" ]("1D8F@M/G!R97!A<F4H(E-%3$5#5"!U<FP@1E)/
>M32!F:6QE<R(I.PT*)'-T:" M/B!E>&5C=71E*"D[#0HD;G5M<F]W<R ]("1S
>M=&@M/G)O=W,[#0H-"F9O<B H)&D@/2 P.R D:2 ]("1N=6UR;W=S.R K*R1I
>M*2O=U]A<G)A>2D[#0H):68H*&AE
>M860H)'5R;"DI(&]R("AG970H)'5R;"DI*2W
>M;W)K<R([#0H)?2!E;'-E('L-"@D))'9A;&ED:71Y(#T@(F)R;VME(CL-"@D)
>M)'9A;&ED7W5P9&%T92 ]("1D8F@M/F1O*")54$1!5$4@9FEL97,@4T54('9A
>M;&ED(#T@=F%L:60@*R Q(%=(15)%('5R;" ]("<D=7)L)R(I.PD-"@E]#0H)
>><')I;G0@(B1V86QI9&ET>2 M("1U<FQ<;B([#0I]
>`
>end
You might consider using LWP::UserAgent which has its
own timeout method and is more versatile than LWP::Simple:
my $browser = LWP::UserAgent->new;
$browser->timeout(20);
...
hth,
--
Charles DeRykus
------------------------------
Date: Tue, 12 Sep 2000 15:16:11 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Where Doesn't this work?
Message-Id: <39BEAB2B.9E675A5C@stomp.stomp.tokyo>
Brian wrote:
> Where Doesn't this work? i am trying to remove all " from
> the file when it is read in?
(snipped)
You may wish to declare $/ as a local variable
or reset $/ to whatever is appropriate if $/
will have an affect elsewhere in your program.
Another choice would be to iterate through
your array, line-by-line, removing quotes,
using a for or foreach type loop. A while
type loop would work for larger size files.
However, for a small html file, looping is not
really needed. Quicker to treat your input as
a single line if file size is not an issue.
Godzilla!
--
print "http://3483852801/%7e%63%61ll%67i%72l";
TEST SCRIPT:
____________
#!/usr/local/bin/perl
print "Content-type: text/plain\n\n";
$/ = "";
open (FILEHANDLE, "test.txt");
$string = <FILEHANDLE>;
close (FILEHANDLE);
print "\nInput:\n\n$string";
$string =~ s/"//g;
print "\n\n\nOutput:\n\n$string";
exit;
PRINTED RESULTS:
________________
Input:
"Test Line One"
Test Line Two <A REF="myplace.com">My Place</A>
Test Line "Three" <FONT SIZE="4">
"Test" Line Four </FONT>
"Finished"
Output:
Test Line One
Test Line Two <A REF=myplace.com>My Place</A>
Test Line Three <FONT SIZE=4>
Test Line Four </FONT>
Finished
------------------------------
Date: Tue, 12 Sep 2000 18:24:18 -0400
From: "Liang Cheng" <Cheng3@email.msn.com>
Subject: Re: Where Doesn't this work?
Message-Id: <uqpy0eQHAHA.436@cpmsnbbsa07>
Brian <brian@ukdj.freeserve.co.uk> wrote in message
news:8pm78b$ck1$1@news6.svr.pol.co.uk...
> Where Doesn't this work? i am trying to remove all " from the file when it
> is read in?
>
> my($SIZE,$i);
> open (FILE,"$productdb") || die "Content-type: text/html\n\nCan't Open
> $productdb(r): $!\n";
> my(@LINES)=<FILE>;
> @LINES =~ s/\"//g;
> close(FILE);
> $SIZE=@LINES;
In addition to Allan's post, you seem to want to get the size of the LINES
array, that should be done with $SIZE =($#LINES +1);
>
>
> Brian
>
>
>
>
------------------------------
Date: 12 Sep 2000 22:31:33 GMT
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: Where Doesn't this work?
Message-Id: <8pmas5$99f$1@internal-news.uu.net>
Liang Cheng <Cheng3@email.msn.com> wrote:
>> $SIZE=@LINES;
> In addition to Allan's post, you seem to want to get the size of the LINES
> array, that should be done with $SIZE =($#LINES +1);
Why should that be done with $#LINES +1 ?
Erik
------------------------------
Date: Tue, 12 Sep 2000 19:23:32 -0400
From: "Liang Cheng" <Cheng3@email.msn.com>
Subject: Re: Where Doesn't this work?
Message-Id: <uISU7$QHAHA.283@cpmsnbbsa07>
well it really depends on your preference, If you have a array that contain
3 elements, $#array gives 2, which is good, if you want to iterate over the
array or just acess the last item of the array. Well it is a bit different
than C, but it is really a philosophical one rather than a practical one.
Erik van Roode <newsposter@cthulhu.demon.nl> wrote in message
news:8pmas5$99f$1@internal-news.uu.net...
> Liang Cheng <Cheng3@email.msn.com> wrote:
>
> >> $SIZE=@LINES;
> > In addition to Allan's post, you seem to want to get the size of the
LINES
> > array, that should be done with $SIZE =($#LINES +1);
>
> Why should that be done with $#LINES +1 ?
>
> Erik
>
------------------------------
Date: Tue, 12 Sep 2000 19:26:57 -0400
From: "Liang Cheng" <Cheng3@email.msn.com>
Subject: Re: Where Doesn't this work?
Message-Id: <#x4Y0BRHAHA.278@cpmsnbbsa07>
Godzilla! <godzilla@stomp.stomp.tokyo> wrote in message
news:39BEAB2B.9E675A5C@stomp.stomp.tokyo...
> Brian wrote:
>
> > Where Doesn't this work? i am trying to remove all " from
> > the file when it is read in?
>
> (snipped)
>
> You may wish to declare $/ as a local variable
> or reset $/ to whatever is appropriate if $/
> will have an affect elsewhere in your program.
>
> Another choice would be to iterate through
> your array, line-by-line, removing quotes,
> using a for or foreach type loop. A while
> type loop would work for larger size files.
>
> However, for a small html file, looping is not
> really needed. Quicker to treat your input as
> a single line if file size is not an issue.
>
>
> Godzilla!
> --
> print "http://3483852801/%7e%63%61ll%67i%72l";
>
>
> TEST SCRIPT:
> ____________
>
>
> #!/usr/local/bin/perl
>
> print "Content-type: text/plain\n\n";
>
> $/ = "";
>
> open (FILEHANDLE, "test.txt");
> $string = <FILEHANDLE>;
doesn't this only get you the first line?
> close (FILEHANDLE);
>
> print "\nInput:\n\n$string";
>
> $string =~ s/"//g;
>
> print "\n\n\nOutput:\n\n$string";
>
> exit;
>
>
> PRINTED RESULTS:
> ________________
>
>
> Input:
>
> "Test Line One"
> Test Line Two <A REF="myplace.com">My Place</A>
> Test Line "Three" <FONT SIZE="4">
> "Test" Line Four </FONT>
> "Finished"
>
>
>
> Output:
>
> Test Line One
> Test Line Two <A REF=myplace.com>My Place</A>
> Test Line Three <FONT SIZE=4>
> Test Line Four </FONT>
> Finished
------------------------------
Date: Tue, 12 Sep 2000 19:34:07 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: Where Doesn't this work?
Message-Id: <Pine.GSO.4.21.0009121931390.10747-100000@crusoe.crusoe.net>
On Sep 12, Godzilla! said:
>Brian wrote:
>
>> Where Doesn't this work? i am trying to remove all " from
>> the file when it is read in?
>
>However, for a small html file, looping is not
>really needed. Quicker to treat your input as
>a single line if file size is not an issue.
>$/ = "";
You should undef $/, rather than assign "" to it. When $/ is "", <FILE>
returns "chunks" of the file -- segments separated by two or more
newlines. When $/ is undef, <FILE> returns the entire contents of the
file. See perlvar.
>$string =~ s/"//g;
I'd use tr/"//d in this case; while I'm not about to benchmark the speeds,
tr/// is usually optimal for character deletion.
--
Jeff "japhy" Pinyan japhy@pobox.com http://www.pobox.com/~japhy/
PerlMonth - An Online Perl Magazine http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc. http://www.perlarchive.com/
CPAN - #1 Perl Resource (my id: PINYAN) http://search.cpan.org/
------------------------------
Date: Tue, 12 Sep 2000 23:49:28 GMT
From: Allan M. Due <All@n.Due.net>
Subject: Re: Where Doesn't this work?
Message-Id: <MPG.14288ad5bae3a715989684@news>
In article <#x4Y0BRHAHA.278@cpmsnbbsa07>, Cheng3@email.msn.com says...
|Godzilla! <godzilla@stomp.stomp.tokyo> wrote in message
|> $/ = "";
|>
|> open (FILEHANDLE, "test.txt");
|> $string = <FILEHANDLE>;
|doesn't this only get you the first line?
Erm, see four lines above in your post. $/ = "" may not be optimal but
it does negate your comment. If you are going to do this with $/ then
$string = do { local $/; <FILEHANDLE> };
is cool but
read FILEHANDLE, $sting, -s FILEHANDLE;
is better for reasons that searching deja will provide.
HTH
AmD
--
$email{'Allan M. Due'} = ' All@n.Due.net ';
--Random Quote--
If the automobile had followed the same development cycle as the
computer, a Rolls-Royce would today cost $100, get one million miles to
the gallon, and explode once a year, killing everyone inside.
Robert X Cringely
oops if anyone sees the cancel... well I needed to fix line counts
------------------------------
Date: Wed, 13 Sep 2000 11:03:25 +1100
From: jason <elephant@squirrelgroup.com>
Subject: Re: Where Doesn't this work?
Message-Id: <MPG.142961467fe0dbf6989799@localhost>
Liang Cheng <Cheng3@email.msn.com> wrote ..
>Erik van Roode <newsposter@cthulhu.demon.nl> wrote in message
>news:8pmas5$99f$1@internal-news.uu.net...
>> Liang Cheng <Cheng3@email.msn.com> wrote:
>>
>> >> $SIZE=@LINES;
>> > In addition to Allan's post, you seem to want to get the size of the
>LINES
>> > array, that should be done with $SIZE =($#LINES +1);
>>
>> Why should that be done with $#LINES +1 ?
-
>well it really depends on your preference, If you have a array that contain
>3 elements, $#array gives 2, which is good, if you want to iterate over the
>array or just acess the last item of the array. Well it is a bit different
>than C, but it is really a philosophical one rather than a practical one.
I think you will find that Erik meant that
$size = @LINES;
and
$size = $#LINES +1;
will result in EXACTLY the same value in $size because the scalar value
of an array *is* it's size
see perldata for more details
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Tue, 12 Sep 2000 17:10:23 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Where Doesn't this work?
Message-Id: <39BEC5EF.F1F745D4@stomp.stomp.tokyo>
"Allan M. Due" wrote:
> In article <#x4Y0BRHAHA.278@cpmsnbbsa07>, Cheng3@email.msn.com says...
> |Godzilla! <godzilla@stomp.stomp.tokyo> wrote in message
> |> $/ = "";
> |>
> |> open (FILEHANDLE, "test.txt");
> |> $string = <FILEHANDLE>;
> |doesn't this only get you the first line?
Don't see this article on Sucker News.
No, reads entire file as a single line.
This is in clear evidence via my printed
results in my article.
Hmm... *scratches her noggin*
> Erm, see four lines above in your post.
No, actually I don't see those four lines.
> $/ = ""; may not be optimal
Why is this? Reads like Mere Assertion.
Without supporting evidence and explanation
your comments are dismissed as such,
unsubstantiated Mere Assertion.
> but it does negate your comment.
Negates what comment and why?
> If you are going to do this with $/ then
> $string = do { local $/; <FILEHANDLE> };
> is cool
Why is this "cool"? Looks like obfuscation to me.
This is not cool for reading comprehension.
> but read FILEHANDLE, $sting, -s FILEHANDLE;
> is better for reasons that searching deja will provide.
Really? What article subject line? What dates? Posted
by whom? Do I even care?
As if I would even bother searching Deja Vu...
You have a lot of essplaning Lucy...
Godzilla!
--
print "http://3483852801/%7e%63%61ll%67i%72l";
------------------------------
Date: Wed, 13 Sep 2000 01:00:21 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Where Doesn't this work?
Message-Id: <slrn8rtkd2.id4.tjla@thislove.dyndns.org>
I was shocked! How could Liang Cheng <Cheng3@email.msn.com>
say such a terrible thing:
>
>Brian <brian@ukdj.freeserve.co.uk> wrote in message
>news:8pm78b$ck1$1@news6.svr.pol.co.uk...
>> Where Doesn't this work? i am trying to remove all " from the file when it
>> is read in?
>> $SIZE=@LINES;
>In addition to Allan's post, you seem to want to get the size of the LINES
>array, that should be done with $SIZE =($#LINES +1);
The two are equivalent.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
BOFH excuse #107:
The keyboard isn't plugged in
------------------------------
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 4305
**************************************