I haven't used Perl in my life before, and in order to automatize my analysis, I need to use a Perl script. In this script, there is a loop (I hope it is the correct term!) and the script should run the analysis for each subject's folder I defined. However, it only ran it for the first subject's folder and did not go to the second folder as it was defined. The script does not give any error that I could share here. So, I'll only share the script here and the message on the terminal when it ran the analysis for the 1st subject. Could you please suggest how to make this loop work? Looking forward to hearing your suggestion! Thanks in advance.
---- The script:----#!/usr/bin/perl # go to directory with subject-specific sub-directories cd .. #or die "directory not changed!\n"; opendir(DIR,"."); @files = ("SubjectASD202","SubjectASD203"); print "@files"; #say something stupid and unnecessary print "\n Thanks, I'll do the rest for you, just wait a second. \n"; $s = 0; foreach (@files) { # do second level statistical analysis run by run # go to the directory where the fsf-file for stats and post-stats +is stored chdir "/mnt/hgfs/ExpAutism/Scripts"; # create a copy of the fsf file #original file is needed as basis for all subjects: Level1Run1.fsf + - specific file is being overwritten for each run:Level1Run1_spec.fs +f use File::Copy; #create string that will be used for foe-wildcard replacement copy ("Level1Run1.fsf","Level1Run1_spec.fsf") or die "Copy fai +led"; use Tie::File; tie @array, 'Tie::File', "Level1Run1_spec.fsf" or die "arrayin +g failed"; # replace dummies for user and subject with specific values + for (@array) { #replace wildcards with specific titles of subjects s/Subjectx/$files[$s]/g; } untie @array; print "working on the stats concerning $files[$s]\n"; `/usr/local/fsl/bin/feat Level1Run1_spec.fsf`; $s=$s+1; } print "\n +++ DONE +++ \n";
The message while running the first subject's analysis:
SubjectASD202 SubjectASD203 Thanks, I'll do the rest for you, just wait a second. working on the stats concerning SubjectASD202
At the end, it only ran the analysis for the SubjectASD202 and did not run it for the SubjectASD203.
In reply to Loop is not working by ozdemmer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |