LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Perl Help (possible split) (https://www.linuxquestions.org/questions/programming-9/perl-help-possible-split-147859/)

fooforon 02-18-2004 10:48 PM

Perl Help (possible split)
 
Hi, I have problems with the out of a script so i was wonder if anyone could help me

I m reading from a database that is set up by pipe only reading in persons name and favorite num

Jamie|8
Joe|45
Jessica|8
bob|7

like that for example

this is hte output of the script

Jamie|8
name: J
fav: a
Jamie|8
name: J
fav: a
Jamie|9
name: J
fav: a
Jamie|10
name: J
fav: a

this is the routine

sub readfile
{
open READ, "tst.db";

while ( $line = <READ>)
{
chomp;
print "$line<br>";
($nam1, $num1) = split (/|/, $line);
print "name: $nam1<br>";
print "fav: $num1<br>";
}


}

I dont understand why the spilt is splitting like that if someone could please help it would be grealy appeiacted

Jamie

Berng 02-19-2004 04:30 AM

($nam1, $num1) = split (/\|/, $line);
BestRegards,
Oleg.

fooforon 02-19-2004 05:53 AM

Thank you for your help


All times are GMT -5. The time now is 02:43 AM.