Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perl version 5.6.1 AIX 5.1 - White spaces getting truncated using perl format #7148

Closed
p5pRT opened this issue Mar 3, 2004 · 4 comments
Closed

Comments

@p5pRT
Copy link

p5pRT commented Mar 3, 2004

Migrated from rt.perl.org#27349 (status was 'resolved')

Searchable as RT27349$

@p5pRT
Copy link
Author

p5pRT commented Mar 3, 2004

From AInaganti@bankofny.com

Hi,
We are having a problem with printing reports using perl format. Each
line on our report has to be 133 bytes where 133rd byte is a newline
character.
So we are padding the strings with white spaces. However on the report
the string is getting truncated ( all the white spaces towards the end
are getting truncated. Here is a sample script​:
#!/usr/bin/perl

my $fileName ="/tmp/anita/tempreport.rpt";
my $reportTitle = " " x 49 . "AAA UNMATCHED TRADE STATUS REPORT" . " " x
50;
my $test = "Hello";
my $strlen = length($test);
my $newString = $test . " " x (132-$strlen)."\n";
#my $newString = sprintf("%-132s",$test);
my $slen = length($newString);
print "length = $slen \n";

open(OUTFILE, ">$fileName") or die "Can't open $fileName file\n";

write(OUTFILE);

format OUTFILE_TOP =
1+_________________________________________________________________________________________________________________________________+

@​|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
$reportTitle
PAGE​: @​##########
$%

+_________________________________________________________________________________________________________________________________+
.

format OUTFILE =

^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$newString
.
exit 0

This is the output​:
$ reportpadding.pl
length = 133

Here is the report​:
1+_________________________________________________________________________________________________________________________________+
  AAA UNMATCHED TRADE
STATUS REPORT
PAGE​: 1

+_________________________________________________________________________________________________________________________________+
Hello

This is the version we are using​:
This is perl, v5.6.1 built for aix-thread-multi
(with 1 registered patch, see perl -V for more detail)

Copyright 1987-2001, Larry Wall

Binary build 631 provided by ActiveState Tool Corp.
http​://www.ActiveState.com
Built 12​:48​:19 Mar 13 2002

Is this a known bug? If so was it fixed. Please let us know.

Thanks
Anita Inaganti

________________________________________________________________________
The information in this e-mail, and any attachment therein, is confidential and for use by the addressee only. If you are not the intended recipient, please return the e-mail to the sender and delete it from your computer. Although The Bank of New York attempts to sweep e-mail and attachments for viruses, it does not guarantee that either are virus-free and accepts no liability for any damage sustained as a result of viruses.

@p5pRT
Copy link
Author

p5pRT commented Mar 4, 2004

From @Tux

On Wed 03 Mar 2004 15​:50, "AInaganti@​bankofny.com (via RT)" <perlbug-followup@​perl.org> wrote​:

# New Ticket Created by AInaganti@​bankofny.com
# Please include the string​: [perl #27349]
# in the subject line of all future correspondence about this issue.
# <URL​: http​://rt.perl.org​:80/rt3/Ticket/Display.html?id=27349 >

Hi,
We are having a problem with printing reports using perl format. Each
line on our report has to be 133 bytes where 133rd byte is a newline
character.
So we are padding the strings with white spaces. However on the report
the string is getting truncated ( all the white spaces towards the end
are getting truncated. Here is a sample script​:

This is the way formats are to behave, especially when using ^<<<<

This is no bug, but there is a workaround​:

a5​:/tmp 104 > cat xx.pl
#!/pro/bin/perl

use strict;
use warnings;

format STDOUT =
@​<<<<<<<<<<<<<<<<<<<
$_
.

$_ = "abcdef";
write;
a5​:/tmp 105 > perl xx.pl | cat -ve
abcdef$
a5​:/tmp 106 >

And now make the lines longer​:

a5​:/tmp 110 > cat xx.pl
#!/pro/bin/perl

use strict;
use warnings;

unless (open STDOUT, "|-") {
  while (<>) {
  s/$/" " x (20 - length)/e;
  print;
  }
  exit;
  }

format STDOUT =
@​<<<<<<<<<<<<<<<<<<<
$_
.

$_ = "abcdef";
write;

close STDOUT;
a5​:/tmp 111 > perl xx.pl | cat -ve
abcdef $
a5​:/tmp 112 >

--
H.Merijn Brand Amsterdam Perl Mongers (http​://amsterdam.pm.org/)
using perl-5.6.1, 5.8.0, & 5.9.x, and 806 on HP-UX 10.20 & 11.00, 11i,
  AIX 4.3, SuSE 8.2, and Win2k. http​://www.cmve.net/~merijn/
http​://archives.develooper.com/daily-build@​perl.org/ perl-qa@​perl.org
send smoke reports to​: smokers-reports@​perl.org, QA​: http​://qa.perl.org

@p5pRT
Copy link
Author

p5pRT commented Mar 4, 2004

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Mar 4, 2004

@Tux - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant