HI,

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

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.