![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| perl -write values in a file to @array in perl | meghana | Shell Programming and Scripting | 27 | 06-07-2009 05:05 PM |
| Array length in PERL | anent | Shell Programming and Scripting | 5 | 07-17-2008 04:39 PM |
| how to get last value in an array in perl | meghana | Shell Programming and Scripting | 7 | 02-04-2008 05:12 PM |
| multidimensional array in perl | prkfriryce | Shell Programming and Scripting | 9 | 12-01-2007 04:33 PM |
| split to array in perl | jaganadh | Shell Programming and Scripting | 3 | 07-06-2007 05:29 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
PERL array spacing
lines in:
4,355,384 20,762,557 16,407,173 TOTAL 14,470,261 27,190,250 12,719,989 TOTAL 18,825,645 47,952,807 29,127,162 TOTAL PERL script: open(TOTAL,"grepTOTAL /otl/ds_metric/data_files/modem_times|"); push(@total,<TOTAL>); close(TOTAL); $record = join(" ", @total); $record =~ s/TOTAL//g; @total2 = split (/\s{2,}/, $record); print @total2; gives me this result. 4,355,384 20,762,557 16,407,17314,470,261 27,190,250 12,719,98918,825,645 47,952,807 29,127,16 what im looking for is this: 4,355,384 20,762,557 16,407,173 14,470,261 27,190,250 12,719,989 18,825,645 47,952,807 29,127,162 Difference : there is a space where TOTAL used to be in the latter versioin of the output line. Ive tried a few different ways to substitue the TOTAL word but everything comes back to having no space between the numbers in between the TOTAL word (ex: 16,407,17314,470,261 27,190,250 is what i get 16,407,173 14,470,261 27,190,250 is what i want) can anyone lend me an idea on how to get that space in there while still subbing that TOTAL out easily? -jamison- |
|
||||
|
its me again..
i have added this : $total_record = join(" ", @total); $total_record =~ s/TOTAL//g; @record2 = split (/\s{1,}/, $total_record); for (@record2) { print $_ . "\n"; } to the code and it prints out each element out on a new line correctly. then i can run a a print statement that puts each element on the same line. -jamison- |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|