David Anderson writes:
 > Hello All,
 > 
 > I am trying to set up formatted printing and seem to be blocked by use
 > strict.
 > 
 > Code below produces the following errors, so could someone be kind
 > enough to explain why they occur (and more particularly how one should
 > write formatted printing)?
 > 
 > Errors:
 > Use of comma-less variable list is deprecated at line 5.
 > Global symbol "$text" requires explicit package name at line 5.
 > Global symbol "$data" requires explicit package name at line 5.
 > Bareword LINE not allowed while "strict subs" in use
 > 
 > Code:
 > #!/usr/bin/perl -w
 > 
 > use strict;
 > 
 > format LINE =
 > @<<<<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 > $text,             $data
 > .
 > 
 > &PrintStd ("Text", "This is the data");
 > 
 > sub PrintStd() {
 >     my ($text, $data) = @_;
 >     $~ = LINE;
 >     write;       
 > }

Two things wrong. Lexical variables are vilsibile in a format
statement unless they are in scope. Also $_ should be assigned a
string. i.e.

--------------------------------------------------
#!/bin/env perl -w

use strict;

&PrintStd ("Text", "This is the data");

sub PrintStd() {
    my ($text, $data) = @_;
format LINE=
@<<<<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$text,             $data
.
    $~ = "LINE";
    write;       
}
--------------------------------------------------

See 'perldoc perlform' for more detail.

HTH

-- 
Brian Raven
But the possibility of abuse may be a good reason for leaving
capabilities out of other computer languages, it's not a good reason for
leaving capabilities out of Perl.
             -- Larry Wall in <[EMAIL PROTECTED]>
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to