Mailing List Archive

format terminating char
Having just seen this message in c.l.perl.misc:

--- snip ---
comp.lang.perl.misc #4458 (66 more) [1]
From: "Daniel M. DiPasquo" <dipasquo@tc.cornell.edu>
[1] Formats -- baffling
Date: Thu Aug 24 15:53:30 BST 1995
Lines: 9

Perhaps this is due to my inexperience with using output formats, but I've come
across a baffling situation, trying to debug a script written by someone who is
no longer around.

I have this format:

format STDOUT =
^<<<<<<<<<<<<<<<<~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$formlabel $formvalue
End of article 4458 (of 4491) -- what next? [npq]
--- snip ---

Spot the problem.

:-)

I think it would be a good idea if there was an alternative format
termination character.

Using a dot made more sence when perl was young and people were used
to using a dot to terminate text entry into mail. Times change.

Allowing a format to be terminated with a semicolon on a line by itself
seems reasonable and would avoid nasty surprises when posting examples.

It seems unlikely that anyone would have a format line with just a
semicolon on it so compatibility shouldn't be a problem (and easy
to fix for the odd case where it might be).

Tim.
Re: format terminating char [ In reply to ]
>I have this format:
>
>format STDOUT =
>^<<<<<<<<<<<<<<<<~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
>$formlabel $formvalue
>End of article 4458 (of 4491) -- what next? [npq]
>--- snip ---
>
>Spot the problem.
>
>:-)
>
>I think it would be a good idea if there was an alternative format
>termination character.


Surprise...

format STDOUT =
^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~~
$_
}

actually is already built into perl. But I must admit it doesn't have
a great appeal for me.


andreas
Re: format terminating char [ In reply to ]
Excerpts from the mail message of Tim Bunce:
) comp.lang.perl.misc #4458 (66 more)
) From: "Daniel M. DiPasquo" <dipasquo@tc.cornell.edu>
[...]
) format STDOUT =
) ^<<<<<<<<<<<<<<<<~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
) $formlabel $formvalue
) End of article 4458 (of 4491) -- what next? [npq]
) --- snip ---
[...]
) I think it would be a good idea if there was an alternative format
) termination character.

I think formats should be able to use any of the regular Perl quoting
mechanisms. This may require something akin to //o in case the format
is given as a run-time expression.

If we are going to do this, I'd also like to see OO format usage.
Something like:

$text= new format '^'.'<'x16.'~ ^'.'<'x46, \$formlabel, \$formvalue;
STDOUT->write( $text );
$text->write( STDOUT );
STDOUT->format( $text );
write( STDOUT );
$copy= STDOUT->format;

$text= new format '^'.'<'x16.'~ ^'.'<'x46, undef, \$formvalue;
$text->write( STDOUT, $formlabel );
STDOUT->write( $text, $formlabel );
$string= $text->sprint( $formlabel );

Then old code can be adjusted just slightly to use the new methods:

format( STDOUT, <<END );
^<<<<<<<<<<<<<<<<~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$formlabel $formvalue
END

--
Tye McQueen tye@metronet.com || tye@doober.usu.edu
Nothing is obvious unless you are overlooking something
http://www.metronet.com/~tye/ (scripts, links, nothing fancy)
Re: format terminating char [ In reply to ]
According to Tim Bunce:
> Using a dot made more sence when perl was young and people were used
> to using a dot to terminate text entry into mail. Times change.

But there's nothing wrong with using dot. Only a broken E-Mail
system (or Usenet system) has trouble with it -- and the broken
systems should be fixed, right?
--
Chip Salzenberg, aka <chs@nando.net>
"Hey, it's the Miss Alternate Universe Pageant!"
-- Crow T. Robot, MST3K: "Stranded In Space"
Re: format terminating char [ In reply to ]
> From: Chip Salzenberg <chs@nando.net>
>
> According to Tim Bunce:
> > Using a dot made more sence when perl was young and people were used
> > to using a dot to terminate text entry into mail. Times change.
>
> But there's nothing wrong with using dot. Only a broken E-Mail
> system (or Usenet system) has trouble with it -- and the broken
> systems should be fixed, right?

In an ideal world, which this ain't.

> --
> Chip Salzenberg, aka <chs@nando.net>

Tim.
Re: format terminating char [ In reply to ]
>From: Tim Bunce <Tim.Bunce@ig.co.uk>
>I think it would be a good idea if there was an alternative format
>termination character.
>Using a dot made more sence when perl was young and people were used
>to using a dot to terminate text entry into mail. Times change.
>Allowing a format to be terminated with a semicolon on a line by itself
>seems reasonable and would avoid nasty surprises when posting examples.
>It seems unlikely that anyone would have a format line with just a
>semicolon on it so compatibility shouldn't be a problem (and easy
>to fix for the odd case where it might be).

Why does the semicolon have to be on a line by itself? Unprotected
semicolons (not in strings or wraped in {}) currently anyway. We should keep
'.' at the beginning of a line but deprecate it and allow a semicolon
either on a line by itself or at the end of a values line end a format.

--
Mark Biggar
mab@wdl.loral.com
Re: format terminating char [ In reply to ]
On Fri, 25 Aug 1995, Chip Salzenberg wrote:

> According to Tim Bunce:
> > Using a dot made more sence when perl was young and people were used
> > to using a dot to terminate text entry into mail. Times change.
>
> But there's nothing wrong with using dot. Only a broken E-Mail
> system (or Usenet system) has trouble with it -- and the broken
> systems should be fixed, right?

Yes, that's right. Unfortunately, the broken systems are now nearly
de-facto standards, and pervade the entire Unix community. Good luck on
fixing it. Fixing perl is simpler.

> --
> Chip Salzenberg, aka <chs@nando.net>
> "Hey, it's the Miss Alternate Universe Pageant!"
> -- Crow T. Robot, MST3K: "Stranded In Space"
>

--
Kenneth Albanowski (kjahds@kjahds.com, CIS: 70705,126)
Re: format terminating char [ In reply to ]
> From: Mark A Biggar <mab@wdl.loral.com>
>
> >From: Tim Bunce <Tim.Bunce@ig.co.uk>
> >I think it would be a good idea if there was an alternative format
> >termination character.
> >Using a dot made more sence when perl was young and people were used
> >to using a dot to terminate text entry into mail. Times change.
> >Allowing a format to be terminated with a semicolon on a line by itself
> >seems reasonable and would avoid nasty surprises when posting examples.
> >It seems unlikely that anyone would have a format line with just a
> >semicolon on it so compatibility shouldn't be a problem (and easy
> >to fix for the odd case where it might be).
>
> Why does the semicolon have to be on a line by itself? Unprotected
> semicolons (not in strings or wraped in {}) currently anyway. We should keep
> '.' at the beginning of a line but deprecate it and allow a semicolon
> either on a line by itself or at the end of a values line end a format.
>
I seem to be causing controversy with my recent posts :-)

I suggested 'on a line by itself' simply on the assumption that it
would be a minimal change - I'd not looked at the code in enough detail
to see what would be simple or not.

I'd also be very happy to see:

format FOO {
...
}

adopted as the standard way to define a format (the perly.y syntax
implies this anyway).

To be honest I'm not bothered how it's fixed, I just think it
causes a problem often enough to be worth fixing.

> Mark Biggar
>
Tim.
Re: format terminating char [ In reply to ]
> From: Tye McQueen <tye@metronet.com>
>
> If we are going to do this, I'd also like to see OO format usage.
>
> $text= new format '^'.'<'x16.'~ ^'.'<'x46, \$formlabel, \$formvalue;
> STDOUT->write( $text );
>
That's great as a medium term goal, along with perhaps:

$regex = new REGEX q/^(foo|bar)/;

Tim.