For Programmers: Free Programming Magazines  


Home > Archive > PERL CGI Freelance > March 2004 > spliting (CGI)









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author spliting (CGI)
Ben Wan

2004-03-19, 1:25 pm

could someone tell me what this line means?

$year = (split /:/)[3];

I know
$year = (split /:/); and
$year = (split /:/,$_);
is the same but what is [3] doing there?

Thx...


Tintin

2004-03-19, 1:25 pm


"Ben Wan" <bwan0425@rogers.com> wrote in message
news:fJ3nb.82132$h61.68549@news01.bloor.is.net.cable.rogers.com...
> could someone tell me what this line means?
>
> $year = (split /:/)[3];
>
> I know
> $year = (split /:/); and
> $year = (split /:/,$_);
> is the same but what is [3] doing there?


Why not try it and find out for free. Not too difficult to do, and
certainly quicker than waiting for a sarcastic answer.


Vorxion

2004-03-19, 1:25 pm

In article <bnikhh$11grc4$1@ID-172104.news.uni-berlin.de>, Tintin wrote:
>
>"Ben Wan" <bwan0425@rogers.com> wrote in message
>news:fJ3nb.82132$h61.68549@news01.bloor.is.net.cable.rogers.com...
>
>Why not try it and find out for free. Not too difficult to do, and
>certainly quicker than waiting for a sarcastic answer.


Hmmm. I've never seen that notation before, offhand. But it's obvious to
me what it does. It populates $year with the third element of the
resultant array generated by split().

As for the book you got, it's obviously not helping. Or you're not reading
it. If you want a good perl book that's comprehensive, I told you, get the
O'Reilley copy of "Programming Perl". www.oreilley.com/catalog/pperl3/

As for perl web sites...try starting at www.perl.org. :)

And as for CGI...God, when I learned CGI it was 1994, and I was using
resources off of http://hoohoo.ncsa.uiuc.edu from the Forms Tutorial, along
with demo C source from the NCSA httpd server that predated Apache.

When I learned CGI in perl, I first started with cgi-lib.pl originally, and
then I moved to CGI.pm. The latter is the way to go, definitely.
`perldoc CGI` and start reading.

And as for perldoc, check in your \perl\bin\ directory. And yes (sort of),
'man' is generally a unix command. It's hardly linux-specific. Hell, you
can have man for windows if you install cygwin. :) As it is, you can get
all the man pages out of perldoc, since they're all created from the POD
anyway. `perldoc perl` I just use `man` for the main pages because it's
less typing and I'm used to that command for all other unix docs.

--
Vorxion - Member of The Vortexa Elite
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com