----- Original Message ----- 
From: "Eric Amick" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, June 13, 2003 9:15 PM
Subject: Re: Reverse of Chomp


> On Fri, 13 Jun 2003 13:49:45 +0000, you wrote:
>
> >Is there a way to reverse chop/chomp
> >
> >I'm reading <STDIN> into an array, then
> >   chomping off the last character of each of the
> >   array elements.
> >
> >Now I'd like to write the array back out
> >  to <STDOUT>, but I want to put the \n's back between
> >  each of the lines.
>
> You've gotten a number of good suggestions.  Let me throw out another
> idea:
>
> $" = "\n";
> print "@array\n";
>
> No doubt someone will tell me how dreadful that is. :-)  I also agree
> with the poster who asked why you chomped in the first place; is there
> really no way to work with the data with the newlines present?

well if that's dreadful then this is at least as bad :-):

$,="\n";
print @array,"";

In any case, I've run into lots of situations where I have to chomp the
input data such as file / directory names or hash keys (of course I don't
know how often I print back out the same thing I'm reading?).

I use the -l command line switch to get this behavior in simple one-liners
from the command line but that won't help here...

>
> -- 
> Eric Amick
> Columbia, MD
>
> _______________________________________________
> Perl-Win32-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to