Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Get record separator of a file

by karlgoethebier (Abbot)
on Nov 14, 2012 at 13:11 UTC ( [id://1003796]=note: print w/replies, xml ) Need Help??


in reply to Get record separator of a file

I tested my four subs (my basic intention).

Unfortunately it seems as there was some confusion about recsep, line seperator and record seperator. Normally Tie::File treats every line of a file as record, except one changes this behaviour. Or vice versa, loading a file under Windows with has "\n" as line separator led to that Tie::File loaded all data into $array[0]. After setting the recsep option to \n everything worked as expected.

From the documentation if Tie::File: recsep What is a 'record'? By default, the meaning is the same as for the <...> operator: It's a string terminated by $/, which is probably "\n". (Minor exception: on DOS and Win32 systems, a 'record' is a string terminated by "\r\n".) You may change the definition of "record" by supplying the recsep option in the tie call: tie @array, 'Tie::File', $file, recsep => 'es';.

The correct question should better have been: "How can i get the line seperator from a file...?".

Thank you for help to all and best regards, Karl

«The Crux of the Biscuit is the Apostrophe»

Replies are listed 'Best First'.
Re^2: Get record separator of a file
by davido (Cardinal) on Nov 14, 2012 at 19:36 UTC

    The correct question should better have been: "How can i get the line seperator from a file...?"

    I think a better question would have been, "How can I use Tie::File with text files from diverse platforms?"

    But we eventually got the point, and I'm glad you got it worked out (:crlf layer).


    Dave

      You're right, Dave.

      Karl

      «The Crux of the Biscuit is the Apostrophe»

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-04-25 06:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found