Anno said:
my $fifth = (split)[4];
Anno
ok another stupid question time!
how does the above work for an array?? $fifth is being created but
does not reference the array?
I've tried the following:
foreach $user (@list){
print "$user"; #output prints fine!
my $fifth = (split $user[4]);
print "$fifth"; # gets 0 every time!
}
Joining this thread a little late, and at the risk of being
misunderstood, I am going to suggest that you read the posting guidelines
for this group. The document is available on the WWW at
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html, and is
posted here regularly (thank you Tad).
Reading that document will alert you to the fact that Perl comes with
searchable documentation accessible via the perldoc command (on Windows,
you also get the docs in HTML format). It will also point out that you
should at least have:
use strict;
use warnings;
in your programs.
While, with perldoc, it can sometimes be a little hard to figure out how
to reach the specific bit of information you are seeking, in your case,
it would have been easy to figure out since you are looking for a way of
splitting text into separate fileds. Hence:
perldoc -f split
In most cases, it is far easier and quicker to figure things out using
tools that are readily available on your computer.
Now, the subtle change you made to Anno's answer indicates you are not on
solid ground with your Perl knowledge. I suggest you invest in a book
first, and learn some of the basics first. Remember, one step at a time.
Sinan.