[22388] in Perl-Users-Digest
Perl-Users Digest, Issue: 4609 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Feb 22 21:05:33 2003
Date: Sat, 22 Feb 2003 18:05:06 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 22 Feb 2003 Volume: 10 Number: 4609
Today's topics:
Re: automating an ftp transfer <mgjv@tradingpost.com.au>
Re: Chucking up text on word boundaries? <mgjv@tradingpost.com.au>
Re: compiling perlcc generated c code with gcc <goldbb2@earthlink.net>
Re: Creating a variable from 3 other variables <mgjv@tradingpost.com.au>
Re: having PERL respond to a key press <mgjv@tradingpost.com.au>
Re: LWP Requests <smiley@uvgotemail.com>
Re: LWP Requests <smiley@uvgotemail.com>
Re: map two lists <REMOVEsdnCAPS@comcast.net>
Re: map two lists <goldbb2@earthlink.net>
Re: parens () <s_grazzini@hotmail.com>
Re: parens () <abigail@abigail.nl>
Re: POSTing data to JHTML page <bwalton@rochester.rr.com>
Re: Q: about opening many processes in parallel as file <goldbb2@earthlink.net>
Re: Questions about perl. <dthomson@NOSPAMusers.sf.net>
Re: Questions about perl. <mail@annuna.com>
Re: setting permissions on my server for cgi <cpb6043@osfmail.rit.edu>
Re: setting permissions on my server for cgi (Jay Tilton)
Simple Pattern Problem? <jeff@lee-burgin.com>
Re: Simple Pattern Problem? <s_grazzini@hotmail.com>
Re: sorting multidimensional arrays on one subkey <krahnj@acm.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 23 Feb 2003 10:43:13 +1100
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: automating an ftp transfer
Message-Id: <slrnb5g2oh.2fm.mgjv@martien.heliotrope.home>
On Sat, 22 Feb 2003 21:19:36 +0000,
Sharon Grant <peakpeek@purethought.com> wrote:
> On 22 Feb 2003 12:36:23 -0800, in comp.lang.perl.misc, voigt691@netscape.net (Voigt Lander) wrote:
>
>>Would perl be a good tool for this??
>
> Probably not
Nonsense.
Perl, together with the Net::FTP module, is a perfectly good tool for
this.
>>I need to connect to an ftpsite each night and pull down a file
>
> Use a good command-line FTP client ...
>
> lftp
> ncftp
> curl
And what exactly is the advantage of any of these tools above using
Perl? These tools would have to be wrapped in a shell or Perl script
anyway.
Martien
--
|
Martien Verbruggen | Useful Statistic: 75% of the people make up
| 3/4 of the population.
|
------------------------------
Date: Sun, 23 Feb 2003 10:46:33 +1100
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Chucking up text on word boundaries?
Message-Id: <slrnb5g2up.2fm.mgjv@martien.heliotrope.home>
On 22 Feb 2003 07:03:57 -0800,
Robert Nicholson <robert@elastica.com> wrote:
[about Text::Wrap::wrap]
> I haven't checked the source but I thought if you called wrap in a
> list context that it would return an array.
Well, the documentation suggest that it does. Quote:
@lines = wrap($initial_tab, $subsequent_tab, @text);
Martien
--
|
Martien Verbruggen |
| Curiouser and curiouser, said Alice.
|
------------------------------
Date: Sat, 22 Feb 2003 18:28:26 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: compiling perlcc generated c code with gcc
Message-Id: <3E58079A.5D330880@earthlink.net>
stig wrote:
[snip]
> as gcc begins to parse the c file it generates 4-5 lines of warnings
> per line c code, and ends in error
>
> this is how the errors and warnings begin
> myprogram.c:1:20: EXTERN.h: No such file or directory
> myprogram.c:2:18: perl.h: No such file or directory
> myprogram.c:3:18: XSUB.h: No such file or directory
You need to have the perl source installed on your machine to be able to
compile the output of perlcc... that is where those headers are.
--
$;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
$__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print
------------------------------
Date: Sun, 23 Feb 2003 10:38:29 +1100
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Creating a variable from 3 other variables
Message-Id: <slrnb5g2fl.2fm.mgjv@martien.heliotrope.home>
On Sat, 22 Feb 2003 13:53:29 -0000,
Mikey <PleaseDontThrowSpam@Me.com> wrote:
>
> "Matija Papec" <mpapec@yahoo.com> wrote in message
> news:dhue5v44gv4i4gpamcjmgl86vtolr89avp@4ax.com...
>> X-Ftn-To: Mikey
>>
>> "Mikey" <PleaseDontThrowSpam@Me.com> wrote:
>> >
>> >If I try the following, I will get errors:
>> >my $date = "$year$month$day";
>>
>> Which error exactly? This should work but as alternative you can use
>> my $date = $year . $month . $day;
>> or:
>> my $date = "${year}${month}${day}";
>
>:)
>
> Thanks,
You forgot to answer the question posed: Which error do you get when
using "$year$month$day"?
You should not be getting any error when using that construction, so if
you do get one, you have a broken perl, and you should fix that.
Starting to use unnecessarily verbose code because you have a broken
installation of Perl, or because you don't understand what's going on,
is silly.
Martien
--
|
Martien Verbruggen | That's not a lie, it's a terminological
| inexactitude.
|
------------------------------
Date: Sun, 23 Feb 2003 10:28:26 +1100
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: having PERL respond to a key press
Message-Id: <slrnb5g1sq.2fm.mgjv@martien.heliotrope.home>
[You have been asked, by several people, several times, to stop
top-posting, yet you persist. You obviously are doing it on purpose.
You have been asked for more information about error messages, yet you
simply ignore this.
I can only conclude that you are here to deliberately annoy us.
I will therefore put you, after this post, in my killfile, as I am sure
many others will as well.]
On Sat, 22 Feb 2003 12:40:23 -0000,
<tyrannous@o-space.com> <tyrannous@o-space.com> wrote:
> "Eric J. Roode" <REMOVEsdnCAPS@comcast.net> wrote in message
> news:Xns9329E00E01517sdn.comcast@216.166.71.239...
>> <tyrannous@o-space.com> wrote in news:b363e3$b40$1@news8.svr.pol.co.uk:
>>
>> > yes i tried it
>> > i tried the following:
>> >
>> > #!c:\perl\bin\perl.exe
>> >
>> > use Term::ReadKey;
>> >
>> > blah blah
>> >
>> > says cannot find Term::ReadKey in @INC or something like that
>>
>> Well then, you should go find it or something like that. Maybe find it on
>> the Internet or something like that.
>
> it is already installed in the lib directory in perl, thank you very much
No, it is not. If you get an error message in which perl states that it
cannot find Term::ReadKey in @INC "or something like that", then you
have _not_ correctly installed the Term::ReadKey module. I don't know
what you _think_ you have done, and I also no longer care.
*PLONK*
Martien
--
|
Martien Verbruggen |
| Curiouser and curiouser, said Alice.
|
------------------------------
Date: Sat, 22 Feb 2003 18:35:05 -0500
From: "Smiley" <smiley@uvgotemail.com>
Subject: Re: LWP Requests
Message-Id: <v5g29lrccnrh9d@corp.supernews.com>
> it could be any number of things, including but not limited to:
>
> - the remote page 2 script may expect GET params and you're using POST,
> or vice versa (you don't say which)
>
> - the remote page 2 script may be set up to recognize that a fake
> browser is being used (lwp) by its user agent signature
>
> etc.
>
> what url are you trying to reach?
It's a page that lists doctors in certain cities. I'm trying to get a list
of the doctors in one city for a project of mine. Some of the pages do seem
to accept only GET while others accept only POST, but I checked it out and
the pages I'm trying to get information from only accept POST, that's why
it's what I was using.
I don't think that they're checking for a fake browser, this information
really isn't that sensitive, and access to it is completely free. Plus, why
would they check for a false browser on the second page but not on the
first? I would get the information directly from them except for that they
haven't returned any of my emails.
This is the page to search for information:
my $req = POST 'http://www.cpso.on.ca/Doctor_Search/ez_srch.asp',
[ Type => 'EASY',
SCR => 'FIRST',
Gender => 'Either',
Status => 'all',
CityList => '1127',
Easysrch => 'Start Search' ];
------------------------------
Date: Sat, 22 Feb 2003 18:44:36 -0500
From: "Smiley" <smiley@uvgotemail.com>
Subject: Re: LWP Requests
Message-Id: <v5g2rk5td1ul2a@corp.supernews.com>
Dang, something happened and this post was accidentally sent uncompleted. I
must have pressed the wrong button. In any case, ignore tha last one, I'll
complete it here.
> it could be any number of things, including but not limited to:
>
> - the remote page 2 script may expect GET params and you're using POST,
> or vice versa (you don't say which)
>
> - the remote page 2 script may be set up to recognize that a fake
> browser is being used (lwp) by its user agent signature
>
> etc.
>
> what url are you trying to reach?
It's a page that lists doctors in certain cities. I'm trying to get a list
of the doctors in one city for a project of mine. Some of the pages do seem
to accept only GET while others accept only POST, but I checked it out and
the pages I'm trying to get information from only accept POST, that's why
it's what I was using.
I don't think that they're checking for a fake browser, this information
really isn't that sensitive, and access to it is completely free. Plus, why
would they check for a false browser on the second page but not on the
first? I would get the information directly from them except for that they
haven't returned any of my emails.
This is the page to search for information:
http://www.cpso.on.ca/Doctor_Search/ez_srch.asp?Scr=FIRST
This is how I retrieved the search results for the first page:
my $req = POST 'http://www.cpso.on.ca/Doctor_Search/ez_srch.asp',
[ Type => 'EASY',
SCR => 'FIRST',
Gender => 'Either',
Status => 'all',
CityList => '1127',
Easysrch => 'Start Search' ];
my $res = $ua->request($req)->as_string;
Then I go through a loop, going through the results and recording the
necessary data. At the end of that loop I have the code to change the
values:
$req = POST 'http://www.cpso.on.ca/Doctor_Search/results1.asp',
[ Gender => 'Either',
strType => 'EASY',
Status => 'all',
CityList => '1127',
intCurrentpage => $i,
Action => 'Next+Items'];
$res = $ua->request($req)->as_string;
I think there might be something else going on here, I'm looking into
possibilities. But I want to make sure that the way I've set things up here
is sound first though.
------------------------------
Date: Sat, 22 Feb 2003 18:08:21 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: map two lists
Message-Id: <Xns932AC298BFEAFsdn.comcast@216.166.71.239>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
Benjamin Goldberg <goldbb2@earthlink.net> wrote in
news:3E58031B.7674838E@earthlink.net:
[suggestions snipped]
Say, those are some excellent suggestions. I especially like the last one,
the bit about having a map() be the last expression in the function, so
that it gets the calling context, and so that I don't need to build a temp
array of results.
Also I'll try your local() tips. I had a dickens of a time getting local
to work on $a and $b in the caller's package, so I kludged it by doing a
copy and restore.
Thanks!
- --
Eric
print scalar reverse sort qw p ekca lre reh
ts uJ p, $/.r, map $_.$", qw e p h tona e;
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBPlgQymPeouIeTNHoEQIV+QCggRwIeidOU7oggWNEClTV8FXMeuEAni7r
okS+I9u9yp+SBXYfi2paVgmi
=n76c
-----END PGP SIGNATURE-----
------------------------------
Date: Sat, 22 Feb 2003 20:25:01 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: map two lists
Message-Id: <3E5822ED.CD6CBEC5@earthlink.net>
Eric J. Roode wrote:
[snip]
> Also I'll try your local() tips. I had a dickens of a time getting
> local to work on $a and $b in the caller's package, so I kludged it by
> doing a copy and restore.
This is because you cannot local() through a reference, unless you are
local()ing a glob.
That is:
local *$foo;
works, while:
local $$foo;
does not.
I have no idea whether or not this will be fixed in perl 5.10.
--
$;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
$__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print
------------------------------
Date: Sun, 23 Feb 2003 01:23:46 GMT
From: Steve Grazzini <s_grazzini@hotmail.com>
Subject: Re: parens ()
Message-Id: <CoV5a.40052$ma2.11176200@twister.nyc.rr.com>
Robert Krueger <racsw@frontiernet.net> writes:
> Robert Krueger wrote:
>> Why does this work:
>> print (( 2 * 3 ) * 8 );
>>
>> and this doesn't?
>> print ( 2 * 3 ) * 8;
...
> Well, I apologize for not being more specific, I was in a rush
> before going to work. I always enable warnings, and I receive
> this warning:
>
> "Useless use of integer multiplication (*) in void context at
> <line #>"
You should actually get two warnings, and the first one
is more helpful:
$ perl -Mdiagnostics -we 'print (2*3)*6'
print (...) interpreted as function at -e line 1 (#1)
(W syntax) You've run afoul of the rule that says that any
list operator followed by parentheses turns into a function,
with all the list operators arguments found inside the
parentheses. See perlop/Terms and List Operators (Leftward).
There's also an explanation toward the top of the perlfunc
manpage:
$ perldoc perlfunc
...
Any function in the list below may be used either with or
without parentheses around its arguments. (The syntax
descriptions omit the parentheses.) If you use the
parentheses, the simple (but occasionally surprising) rule
is this: It looks like a function, therefore it is a
function, and precedence doesn't matter. Otherwise it's a
list operator or unary operator, and precedence does
matter. And whitespace between the function and left
parenthesis doesn't count--so you need to be careful
sometimes:
print 1+2+4; # Prints 7.
print(1+2) + 4; # Prints 3.
print (1+2)+4; # Also prints 3!
> In C or C++, I would never get a warning for this syntax
$ gcc -Wunused ...
--
Steve
------------------------------
Date: 23 Feb 2003 01:49:39 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: parens ()
Message-Id: <slrnb5ga5i.4cb.abigail@alexandra.abigail.nl>
Robert Krueger (racsw@frontiernet.net) wrote on MMMCDLXII September
MCMXCIII in <URL:news:v5frr523k2r71@corp.supernews.com>:
][ Robert Krueger wrote:
][
][ > Hi,
][ > Why does this work:
][ > print (( 2 * 3 ) * 8 );
][ >
][ > and this doesn't?
][ > print ( 2 * 3 ) * 8;
][ >
][ > Thanks,
][ > Robert
][
][ Well, I apologize for not being more specific, I was in a rush before going
][ to work.
][ I always enable warnings, and I receive this warning:
][
][ "Useless use of integer multiplication (*) in void context at <line #>"
][
][ In C or C++, I would never get a warning for this syntax, but regardless,
][ the order of precedence remains the same with or without the parens(), so
][ why does Perl take issue with this?
$ cat hmm.c
# include <stdlib.h>
# include <stdio.h>
int main (int argc, char * argv []) {
printf ("%d\n", (2 * 3)) * 8;
exit (0);
}
$ gcc -Wall -o hmm hmm.c
$ ./hmm
6
$
So, yeah, gcc isn't giving you a warning. But it isn't printing 48 either.
Of course, it could be that you really wanted to have '6' printed, and
you don't want to see the warning. In that case, turn the warnings off
by doing:
no warnings 'void';
Abigail
--
# Count the number of lines; code doesn't match \w. Linux specific.
()=<>;$!=$=;($:,$,,$;,$")=$!=~/.(.)..(.)(.)..(.)/;
$;++;$*++;$;++;$*++;$;++;`$:$,$;$" $. >&$*`;
------------------------------
Date: Sat, 22 Feb 2003 23:38:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: POSTing data to JHTML page
Message-Id: <3E5809EE.9080005@rochester.rr.com>
Hrishikesh Agashe wrote:
...
> I am trying to POST the data through Perl code to JHTML page
> But every time I execute the program, what I get back is the same jhtml page
> !!
>
> Is there any way to solve this problem ?
>
> --Hrishi
...
What is JHTML?
Where is your simplified standalone code that anyone can
cut/paste/execute which demonstrates the essence of your problem? You
gave no information on which anyone can formulate a reply. One might
assume you are using the various LWP modules, and that there is probably
a problem with how you used them, probably with LWP::UserAgent.
--
Bob Walton
------------------------------
Date: Sat, 22 Feb 2003 18:45:45 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Q: about opening many processes in parallel as filehandles and win* OSes
Message-Id: <3E580BA9.DF69B31E@earthlink.net>
Michele Dondi wrote:
[snip]
> Then I tried it on my Win98 system (AS 5.6.1 FWIM) as well (modulo a
> minor modification on the invocation of ping), but it failed with
> (e.g.) 127.0.0.65 dying with the error message "Bad file descriptor".
>
> After some experimenting I discovered that I can have at most 64 FHs
> opened as pipes. Is this limitation perl-implementation-dependent or
> OS-dependent? Ah, and where is it documented?
This limitation is operating system dependent; it's not perl's fault.
I have no idea where it's documented.
Anyway... as a workaround to the problem, I would suggest you code
something like the following:
my @p;
local $/;
for( 1 .. 255 ) {
print readline shift @p if @p == 64;
open $p[@p], "-|", "ping $net$_ -c 10"
or die "Couldn't start ping for $net$_: $!\n"
}
print readline $_ for @p;
__END__
[untested]
--
$;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
$__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print
------------------------------
Date: Sun, 23 Feb 2003 09:11:35 +1000
From: Derek Thomson <dthomson@NOSPAMusers.sf.net>
Subject: Re: Questions about perl.
Message-Id: <3e580363$0$10328$afc38c87@news.optusnet.com.au>
Michael Budash wrote:
> In article <3E57B95E.3050502@annuna.com>, Joe Creaney <mail@annuna.com>
> wrote:
>
>
>>I picked up a book on c++. It is very intersting but seems like it is
>>rather cumbersome to program next to perl. C++ has objects and classes?
>>Does perl have simmilar functions?
>>
>
>
> yes, the concepts exist in perl. but you don't have to use them! 8^)
>
For completeness, it's worth noting that you don't have to use them in
C++ either! You can use C++ features, like references and a decent
"string" type, merely to get a "better C", without worrying about that
OO stuff!
--
Derek.
------------------------------
Date: Sat, 22 Feb 2003 18:38:05 -0600
From: Joe Creaney <mail@annuna.com>
Subject: Re: Questions about perl.
Message-Id: <3E5817ED.6070605@annuna.com>
I guess I need to learn more about programming.
Mina Naguib wrote:
> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
>
> Joe Creaney wrote:
>
>> I picked up a book on c++. It is very intersting but seems like it is
>> rather cumbersome to program next to perl.
>
>
> C and C++ sacrifice ease of use (from the programmer's prespective) for
> speed and precise control.
>
>> C++ has objects and classes?
>
>
> Yes it does.
>
>> Does perl have simmilar functions?
>
>
> You can do object-oriented programming in perl, yes. That's where the
> similaries end though.
>
> See http://www.perldoc.com/perl5.8.0/pod/perl.html , specifically
> perboot, perltoot, perltooc and perlbot.
>
> Best of luck.
>
>
> -----BEGIN xxx SIGNATURE-----
> Version: GnuPG v1.0.6 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQE+V+FveS99pGMif6wRAqKtAKDnAGI019mcywgUwq50drCj85lNvACZATpN
> DrbNEtrPHH57RDqYb+QR9O0=
> =DfEi
> -----END PGP SIGNATURE-----
>
------------------------------
Date: Sat, 22 Feb 2003 20:03:41 -0500
From: "chris" <cpb6043@osfmail.rit.edu>
Subject: Re: setting permissions on my server for cgi
Message-Id: <3e581d89@news.isc.rit.edu>
"Bob Walton" <bwalton@rochester.rr.com> wrote in message
news:3E57FB52.9080000@rochester.rr.com...
> chris wrote:
>
> ...
>
> > i do my best to read the documentation, but it's very frustrating
> with > the amount of reading required. it requires time, and patience
> that i
> do not often have to devote to this.
>
> Then hire a programmer to do your programming for you.
i'm not going to hire a programmer to do my work, i like to program for fun.
i'm doing this all on my own mind you, it's not easy.
>
> > i tried doing use cgi; that didn't work. thanks anyway.what newsgroup
should
> > i try posting this to?
> ...
>
> > "Bob Walton" <bwalton@rochester.rr.com> wrote
>
> >>Have you followed everything in the FAQ? (that's perldoc -q 500). Oh,
> >>guess not -- it says there to submit requests like yours to a different
> >>newsgroup. Where they talk about server configuration and file
> ...
>
>
> What newsgroup did it suggest when you took the two seconds it takes to
> type:
>
> perldoc -q 500
i don't even know where i'm supposed to type that.
>
> ? BTW, posting to a newsgroup, including
> comp.infosystems.www.authoring.cgi, should come *after* having read all
> the documentation and FAQ's and making a serious attempt at solving the
> problem yourself. Not only is reading the docs etc faster and more
> reliable, it also avoids sending millions of copies of the same old
> question to newsservers all over the world and wasting the time of
> thousands of people who, believe it or not, are eager to help with
> questions that aren't FAQ's. Harsh? Not really. What is harsh is when
> you get "plonked" (put on newsreader autorejection lists) by the people
> who could have helped you.
so far, the docs have not helped me at all. they're not easy to read, and
even though they're very thorough that might also make it part of their
weakness, because it discourages a large portion of casual programmers such
as myself who are simply trying to learn at their own pace without being
overwhelmed with information.
>
> Also, the more information you can supply, the better. Statements like
> "that didn't work" (above) are not helpful at all. What did it do that
> was different from what the documentation says? Or you expected? Did
> it generate any error messages? If so, what *exactly* did they say? Etc.
if you want to see the exact error message, simply try to execute the script
on the server. your guess is as good as mine as to what is the cause of the
error message
> --
> Bob Walton
>
>
------------------------------
Date: Sun, 23 Feb 2003 01:50:30 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: setting permissions on my server for cgi
Message-Id: <3e5820b5.9016616@news.erols.com>
"chris" <cpb6043@osfmail.rit.edu> wrote:
: "Bob Walton" <bwalton@rochester.rr.com> wrote in message
: news:3E57FB52.9080000@rochester.rr.com...
: > chris wrote:
: >
: > i do my best to read the documentation, but it's very frustrating
: > with the amount of reading required. it requires time, and patience
: > that i do not often have to devote to this.
: >
: > Then hire a programmer to do your programming for you.
:
: i'm not going to hire a programmer to do my work, i like to program for fun.
: i'm doing this all on my own mind you, it's not easy.
Compounding the difficulty, you're trying to learn two new
technologies at the same time, maybe even three if you're not already
familiar with the OS.
Perl is not CGI, and CGI is not Perl. They can be made to get along
splendidly, but it's important to know each as a separate entity.
Forget about any web server for your first explorations of Perl.
Install Perl on your local machine to try it out, where you'll also
get the complete documentation. Commands like "perldoc -q 500" will
be more meaningful.
A tutorial would be a solid investment. _Learning Perl_ is one of the
most highly regarded works in the library.
: > What newsgroup did it suggest when you took the two seconds it takes to
: > type:
: >
: > perldoc -q 500
:
: i don't even know where i'm supposed to type that.
At a system/shell command prompt.
: so far, the docs have not helped me at all. they're not easy to read, and
The perlfaq documents are your best friends. Even if an exact
solution to your problem is not given, they will at least give you an
idea on what document to read next.
: > Also, the more information you can supply, the better. Statements like
: > "that didn't work" (above) are not helpful at all. What did it do that
: > was different from what the documentation says? Or you expected? Did
: > it generate any error messages? If so, what *exactly* did they say? Etc.
:
: if you want to see the exact error message, simply try to execute the script
: on the server.
The exact error message will be in the server logs. An internal
server error page typically has no useful information, amounting to
little more than "that didn't work."
: your guess is as good as mine as to what is the cause of the
: error message
Any guesses would be just that, since you have not shared a listing of
the non-functional program.
------------------------------
Date: Sat, 22 Feb 2003 23:56:17 GMT
From: Jeffrey Lee <jeff@lee-burgin.com>
Subject: Simple Pattern Problem?
Message-Id: <BA7D4E53.C4B8%jeff@lee-burgin.com>
Ah, it should work, but it doesn't. I'm a relative Perl newbie, but this
seems awfully simple:
I've got the following:
@samples = grep /$mat_type/, <INPUTFILE>;
This gives me nothing in @samples. $mat_type is VAL CLASS 100K
However, if I change the line to :
@samples = grep /VAL CLASS 100K/, <INPUTFILE>;
I get only the lines with the matching text, as I expected.
Any suggestions?
------------------------------
Date: Sun, 23 Feb 2003 01:41:09 GMT
From: Steve Grazzini <s_grazzini@hotmail.com>
Subject: Re: Simple Pattern Problem?
Message-Id: <VEV5a.40054$ma2.11185080@twister.nyc.rr.com>
Jeffrey Lee <jeff@lee-burgin.com> writes:
>
> I've got the following:
>
> @samples = grep /$mat_type/, <INPUTFILE>;
>
> This gives me nothing in @samples. $mat_type is VAL CLASS 100K
That's hard to believe...
Maybe if you post a complete example someone
will be able to tell you what's going on.
e.g.
#!/usr/bin/perl -w
my $mat_type = "VAL CLASS 100K";
my @samples = grep /$mat_type/, <DATA>;
print for @samples;
__END__
VAL CLASS 200K
VAL CLASS 100K
--
Steve
------------------------------
Date: Sun, 23 Feb 2003 01:06:52 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: sorting multidimensional arrays on one subkey
Message-Id: <3E581E9E.56ACC386@acm.org>
Bob wrote:
>
> I'm hoping someone can help me, I've been trying to figure out how to
> do this and just running into a brick wall.
>
> I have an array structure like this:
>
> $arr[$i][0] = sum of array[$i][1..endofarray]
>
> So I might have data like this:
>
> $arr[0][0]=10; ##10 = 3 +2+3+1+2
> $arr[0][1]=3;
> $arr[0][2]=2;
> $arr[0][3]=3;
> $arr[0][4]=1;
> $arr[0][5]=2;
> $arr[1][0]=15; ##15= 1+9+1+1+1+2
> $arr[1][1]=1;
> $arr[1][2]=9;
> $arr[1][3]=1;
> $arr[1][4]=1;
> $arr[1][5]=1;
> $arr[1][6]=2;
> $arr[2][0]=5; ## 5 = 3+2
> $arr[2][1]=3;
> $arr[2][2]=2;
>
> and so forth. I want to order them by their length, $arr[$i][0]
^^^^^^ ^^^^^^^^^^^
By their length:
@arr = sort { @$a <=> @$b } @arr;
Or by the value in $arr[$i][0]
@arr = sort { $a->[0] <=> $b->[0] } @arr;
> so that if I do this
>
> $mylength = @arr;
> $q = 0;
> while ($q < $mylength)
> {
> print "$arr[$q][0]\n";
> }
Why would you do that? Since you don't change the value of $q that will
always print $arr[0][0]. The usual way to do that in perl is:
for ( @arr ) {
print "$_->[0]\n";
}
> Eventually what I want to do is keep the top N arrays and throw the
> rest away, which I can do once I order them.
$N = 10;
@keep = ( sort { ... } @arr )[ 0 .. $N - 1 ];
John
--
use Perl;
program
fulfillment
------------------------------
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.
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 4609
***************************************