![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to transpose data elements in awk | ahjiefreak | Shell Programming and Scripting | 2 | 05-13-2008 01:44 AM |
| Map - printing all elements - why? | dhanamurthy | High Level Programming | 0 | 04-14-2008 10:19 AM |
| Reomve elements from a path name | kgeasler | Shell Programming and Scripting | 3 | 03-26-2008 10:48 AM |
| Help in extracting only certain elements in file | ahjiefreak | Shell Programming and Scripting | 1 | 12-07-2007 12:20 AM |
| seperate elements of a file | nektarios4u | Shell Programming and Scripting | 1 | 11-02-2007 09:53 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
just want certail elements
I just want to be able to take every 6 value out of an arrays
can someone tell me what i'm doing wrong? the data looks like 1500680,Treverbyn,397,1,2136,4420 and i want the 2 element treverbyn out of every row #hour0.pl my $url = 'http://en19.tribalwars.net/map/tribe.txt'; use LWP::Simple; my $content = get $url; @array=split(/,/, $content); $n=1; print " @array[1,7..56]\n"; $n++; |
| Forum Sponsor | ||
|
|
|
|||
|
Even though you are getting the entire file in a variable, the best is to treat it as if an ordinary file and read the file line-by-line and then split the fields as usual.
Code:
#!/usr/bin/perl -w
my $url = 'http://en19.tribalwars.net/map/tribe.txt';
use LWP::Simple;
my $content = get $url;
my @uid;
open(DAT, "<", \$content) or die $!;
while ($line = <DAT>) {
push(@uid, [split(/,/, $line)]->[1]);
}
close DAT;
use Data::Dumper;
print Dumper(\@uid);
|
|||
| Google The UNIX and Linux Forums |