perlnewbie has asked for the wisdom of the Perl Monks concerning the following question:
Hey, I've got a question about using a reference to an array in a while loop. My folders with the data from different subjects are named abc_001, abc_002, abc_003 and so on. Now I want to tell my script to go in each subfolder and do some processing steps for alle the subjects.
$i=1; while ($i<=4); {chdir ($i) or die "Konnte Verzeichnis $i nicht öffnen"; foreach ("T1_Map","T2_Map", "PD_Map", "T2STAR_Map") { system ("fslreorient2std $_.nii.gz $_._swapped.nii.gz") system ("bet $_._swapped.nii.gz $_._swappedbrain.nii.gz -m"); } chdir (".."); } continue { $i ++; }
When I name the folder with "1", "2" etc. there is no problem, but I would prefer naming them abc_001, abc_002 etc. Is there a option I define my subjects using an array and referencing them in the while loop, so the while loop uses the subjects from the array? Thanks a lot!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: using an array in a while loop
by choroba (Cardinal) on Jan 31, 2022 at 09:47 UTC | |
|
Re: using an array in a while loop
by davies (Monsignor) on Jan 31, 2022 at 11:41 UTC | |
|
Re: using an array in a while loop
by bliako (Abbot) on Jan 31, 2022 at 12:29 UTC | |
|
Re: using an array in a while loop
by BillKSmith (Monsignor) on Jan 31, 2022 at 16:26 UTC | |
|
Re: using an array in a while loop
by Anonymous Monk on Jan 31, 2022 at 16:38 UTC | |
by hippo (Archbishop) on Jan 31, 2022 at 16:48 UTC |