I think if you want to be lazy you can set the env variable $,="\n";
Also, wont this create an array of 3 items? Perhaps you want to throw in a print "$pricelist[1]
\n" instead of print @pricelist. (dont do both though)
Brett Williams wrote:


Hi :)

Ive been working all afternoon trying to get what seems like a fairly
simple outcome with split, but depite trying again & again i can't get
things going. I would very much appreciate any help/insight offered.
What im trying to do is read from a text file and use split then print
to display certain text within the file. Im aware of regular
expressions now, but find them too confusing at this stage (im an
extreme newbie to any programming).
The text file reads,

:Weekly expenses...:
:1002.00:
:125.00:
:61864.35:
:890876.99:
:9.99:

%Member number%
%3054%
%3567%
%3576%
%7845%

I want to print to screen all text between ":" on a new line. I
thought this would be easy :)
The final code i came up with is,

open (INPUT, "file.txt") or die "Error, can't find file\n";
$line = readline(INPUT);
while($line)
{
chomp($line);
@pricelist = split (/\:/, $line);
print @pricelist;
$line = readline(INPUT);
}

For some reason this code prints out the entire contents of the text
file (and fails to display every entry on a new line). Im completely
lost, can anyone help?

Thanks
brettaw





--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to