unwanted leading whitespace when using print

R

rroo

The following bit of code adds unwanted whitespace at the beginning of
some lines. It looks like the /n in the added text is not interpret
correctly. Using komodo debugger I cannot pinpoint the problem. The
generic array is filled correctly, only after the print the output is
incorrect.
See code and output:
<begin code>
my @generic;
my @allGeneric;

# read some lines from file, no specific mark up
# store matching lines in @genreric
FH = open "<", "Some file.txt";

while (<FH>)
{
if ($line =~ /some match/)
{
push (@generic, $line);
}
}
close FH;

#add some trailing text
#remove first element since it si always empty due to push

push (@generic, "\nSee some place: \n");
splice (@generic, 0,1);
push (@allGeneric,"*"x80 . "\n");
push (@allGeneric,@generic);

print "The system folder is ...\n\n";
print "===== Generic actions =====\n";
print "@allGeneric\n";
<end code>

This produces:
<begin output>
The system folder is ...


===== Generic actions =====
********************************************************************************
Ja, we hebben hier een heleboel werk om alles goed te krijgen met
allerlei linefeeds en line dingetjes waar ik niet zo'n goed zicht op
heb in perl gebruik. Daarom is het af en toe ook wel lastig, maar toch
ook wel (heel) erg vaak.

En soms: treedt er een 'panic' of "dubbele quote" op, maar mag dat?


See some place:

<end output>

Note the leading whitespace before 'Ja, ' and before 'En soms'.

Any help?
( I am using
This is perl, v5.8.7 built for MSWin32-x86-multi-thread
(with 7 registered patches, see perl -V for more detail)

Copyright 1987-2005, Larry Wall

Binary build 813 [148120] provided by ActiveState http://www.ActiveState.com
ActiveState is a division of Sophos.
Built Jun 6 2005 13:36:37
)
 
R

rroo

The following bit of code adds unwanted whitespace at the beginning of
some lines. It looks like the /n in the added text is not interpret
correctly. Using komodo debugger I cannot pinpoint the problem. The
generic array is filled correctly, only after the print the output is
incorrect.
See code and output:
<begin code>
my @generic;
my @allGeneric;

# read some lines from file, no specific mark up
# store matching lines in @genreric
FH = open "<", "Some file.txt";

while (<FH>)
{
if ($line =~ /some match/)
{
push (@generic, $line);
}}

close FH;

#add some trailing text
#remove first element since it si always empty due to push

push (@generic, "\nSee some place: \n");
splice (@generic, 0,1);
push (@allGeneric,"*"x80 . "\n");
push (@allGeneric,@generic);

print "The system folder is ...\n\n";
print "===== Generic actions =====\n";
print "@allGeneric\n";
<end code>

This produces:
<begin output>
The system folder is ...

===== Generic actions =====
********************************************************************************
Ja, we hebben hier een heleboel werk om alles goed te krijgen met
allerlei linefeeds en line dingetjes waar ik niet zo'n goed zicht op
heb in perl gebruik. Daarom is het af en toe ook wel lastig, maar toch
ook wel (heel) erg vaak.

En soms: treedt er een 'panic' of "dubbele quote" op, maar mag dat?

See some place:

<end output>

Note the leading whitespace before 'Ja, ' and before 'En soms'.

Any help?
( I am using
This is perl, v5.8.7 built for MSWin32-x86-multi-thread
(with 7 registered patches, see perl -V for more detail)

Copyright 1987-2005, Larry Wall

Binary build 813 [148120] provided by ActiveStatehttp://www.ActiveState.com
ActiveState is a division of Sophos.
Built Jun 6 2005 13:36:37
)

Oops, I just read FAQ 5.39 :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top