trantorvega has asked for the wisdom of the Perl Monks concerning the following question:
Hello to everyone. In the last hour I've been trying to format the contents of a file using Perl formats, with no success. A brief example:
I example
Output:my $text = "line 1\0line 2\0line 3"; IO::Handle->format_line_break_characters("\0"); format STDOUT = Text: ^* $text ~~ ^* $text . write;
Text: line 1line 2line 3
II example
Output:my $text = "line 1\nline 2\nline 3"; IO::Handle->format_line_break_characters("\0"); format STDOUT = Text: ^* $text ~~ ^* $text . write;
Text: line 1 line 2 line 3
III example
Output:my $text = "line 1\nline 2\nline 3"; ####IO::Handle->format_line_break_characters("\0"); format STDOUT = Text: ^* $text ~~ ^* $text . write;
Text: line 1 line 2 line 3
Taken straight from the perlform man page "The Field ^* for Variable-Width One-line-at-a-time Text" paragraph.
According to the "Using Fill Mode" paragraph, unless I've misunderstood the context, changing the $FORMAT_LINE_BREAK_CHARACTERS or $: variable should change the characters used for line-breaking.
In the first two examples above the variable is correctly set to "\0", instead of its default value " \n-", but that doesn't appear to make lines in the output break on anything other than "\n".
Any ideas? Any obvious misunderstandings on my part?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl format line breaking, $FORMAT_LINE_BREAK_CHARACTERS apparently ignored
by NetWallah (Canon) on Sep 13, 2012 at 22:21 UTC | |
by Anonymous Monk on Sep 14, 2012 at 01:46 UTC | |
|
Re: Perl format line breaking, $FORMAT_LINE_BREAK_CHARACTERS apparently ignored
by Anonymous Monk on Sep 14, 2012 at 01:17 UTC | |
by trantorvega (Initiate) on Sep 14, 2012 at 08:24 UTC | |
by Anonymous Monk on Sep 14, 2012 at 08:29 UTC |