Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^6: split function

by tcheungcm (Novice)
on Jan 26, 2012 at 08:41 UTC ( [id://950043]=note: print w/replies, xml ) Need Help??


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

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.

Replies are listed 'Best First'.
Re^7: split function
by Anonymous Monk on Jan 26, 2012 at 08:53 UTC
Re^7: split function
by tcheungcm (Novice) on Jan 26, 2012 at 08:55 UTC
    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

      The data file is not in code tags

      The code doesn't do anything (it doesn't run)

      Your data file has some "hidden control characters" that mess up the line by line reading. The data lines that you present are not what the actual data is. Its just that simple.

      Create this data file yourself by manually typing it in with vi or notepad or whatever plain text editor that you normally use and you will see that the code works. Don't use copy-and-paste as that would copy these "invisible" wrong characters.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-03-29 08:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found