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

Re:{2} Output Separators (Was: changing DB delimiters)

by jeroenes (Priest)
on Jun 20, 2001 at 20:50 UTC ( [id://90076]=note: print w/replies, xml ) Need Help??


in reply to Re: changing DB delimiters
in thread changing DB delimiters

Well, it depends on what you do, actually. I understand that he prints his 'DB' with print @guests. In that case, you need to separate the fields with $,. The $\ is active after each print statement, as appears from:
$OUTPUT_FIELD_SEPARATOR
$OFS
$,
The output field separator for the print operator. Ordinarily the print operator simply prints out its arguments without further adornment. To get behavior more like awk, set this variable as you would set awk's OFS variable to specify what is printed between fields. (Mnemonic: what is printed when there is a "," in your print statement.)

$OUTPUT_RECORD_SEPARATOR
$ORS
$\
The output record separator for the print operator. Ordinarily the print operator simply prints out its arguments as is, with no trailing newline or other end-of-record string added. To get behavior more like awk, set this variable as you would set awk's ORS variable to specify what is printed at the end of the print. (Mnemonic: you set `$\' instead of adding "\n" at the end of the print. Also, it's just like `$/', but it's what you get "back" from Perl.)
So it makes no sense to set $, and $\ to the same value.

Jeroen

Replies are listed 'Best First'.
Re: Output Separators (Was: changing DB delimiters)
by Abigail (Deacon) on Jun 20, 2001 at 22:27 UTC
    So it makes no sense to set $, and $\ to the same value.

    Actually, it does. It makes no sense to not set it to the same value, unless you take care of those things elsewhere. Remember that all the records are collected in a single array, and there's only one print statement, printing out the entire database. Not setting $\ equal to $, makes that your last record has a different format than the others.

    -- Abigail

      It's becoming prettu much a private conversation methinks ;-}.

      I personnally wouldn't put a record separator after the last record. So in this case I would leave $\ alone.

      I think $\ is handy in case you want to loop over the records, using to print to write it. Actually I consider using it more often, as there is an endless number of "\n"s in the average reporting script.

        Whether you would put a record separator after the last record isn't very relevant for this particular case, as it is putting one there.

        Just because you fancy data formats with needless exceptions (handy if you are going to append records....) doesn't mean it's fine to change the data format at hand - without informing the reader about it.

        -- Abigail

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2024-04-19 12:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found