Re: Reverse of Chomp...

2003-06-18 Thread Jonathan D Johnston
On Wed, 18 Jun 2003 15:18:31 +0100 Beckett Richard-qswi266,
[EMAIL PROTECTED] wrote:
 Surely the nicest way is to set the output array seperator to \n?

 i.e.

 $\ = \n;
 print @array;

Hi Richard,

I'm afraid your idea won't help George much. If you reread his email,
you will see that he needs to append a \n to _each_ element of @array.
Your suggestion will only add a \n after all of the array elements
have been printed ($\ == $OUTPUT_RECORD_SEPARATOR).

As has been already suggested, setting $ (LIST_SEPARATOR)

{ local $ = \n; print @array\n; }

or, probably better, $, (OUTPUT_FIELD_SEPARATOR)

{ local $, = \n; print @array,''; }

will do the trick quite nicely.

For the difference between '$\', '$',  '$,' see perldoc perlvar.

Regards,
Jonathan D Johnston

 -Original Message-
 From: George Gallen [mailto:[EMAIL PROTECTED]
 Sent: 12 June 2003 21:46
 To: [EMAIL PROTECTED]
 Subject: Reverse of Chomp...


 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.

 Aside from looping through the array, and
print each element followed by a \n to STDOUT
is there an easier way like:

unchop(@array) ; STDOUT = @array ;

 I guess I could write a short subroutine, but didn't
 want to re-invent the wheel, even though there isn't
 much re-inventing in that routine.

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


RE: Reverse of Chomp..(regarding not chomping)

2003-06-14 Thread Carl Jolley
On Fri, 13 Jun 2003, George Gallen wrote:

 Possibly in some cases, yes. In my case no. While
 yes by creating a second working array which is
 chomped would be fine, except for the additional
 memory needed to hold the second array. That also
 assumes that the array contents won't change from
 when it was chomped to when I need to join it back,
 which in my case, will happen, so by not chomping
 in the first place (if you mean by keeping a working
 array and chomping that one). Otherwise it would take
 more coding (for my application) to constantly ignore
 the tailing \n on each element.


The terminal $ in a regex will match either the end of the string OR
the \n at the end of a string.

 [EMAIL PROTECTED] Carl Jolley
 All opinions are my own and not necessarily those of my employer 

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


Re: Reverse of Chomp

2003-06-13 Thread Eric Amick
On Fri, 13 Jun 2003 13:49:45 +, 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?

-- 
Eric Amick
Columbia, MD

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


Re: Reverse of Chomp

2003-06-13 Thread Gerry Green

- 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 +, 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


RE: Reverse of Chomp...

2003-06-12 Thread Scot Robnett
Title: Reverse of Chomp...



Would this 
work?

 map { print "$_ \n" } 
@array;

I think that 
still loops through it though. H.




  -Original Message-From: 
  [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED]On Behalf Of 
  George GallenSent: Thursday, June 12, 2003 3:46 
  PMTo: [EMAIL PROTECTED]Subject: 
  Reverse of Chomp...
  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. 
  Aside from looping through the array, and  print each element followed by a \n to 
  STDOUT  is there an easier way 
  like: 
   unchop(@array) ; STDOUT = @array ; 
  
  I guess I could write a short subroutine, but didn't 
  want to re-invent the wheel, even though there isn't 
  much re-inventing in that routine. 
  Thanks George 

BEGIN:VCARD
VERSION:2.1
N:Robnett;Scot
FN:Scot Robnett
ORG:inSite Internet Solutions
NOTE;ENCODING=QUOTED-PRINTABLE:Low cost web hosting, 50 MB disk space, easy and intuitive browser-based pag=
e builder and control panel, 2000 product shopping cart, contact management,=
 site promotion, and free tech support:=0D=0A=0D=0A	http://www.mawebcenters.=
com/insite2000
TEL;WORK;VOICE:(815) 206-2907
TEL;CELL;VOICE:(815) 790-9687
ADR;WORK;ENCODING=QUOTED-PRINTABLE:;;Square West Center=0D=0A454 W. Jackson St.;Woodstock;IL;60098;United State=
s of America
LABEL;WORK;ENCODING=QUOTED-PRINTABLE:Square West Center=0D=0A454 W. Jackson St.=0D=0AWoodstock, IL 60098=0D=0AUni=
ted States of America
URL;HOME:http://www.insiteful.tv
URL;WORK:http://www.insiteful.tv
EMAIL;PREF;INTERNET:[EMAIL PROTECTED]
EMAIL;INTERNET:[EMAIL PROTECTED]
EMAIL;INTERNET:[EMAIL PROTECTED]
REV:20030223T194915Z
END:VCARD


Re: Reverse of Chomp...

2003-06-12 Thread Michael Higgins
George Gallen 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.
Aside from looping through the array, and
   print each element followed by a \n to STDOUT
   is there an easier way like:
   unchop(@array) ;  = @array ;

I guess I could write a short subroutine, but didn't
want to re-invent the wheel, even though there isn't
much re-inventing in that routine.
Thanks
George
George --

print STDOUT join \n, @array

or

@array = map {$_.=\n[EMAIL PROTECTED];

Cheers!

-- mike higgins

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


RE: Reverse of Chomp...

2003-06-12 Thread Thomas, Mark - BLS CTR
Title: Message



You mean like 
this?

print join "\n", 
@array;

-- Mark 
Thomas 
Thomas.Mark@bls.gov Internet Systems Architect User Technology Associates, 
Inc. 
$_=q;KvtuyboopuifeyQQfeemyibdlfee;; 
y.e.s. ;y+B-x+A-w+s; ;y;y; ;;print;;  

  
  -Original Message-From: George Gallen 
  [mailto:[EMAIL PROTECTED] Sent: Thursday, June 12, 2003 4:46 
  PMTo: [EMAIL PROTECTED]Subject: 
  Reverse of Chomp...
  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. 
  Aside from looping through the array, and  print each element followed by a \n to 
  STDOUT  is there an easier way 
  like: 
   unchop(@array) ; STDOUT = @array ; 
  
  I guess I could write a short subroutine, but didn't 
  want to re-invent the wheel, even though there isn't 
  much re-inventing in that routine. 
  Thanks George 



RE: Reverse of Chomp...

2003-06-12 Thread Tobias Hoellrich
print STDOUT join(qq{\n},@array),qq{\n};

should do it.

Hope this helps
  Tobias

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of George
Gallen
Sent: Thursday, June 12, 2003 2:46 PM
To: [EMAIL PROTECTED]
Subject: Reverse of Chomp...


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. 
Aside from looping through the array, and 
   print each element followed by a \n to STDOUT 
   is there an easier way like: 
   unchop(@array) ; STDOUT = @array ; 
I guess I could write a short subroutine, but didn't 
want to re-invent the wheel, even though there isn't 
much re-inventing in that routine. 
Thanks 
George 

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


RE: Reverse of Chomp...

2003-06-12 Thread Bradley K. Embree
Try:

print STDOUT join \n, @array;

Brad


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of George
Gallen
Sent: Thursday, June 12, 2003 1:46 PM
To: [EMAIL PROTECTED]
Subject: Reverse of Chomp...


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.
Aside from looping through the array, and
   print each element followed by a \n to STDOUT
   is there an easier way like:
   unchop(@array) ; STDOUT = @array ;
I guess I could write a short subroutine, but didn't
want to re-invent the wheel, even though there isn't
much re-inventing in that routine.
Thanks
George

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


RE: Reverse of Chomp...

2003-06-12 Thread George Gallen
Title: Reverse of Chomp...



Thanks 
to all, it seems join("\n",@array) will do exactly
what I 
need. And for the STDOUT part, just tack on the
extra 
\n for the last element.

I'll 
have to look at join again to see what else it can do
as well 
as map.

Thanks 
for the info.
George

  -Original Message-From: George Gallen 
  [mailto:[EMAIL PROTECTED]Sent: Thursday, June 12, 2003 4:46 
  PMTo: [EMAIL PROTECTED]Subject: 
  Reverse of Chomp...
  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. 
  Aside from looping through the array, and  print each element followed by a \n to 
  STDOUT  is there an easier way 
  like: 
   unchop(@array) ; STDOUT = @array ; 
  
  I guess I could write a short subroutine, but didn't 
  want to re-invent the wheel, even though there isn't 
  much re-inventing in that routine. 
  Thanks George