Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Get record separator of a file

by karlgoethebier (Vicar)
on Nov 14, 2012 at 13:11 UTC ( #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»


Comment on Re: Get record separator of a file
Select or Download Code
Re^2: Get record separator of a file
by davido (Archbishop) 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
Node Status?
node history
Node Type: note [id://1003796]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (12)
As of 2015-07-07 12:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (88 votes), past polls