#!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( <INPUT> ) { # 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

In reply to Re: build geometry group by Frippe
in thread build geometry group by Frippe

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.