×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

PERL loop problem

PERL loop problem

PERL loop problem

(OP)
I have written the below PERL script to reprocess messages from a failure queue.



It basically browses all the messages in the failure queue to individual files in a directory and then scans those files to determine the originating queue. The script will then move each message in turn from the failure queue to their respective originating queue.



The problem I currently have is that if the value meets the FROM_BOB condition then any subsequent messages gets assigned the same $queue value regardless.



CODE

#!/usr/bin/perl

 

use strict;

 

my $count;

my $queue;

my $var;

my $tancCheck;

my $numOfFilesTMP;

my $numOfFiles;

my $suffix;

 

browseMsgs();

messageMove();

exit(0);

sub browseMsgs 

{

`rm -f MQSIFailMsgs*`;

`./mqcapture -f parmcapt -o MQSIFailMsgs -d`;

}

sub messageMove 

{

       $count=0;

       `rm -f output`;

       $numOfFilesTMP=`ls MQSIFailMsgs* | wc -l`;

       $numOfFiles = $numOfFilesTMP - 1;

       if ( -z './MQSIFailMsgs' ) {

       print "MQSIFailMsgs is empty!\n";

       }

       if ( $count == 0 ){

       $suffix = "";

       } elsif ( $count != 0 ){

       $suffix = $count;

       }

       while ( $count <= $numOfFiles )

       {

       open FAILED, "./MQSIFailMsgs$suffix";

       while(<FAILED>)

             {

              my $queue;

              my $tancCheck;

              ##local $/ = undef;

              $var = $_;

              ($var) =~ m/OPT_APP_GRP(.*)OPT_MSG_TYPE/s;

                     print "line 48 $1\n";

                     if ($1 eq " FROM_BOB ") {

                        open NEXTCHECK, "./MQSIFailMsgs$suffix";

                        $tancCheck =$_;

                        ($tancCheck) =~ m/OPT_MSG_TYPE(.{7})/s;

                              print "line 55 $1\n";

                              if ($1 eq " A_ABCD") {

                              $queue = "FROM_BILL";

                              } else {

                                     $queue = "FROM_BOB";

                                     }

                              close NEXTCHECK;

                     print "line 57 $queue\n";

                     } elsif ($1 eq " SANDRA ") {

                     $queue = "FROM_SANDRA_PP";

                     print "line 60 $1\n";

                     } elsif ($1 eq " BEN_MSGS ") {

                     $queue = "FROM_BEN";

                     print "line 63 $1\n";

                     } elsif ($1 eq " FROM_SUSAN ") {

                     $queue = "FROM_SUSAN";

                     print "line 66 $1\n";

                     } elsif ($1 eq "") {

                     print "line 68 $1\n";

                     $queue ="noQueue";

                     }

              if ($queue eq "noQueue") {

              print "no queue defined!\n"; exit(1);

              }

              `/a/b/c/d/e/f -IMQSI_FAIL -o$queue -mQM_F -L1`;

              $count = $count + 1;

              print "$queue\n";

              open FILE, ">>./output\n";

              print FILE "Message number $count has been put to $queue\n"; close FILE;

 

              }

      close FAILED;

      }

} 



Any ideas?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close