Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,
I am trying to understand what is causing returns at the end of each print FILE "$line"; statement. I cant seem to get rid of these returns.
open (FILE, "+> $fullpath/$dir/$filename")|| die "cant open file"; print FILE "#stored_email\n"; print FILE "\@email\=\(\'"; foreach $line($all_email) { print FILE "$line"; } print FILE "\'\)"; print FILE "\$SECRETARY_EMAIL = \'$SECRETARY_EMAIL\';\n"; close FILE; }

Thanks in advance for any help

Replies are listed 'Best First'.
Re: why? returns
by Cabrion (Friar) on Feb 10, 2003 at 02:42 UTC
    It must be in your data. Try adding
    chomp $line;
    before the print statement.
Re: why? returns
by jacques (Priest) on Feb 10, 2003 at 02:46 UTC
Re: why? returns
by thelenm (Vicar) on Feb 10, 2003 at 16:43 UTC
    The previous responses will probably solve your problem, but in case they don't, here's something else to try. It's possible that you're running with the -l switch enabled, which will automatically print a newline character every time you print something. Check the top of the program for something like #!/usr/bin/perl -l, and remove the -l, if it's there. And make sure whatever is calling your program isn't passing it the -l switch.

    -- Mike

    --
    just,my${.02}