BrianAtWork
Programmer
Hello,
I have an array of files:
Notice that there are 2 elements in @array, but each element is comma separated. I want a main array to contain all (in this example) 4 elements.
Currently, to accomplish this, I use a function, like this:
This works fine, but I was wondering if there was a better way to do this? I know you can't use something like @mainarray=split(/,/,@array), but are there other, better options?
Thanks in advance!
Brian
I have an array of files:
Code:
my @array=('/tmp/file1,/tmp/files/file1','/tmp/file2,/tmp/files/file2');
Notice that there are 2 elements in @array, but each element is comma separated. I want a main array to contain all (in this example) 4 elements.
Currently, to accomplish this, I use a function, like this:
Code:
my @main_array=&split_array(@array);
sub split_array {
my @files=@_;
my @mainarray=();
foreach my $fileline (@files){
my @temp=split(/,/,$fileline);
push (@mainarray,@temp);
}#end foreach
return @mainarray;
}
This works fine, but I was wondering if there was a better way to do this? I know you can't use something like @mainarray=split(/,/,@array), but are there other, better options?
Thanks in advance!
Brian