Patricia Hinman wrote: > > Hi everyone, Hello,
> I have a \n character in my program that won't go > away. Are you sure? > portion of program: > > open(CAP, ">./captions.txt")|| push(@message, > "Couldn't open the captions.txt file for writing, > $!"); Do you really what to try and write to this file if you can't open it? > chomp(@captions); This will remove the value of the $/ variable from the end of every element of @captions. > for(my$i=0;$i<@caption;$i++){ > $_ = $caption[$i]; Would more properly be written as: for ( @caption ) { Then $_ would be aliased to the actual elements of @caption instead of your way where changing $_ does not change anything in @caption. > s/\n//g; Changes $_, does not change $caption[$i]. > #going to extremes!!! > if(/^\s/){for(my$i=0;$i<$i+1;$i++){if(/\s$/){s/\s$//}else{last}}} > if(/\n/){$oops = "yes, found a space in "} > print "$oops caption $i is $_<BR>"; > } > my($printcap) = join("|",@caption); > $printcap=~ s/\n//g; > print CAP "$printcap";} Quoting a scalar variable is almost always unnecessary. > close(CAP); > > Output: > Variety Story > |Local Church > |Local Fairgrounds > |Bellys full > > Do I have to reinstall perl to get it to remove the > new line? No. > In one of my other files while writing it printed out > a square box for a newline character that I was trying > to remove. Has anyone had this happen? Try this instead: for ( @caption ) { # modify the contents of array tr/\r\n//d; # remove all CRs and NLs from current element s/^\s+//; # remove all whitespace from beginning s/\s+$//; # remove all whitespace from end } if ( open CAP, ">./captions.txt" ) { print CAP join '|', @caption; close CAP; } else { push @message, "Couldn't open the captions.txt file for writing, $!"; } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]