Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
"be consistent"
 
PerlMonks  

Re^4: split function

by tcheungcm (Initiate)
on Jan 26, 2012 at 08:20 UTC ( #950037=note: print w/ replies, xml ) Need Help??


in reply to Re^3: split function
in thread split function

Thanks all. I think the problem is happened on the readline. After I add the line before the split

 print "Line just read is $_\n";

the output is

Line just read is 1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;

Line just read is 21;22;23;24;25;26;27;28;29;30;31;32;33;34;35;36

I also checked the lenght of each line is limited 51. Anyone would have clue?


Comment on Re^4: split function
Download Code
Re^5: split function
by Anonymous Monk on Jan 26, 2012 at 08:31 UTC

    Have a clue about what?

    Hopefully you're sufficiently convinced split function isn't broken, so your question is?

      I don't think split function is an issue. it's something related when I tried to read a file. it only read the line up to length = 51 and then it will continue to read on the nextline. I already checked the file, there is no newline in the file.
        The datafile

        1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;27;28;29;30;31;32;33;34;35;36

        1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;27;28;29;30;31;32;33;34;35;36

        1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;27;28;29;30;31;32;33;34;35;36

        1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;27;28;29;30;31;32;33;34;35;36

        sub split_the_element{ my ($local_fh) = @_; while (<$local_fh>) { chomp; my $size = length $_; print "size $size\n"; foreach my $element (split ';', $_) { printf $fhout "%s,\n", $element; } }
        However, the line get chop after the lengh is >= 51. Is there any workaround which can read the full line?

        size 51

        size 51

        size 51

        size 51

        size 51

        size 51

        size 51

        size 51

        size 51

        size 36

Re^5: split function
by rovf (Priest) on Jan 26, 2012 at 09:21 UTC

    Did you hexdump your data file?

    -- 
    Ronald Fischer <ynnor@mm.st>

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://950037]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2014-04-16 23:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (436 votes), past polls