Printing An Array

Printing An Array

am 27.02.2006 02:34:00 von overkill

Currently I have my script print in a long list .csv file. I need to
print my long list into rows of 20 elements. How can I go about doing
this?

while ($x = )
{

chop $x;
@arr = split /\s+/,$x;
$temp = @arr;
print "$arr[$temp -1],\n";

}

__DATA__
hostname01
Unknown
DL360 G3
M0PCLGP82F





Redhat_ES_3.0




Production


2.4.21-27.ELsmp
hostname03
Unknown
Netra X1











Production


117350-02

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org

Re: Printing An Array

am 27.02.2006 03:23:26 von krahnj

overkill@sadsix.com wrote:
> Currently I have my script print in a long list .csv file. I need to
> print my long list into rows of 20 elements. How can I go about doing
> this?
>
> while ($x = )
> {
>
> chop $x;
> @arr = split /\s+/,$x;
> $temp = @arr;
> print "$arr[$temp -1],\n";
>
> }

Based on your data, this seems to work:

while ( ) {
chomp;
print $_, $. % 18 ? ',' : ",,\n";
}



John
--
use Perl;
program
fulfillment

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org