#!perl -w
use strict;
my $fileopen = $ARGV[0];
my $filesave = $ARGV[1];
open(OUTPUT, ">$filesave");
open(INPUT, "$fileopen");
my $line;
my @riPrimGroup;
my $i;
while( )
{
# Good practice to store $_ value because
# subsequent operations may change it.
$line = $_;
# Good practice to always strip the trailing
# newline from the line.
chomp($line);
foreach( /^PatchMesh/ ) {
my @data = split(/\s+/,$line);
push(@riPrimGroup, \@data);
}
}
close INPUT;
my @riGeo1; my @riGeo2; my @riGeo3; my @riGeo4; my @riGeo5;
@riGeo1 = @{$riPrimGroup[0]};
@riGeo2 = @{$riPrimGroup[1]};
@riGeo3 = @{$riPrimGroup[2]};
@riGeo4 = @{$riPrimGroup[3]};
@riGeo5 = @{$riPrimGroup[4]};
print OUTPUT "Geo1: @riGeo1\n";
print OUTPUT "Geo2: @riGeo2\n";
print OUTPUT "Geo3: @riGeo3\n";
print OUTPUT "Geo4: @riGeo4\n";
print OUTPUT "Geo5: @riGeo5\n";
print OUTPUT "\n";
close OUTPUT;
_BEGIN_FILE_
PatchMesh "bilinear" 123 "periodic" 321 "nonperiodic"
[ ............ array ]
PatchMesh "bilinear" 456 "periodic" 654 "nonperiodic"
[ ............ array ]
PatchMesh "bilinear" 789 "periodic" 987 "nonperiodic"
[ ............ array ]
PatchMesh "bilinear" 012 "periodic" 210 "nonperiodic"
[ ............ array ]
PatchMesh "bilinear" ABC "periodic" DEF "nonperiodic"
[ ............ array ]
PatchMesh "bilinear" GHJ "periodic" KLM "nonperiodic"
_END_FILE_
####
The above code look for a 'string' match Patchmesh
and build a array from that info.
and what I trying to do is to build a for loop by
asignment of the array.
ex.
this is the info I like to build with a for loop
@riGeo1 = @{$riPrimGroup[0]};
@riGeo2 = @{$riPrimGroup[1]};
@riGeo3 = @{$riPrimGroup[2]};
@riGeo4 = @{$riPrimGroup[3]};
@riGeo5 = @{$riPrimGroup[4]};
so I thought about this
for ($i = 0; $i < $#riPrimGroup; $i += 1 ) {
@riGeo$i = @{$riPrimGroup[$i]};
}
but it doesn't work, maybe a join could be used to
build the for loop and append it to the
arrayname 'riGeo+newname'
the idea is to read in a file 'geometry data' extrate
information PatchMesh or another info and build a
ArrayName of how many PatchMesh it is find this way
I could print information about this info and build
the 'geometry' group for export to another format.
regards,
Fredrik Gustafsson