setting format explicitly

setting format explicitly

am 11.10.2011 22:38:55 von Chris Stinemetz

I am currently just trying to build my table structure for this program.

I am getting the following error:

Any help in resolution or advice is greatly appreciated.


$ ./heh.pl
Can't locate object method "format_name" via package "RAW" (perhaps
you forgot to load "RAW"?) at ./heh.pl line 39, <$fh> line 4288257.



#!/usr/bin/perl

use warnings;
use strict;
use POSIX;
# require "heh_lib.pl";

# my $filepath =
sprintf("/omp/omp-data/logs/OMPROP1/%s.APX",strftime("%y%m%d %H",localtime));
my $filepath = ("/tmp/110923.APX"); # for testing

my $runTime = sprintf("/home/cstinemetz/programs/%s.txt",strftime("%y%m%d% H%M",localtime));

my $fileDate = strftime("%y%m%d%H%",localtime);

open my $fh, '<', $filepath or die "ERROR opening $filepath: $!";
open my $out, '>', $runTime or die "ERROR opening $runTime: $!";

while(<$fh>) {
print if /,HEH/;
}

# my $timeStamp = localtime;#&getDateTime(my $time,0);

format RAW_HEADER =

^>>>>>> HR 17-21 HEH Report @<<<<<<<<<<<<<<<<<<
my $rptType # my $timeStamp

Cell CDM1 CDM2 CDM3 TFU1 TFU2 CCU
CBR1 CBR2 CBR3 CBR4 CBR5 CBR6 EVM TXAMP
CTRM
--------- -------- -------- --------- --------- -------- ---------
-------- -------- -------- -------- -------- -------- --------
-------- --------
..

format RAW =
@<<<<<<<< @||||||| @||||||| @||||||| @||||||| @|||||||| @|||||||
@|||||||| @||||||| @||||||| @||||||| @||||||| @||||||| @|||||||
@||||||| @|||||||
#$cell,$cdm1,$cdm2,$cdm3,$tfu1,$tfu2,$ccu,$cbr1,$cbr2,$cbr3, $cbr4,$cbr5,$cbr6,$evm,$txamp,$ctrm
..

my $rptType = "HEH";
RAW->format_name("RAW_HEADER");
print RAW
sprintf("%10s\t%10s\t%10s\t%10s\t%10s\t%10s\t%10s\t%10s\t%10 s\t%10s\t%10s\t%10s\t%10s\t%10s\t%10s\t%10s\n","Date","Cell" ,"CDM1","CDM2","CDM3","TFU1",
"TFU2","CCU","CBR1","CBR2","CBR3","CBR4","CBR5","CBR6","EVM" ,"TXAMP","CTRM");
RAW->format_name("RAW");

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: setting format explicitly

am 11.10.2011 23:35:53 von jwkrahn

Chris Stinemetz wrote:
> I am currently just trying to build my table structure for this program.
>
> I am getting the following error:
>
> Any help in resolution or advice is greatly appreciated.
>
>
> $ ./heh.pl
> Can't locate object method "format_name" via package "RAW" (perhaps
> you forgot to load "RAW"?) at ./heh.pl line 39,<$fh> line 4288257.

Have you read the format man page:

perldoc perlform


> #!/usr/bin/perl
>
> use warnings;
> use strict;
> use POSIX;
> # require "heh_lib.pl";
>
> # my $filepath =
> sprintf("/omp/omp-data/logs/OMPROP1/%s.APX",strftime("%y%m%d %H",localtime));
> my $filepath = ("/tmp/110923.APX"); # for testing
>
> my $runTime = sprintf("/home/cstinemetz/programs/%s.txt",strftime("%y%m%d% H%M",localtime));
>
> my $fileDate = strftime("%y%m%d%H%",localtime);
>
> open my $fh, '<', $filepath or die "ERROR opening $filepath: $!";
> open my $out, '>', $runTime or die "ERROR opening $runTime: $!";
>
> while(<$fh>) {
> print if /,HEH/;
> }
>
> # my $timeStamp = localtime;#&getDateTime(my $time,0);
>
> format RAW_HEADER =
>
> ^>>>>>> HR 17-21 HEH Report @<<<<<<<<<<<<<<<<<<
> my $rptType # my $timeStamp
>
> Cell CDM1 CDM2 CDM3 TFU1 TFU2 CCU
> CBR1 CBR2 CBR3 CBR4 CBR5 CBR6 EVM TXAMP
> CTRM
> --------- -------- -------- --------- --------- -------- ---------
> -------- -------- -------- -------- -------- -------- --------
> -------- --------
> .
>
> format RAW =
> @<<<<<<<< @||||||| @||||||| @||||||| @||||||| @|||||||| @|||||||
> @|||||||| @||||||| @||||||| @||||||| @||||||| @||||||| @|||||||
> @||||||| @|||||||
> #$cell,$cdm1,$cdm2,$cdm3,$tfu1,$tfu2,$ccu,$cbr1,$cbr2,$cbr3, $cbr4,$cbr5,$cbr6,$evm,$txamp,$ctrm
> .
>
> my $rptType = "HEH";
> RAW->format_name("RAW_HEADER");

A format name is not an object so you can't use it like one.


> print RAW

A format name is not a filehandle so you can't use it like one.


> sprintf("%10s\t%10s\t%10s\t%10s\t%10s\t%10s\t%10s\t%10s\t%10 s\t%10s\t%10s\t%10s\t%10s\t%10s\t%10s\t%10s\n","Date","Cell" ,"CDM1","CDM2","CDM3","TFU1",
> "TFU2","CCU","CBR1","CBR2","CBR3","CBR4","CBR5","CBR6","EVM" ,"TXAMP","CTRM");

That would look cleaner as:

print RAW join( "\t", map sprintf( '%10s', $_ ), qw/ Date Cell CDM1 CDM2
CDM3 TFU1 TFU2 CCU CBR1 CBR2 CBR3 CBR4 CBR5 CBR6 EVM TXAMP CTRM / ), "\n";


> RAW->format_name("RAW");

Again, you can't use a format name as an object.




John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction. -- Albert Einstein

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: setting format explicitly

am 11.10.2011 23:45:08 von Rob Dixon

On 11/10/2011 21:38, Chris Stinemetz wrote:
> I am currently just trying to build my table structure for this program.
>
> I am getting the following error:
>
> Any help in resolution or advice is greatly appreciated.
>
>
> $ ./heh.pl
> Can't locate object method "format_name" via package "RAW" (perhaps
> you forgot to load "RAW"?) at ./heh.pl line 39,<$fh> line 4288257.
>
>
>
> #!/usr/bin/perl
>
> use warnings;
> use strict;
> use POSIX;
> # require "heh_lib.pl";
>
> # my $filepath =
> sprintf("/omp/omp-data/logs/OMPROP1/%s.APX",strftime("%y%m%d %H",localtime));
> my $filepath = ("/tmp/110923.APX"); # for testing
>
> my $runTime = sprintf("/home/cstinemetz/programs/%s.txt",strftime("%y%m%d% H%M",localtime));
>
> my $fileDate = strftime("%y%m%d%H%",localtime);
>
> open my $fh, '<', $filepath or die "ERROR opening $filepath: $!";
> open my $out, '>', $runTime or die "ERROR opening $runTime: $!";
>
> while(<$fh>) {
> print if /,HEH/;
> }
>
> # my $timeStamp = localtime;#&getDateTime(my $time,0);
>
> format RAW_HEADER =
>
> ^>>>>>> HR 17-21 HEH Report @<<<<<<<<<<<<<<<<<<
> my $rptType # my $timeStamp
>
> Cell CDM1 CDM2 CDM3 TFU1 TFU2 CCU
> CBR1 CBR2 CBR3 CBR4 CBR5 CBR6 EVM TXAMP
> CTRM
> --------- -------- -------- --------- --------- -------- ---------
> -------- -------- -------- -------- -------- -------- --------
> -------- --------
> .
>
> format RAW =
> @<<<<<<<< @||||||| @||||||| @||||||| @||||||| @|||||||| @|||||||
> @|||||||| @||||||| @||||||| @||||||| @||||||| @||||||| @|||||||
> @||||||| @|||||||
> #$cell,$cdm1,$cdm2,$cdm3,$tfu1,$tfu2,$ccu,$cbr1,$cbr2,$cbr3, $cbr4,$cbr5,$cbr6,$evm,$txamp,$ctrm
> .
>
> my $rptType = "HEH";
> RAW->format_name("RAW_HEADER");
> print RAW
> sprintf("%10s\t%10s\t%10s\t%10s\t%10s\t%10s\t%10s\t%10s\t%10 s\t%10s\t%10s\t%10s\t%10s\t%10s\t%10s\t%10s\n","Date","Cell" ,"CDM1","CDM2","CDM3","TFU1",
> "TFU2","CCU","CBR1","CBR2","CBR3","CBR4","CBR5","CBR6","EVM" ,"TXAMP","CTRM");
> RAW->format_name("RAW");

You must

use IO::Handle;

at the start of your program to make the 'form_name' method available.

But beware that your program is less than ideal in several other ways as
well, and you need to use 'write' instead of 'print' for your format to
have any effect.

Rob

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: setting format explicitly

am 12.10.2011 09:59:07 von Shlomi Fish

Hello Chris,

On Tue, 11 Oct 2011 15:38:55 -0500
Chris Stinemetz wrote:

> I am currently just trying to build my table structure for this program.
>=20
> I am getting the following error:
>=20
> Any help in resolution or advice is greatly appreciated.
>=20

You shouldn't use the functionality documented in «perldoc perlform=C2=
=BB:

http://perl-begin.org/tutorials/bad-elements/#perlform

Instead look into http://search.cpan.org/dist/Perl6-Form/ .

Regards,

Shlomi Fish

>=20
> $ ./heh.pl
> Can't locate object method "format_name" via package "RAW" (perhaps
> you forgot to load "RAW"?) at ./heh.pl line 39, <$fh> line 4288257.
>=20
>=20
>=20
> #!/usr/bin/perl
>=20
> use warnings;
> use strict;
> use POSIX;
> # require "heh_lib.pl";
>=20
> # my $filepath =3D
> sprintf("/omp/omp-data/logs/OMPROP1/%s.APX",strftime("%y%m%d %H",localtime=
));
> my $filepath =3D ("/tmp/110923.APX"); # for testing
>=20
> my $runTime =3D sprintf("/home/cstinemetz/programs/%s.txt",strftime("%y%m=
%d%H%M",localtime));
>=20
> my $fileDate =3D strftime("%y%m%d%H%",localtime);
>=20
> open my $fh, '<', $filepath or die "ERROR opening $filepath: $!";
> open my $out, '>', $runTime or die "ERROR opening $runTime: $!";
>=20
> while(<$fh>) {
> print if /,HEH/;
> }
>=20
> # my $timeStamp =3D localtime;#&getDateTime(my $time,0);
>=20
> format RAW_HEADER =3D
>=20
> ^>>>>>> HR 17-21 HEH Report @<<<<<<<<<<<<<<<<<<
> my $rptType # my $timeStamp
>=20
> Cell CDM1 CDM2 CDM3 TFU1 TFU2 CCU
> CBR1 CBR2 CBR3 CBR4 CBR5 CBR6 EVM TXAMP
> CTRM
> --------- -------- -------- --------- --------- -------- ---------
> -------- -------- -------- -------- -------- -------- --------
> -------- --------
> .
>=20
> format RAW =3D
> @<<<<<<<< @||||||| @||||||| @||||||| @||||||| @|||||||| @|||||||
> @|||||||| @||||||| @||||||| @||||||| @||||||| @||||||| @|||||||
> @||||||| @|||||||
> #$cell,$cdm1,$cdm2,$cdm3,$tfu1,$tfu2,$ccu,$cbr1,$cbr2,$cbr3, $cbr4,$cbr5,$=
cbr6,$evm,$txamp,$ctrm
> .
>=20
> my $rptType =3D "HEH";
> RAW->format_name("RAW_HEADER");
> print RAW
> sprintf("%10s\t%10s\t%10s\t%10s\t%10s\t%10s\t%10s\t%10s\t%10 s\t%10s\t%10s=
\t%10s\t%10s\t%10s\t%10s\t%10s\n","Date","Cell","CDM1","CDM2 ","CDM3","TFU1",
> "TFU2","CCU","CBR1","CBR2","CBR3","CBR4","CBR5","CBR6","EVM" ,"TXAMP","CTR=
M");
> RAW->format_name("RAW");
>=20



--=20
------------------------------------------------------------ -----
Shlomi Fish http://www.shlomifish.org/
"Star Trek: We, the Living Dead" - http://shlom.in/st-wtld

I invented the term Objectâ€=90Oriented, and I can tell you I did not h=
ave C++ in
mind. â€=94 Alan Kay (Attributed)

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/