in reply to Loop is not working

Another problem with your code:

for (@array) { #replace wildcards with specific titles of subjects s/Subjectx/$files[$s]/g; }

You are using a fixed string for a regular expression which means that the first time through the loop the string "Subjectx" will be replaced so that the second time through the loop the string will not exist and nothing will be replaced.

Replies are listed 'Best First'.
Re^2: Loop is not working
by ozdemmer (Novice) on Oct 04, 2018 at 01:42 UTC

    Thanks to everyone for commenting on my question. I just added the following line  use diagnostics; and reran the code. The loop worked successfully, and the result seems to be okay too. However, I received this long and confusing message in the terminal. What does this message mean exactly?

    sluser@localhost Scripts]$ perl Level1Run1_test.pl 1538605204768 addons.update-checker WARN onUpdateCheckComplet +e failed to parse update manifest: [Exception... "Update manifest is +missing a required addons property." nsresult: "0x80004005 (NS_ERROR +_FAILURE)" location: "JS frame :: resource://gre/modules/addons/Addo +nUpdateChecker.jsm :: getRequiredProperty :: line 473" data: no] Sta +ck trace: getRequiredProperty()@resource://gre/modules/addons/AddonUp +dateChecker.jsm:473 < parseJSONManifest()@resource://gre/modules/addo +ns/AddonUpdateChecker.jsm:483 < UpdateParser.prototype.onLoad/parser( +)@resource://gre/modules/addons/AddonUpdateChecker.jsm:655 < UpdatePa +rser.prototype.onLoad()@resource://gre/modules/addons/AddonUpdateChec +ker.jsm:675 < UpdateParser/<()@resource://gre/modules/addons/AddonUpd +ateChecker.jsm:593 1538605204784 addons.update-checker WARN onUpdateCheckComplet +e failed to parse update manifest: [Exception... "Update manifest is +missing a required addons property." nsresult: "0x80004005 (NS_ERROR +_FAILURE)" location: "JS frame :: resource://gre/modules/addons/Addo +nUpdateChecker.jsm :: getRequiredProperty :: line 473" data: no] Sta +ck trace: getRequiredProperty()@resource://gre/modules/addons/AddonUp +dateChecker.jsm:473 < parseJSONManifest()@resource://gre/modules/addo +ns/AddonUpdateChecker.jsm:483 < UpdateParser.prototype.onLoad/parser( +)@resource://gre/modules/addons/AddonUpdateChecker.jsm:655 < UpdatePa +rser.prototype.onLoad()@resource://gre/modules/addons/AddonUpdateChec +ker.jsm:675 < UpdateParser/<()@resource://gre/modules/addons/AddonUpd +ateChecker.jsm:593 1538605204810 addons.update-checker WARN onUpdateCheckComplet +e failed to parse update manifest: [Exception... "Update manifest is +missing a required addons property." nsresult: "0x80004005 (NS_ERROR +_FAILURE)" location: "JS frame :: resource://gre/modules/addons/Addo +nUpdateChecker.jsm :: getRequiredProperty :: line 473" data: no] Stack trace: getRequiredProperty()@resource://gre/modules/a +ddons/AddonUpdateChecker.jsm:473 < parseJSONManifest()@resource://gre +/modules/addons/AddonUpdateChecker.jsm:483 < UpdateParser.prototype.o +nLoad/parser()@resource://gre/modules/addons/AddonUpdateChecker.jsm:6 +55 < UpdateParser.prototype.onLoad()@resource://gre/modules/addons/Ad +donUpdateChecker.jsm:675 < UpdateParser/<()@resource://gre/modules/ad +dons/AddonUpdateChecker.jsm:593 1538605204818 addons.update-checker WARN onUpdateCheckComplet +e failed to parse update manifest: [Exception... "Update manifest is +missing a required addons property." nsresult: "0x80004005 (NS_ERROR +_FAILURE)" location: "JS frame :: resource://gre/modules/addons/Addo +nUpdateChecker.jsm :: getRequiredProperty :: line 473" data: no] Sta +ck trace: getRequiredProperty()@resource://gre/modules/addons/AddonUp +dateChecker.jsm:473 < parseJSONManifest()@resource://gre/modules/addo +ns/AddonUpdateChecker.jsm:483 < UpdateParser.prototype.onLoad/parser( +)@resource://gre/modules/addons/AddonUpdateChecker.jsm:655 < UpdatePa +rser.prototype.onLoad()@resource://gre/modules/addons/AddonUpdateChec +ker.jsm:675 < UpdateParser/<()@resource://gre/modules/addons/AddonUpd +ateChecker.jsm:593 1538605204826 addons.update-checker WARN onUpdateCheckComplet +e failed to parse update manifest: [Exception... "Update manifest is +missing a required addons property." nsresult: "0x80004005 (NS_ERROR +_FAILURE)" location: "JS frame :: resource://gre/modules/addons/Addo +nUpdateChecker.jsm :: getRequiredProperty :: line 473" data: no] Sta +ck trace: getRequiredProperty()@resource://gre/modules/addons/AddonUp +dateChecker.jsm:473 < parseJSONManifest()@resource://gre/modules/addo +ns/AddonUpdateChecker.jsm:483 < UpdateParser.prototype.onLoad/parser( +)@resource://gre/modules/addons/AddonUpdateChecker.jsm:655 < UpdatePa +rser.prototype.onLoad()@resource://gre/modules/addons/AddonUpdateChec +ker.jsm:675 < UpdateParser/<()@resource://gre/modules/addons/AddonUpd +ateChecker.jsm:593 + DONE +++

    Just in case you need to see the code I used again:

    #!/usr/bin/perl use strict; use warnings; use diagnostics; # 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"; my $infile = 'Level1Run1_test.fsf'; my $outfile = 'Level1Run1_test_spec.fsf'; my $program = '/usr/local/fsl/bin/feat'; my @subjects = ("SubjectASD203","SubjectTD106C"); foreach my $subject (@subjects){ open my $fh_IN, '<', $infile or die "Could not open $infile ; $!"; open my $fh_OUT, '>', $outfile or die "Could not open $outfile ; $!"; # replace wildcards with specific titles of subjects while (<$fh_IN>){ s/Subjectx/$subject/g; print $fh_OUT $_; } close $fh_IN; close $fh_OUT; system($program,$outfile) == 0 or die "$program $outfile failed: $?"; } print "\n +++ DONE +++ \n";

    Thanks a ton!

      Hi, that message seems to refer to an issue with your Mozilla-based browser. I don't know how this comes into play in your program; I did look at the source of feat a little bit and saw that it outputs HTML, so maybe related?

      Anyway I wanted to point you to one of many ways to capture all the output from your external command, Capture::Tiny. You could use something like this to examine the output and perhaps see where the source of the message is:

      use Capture::Tiny ':all'; my ($stdout, $stderr, $exit) = capture { system( $program, $outfile ); }; print sprintf('Stderr: >%s< Stdout: >%s<', $stderr, $stdout); if ( $exit != 0 ) { die sprintf('%s exited with status %s.', $program, $exit; }

      Hope this helps!


      The way forward always starts with a minimal test.

      I agree with 1nickt that this looks like error messages from a Mozilla browser. At the moment I don't see the version of feat that 1nickt found launching a browser though - could you point us to where you got feat and its accompanying tools?

      So in other words this isn't Perl outputting these messages, and I think you could probably just ignore them for now, as long as the rest of the code runs and the output looks good.

        Hi everyone,

        Thanks a lot for your help. Everything went smoothly and I could finish this analysis. I would not have had progressed this fast without your inputs. I really appreciated your help.

        Thanks again and have a great weekend!

        Best,