
rroo
New User
Mar 26, 2008, 12:41 AM
Post #1 of 2
(819 views)
|
|
perl print adds unwanted leading whitepsace
|
Can't Post
|
|
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:
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"; This produces 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: Note the leading whitespace before 'Ja, ' and before 'En soms'. (In preview post the leading whitespaces seem to have been removed... In hex editor this space is present as a 0x20, so a real space.) Any help?
(This post was edited by rroo on Mar 26, 2008, 12:44 AM)
|