Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9054677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:44:56+00:00 2026-06-16T13:44:56+00:00

I already did some research on Perl script debugging but couldn’t find what I

  • 0

I already did some research on Perl script debugging but couldn’t find what I was looking for.

Let me explain my problem here.

I have a Perl script which is not entering into last while loop it seems cos it is not printing anything inside as instructed.

So, I want to know is there any easier method available to see all lines one by one like we can see in shell script using

set -x

Here is my Perl script code

#!/usr/bin/perl -w

my $ZONEADM = "/usr/sbin/zoneadm list -c";

use strict;
use diagnostics;
use warnings;

system("clear");
print "Enter the app\n";
chomp(my $INS = <>);

print "\nEnter the Symmitrix ID\n";
chomp(my $SYMM = <>);

print "\nEnter the Server\n";
chomp(my $SRV = <>);

print "\nEnter the devices\n";
while (<>) {
  if($_ !~ m/(q|quit)/) {    
    chomp($_);
    my $TEMP_FILE = "/export/home/ptiwari/scripts/LOG.11";
    open (my $FH, '>>', $TEMP_FILE);
    my @arr = split(/:/, $_);
    if($arr[3]) {
      print $FH "/".$INS."db/".$arr[0]."  ".$SYMM."  ".$arr[1]."  ".$arr[2]."  ".$arr[3]."\n";
    }
    else {
      print $FH "/".$INS."db/".$arr[0]."  ".$SYMM."  ".$arr[1]."  ".$arr[2]."\n";
    }
    undef @arr;
    close $FH;
  }
  else {
    exit;
  }
}

my $IS_ZONE = qx($ZONEADM|grep -i $SRV|grep -v global);
if($IS_ZONE) {
  $IS_ZONE = "yes";
}
else {
  $IS_ZONE = "no";    
}    

open(my $FLH, '<', "/export/home/ptiwari/scripts/LOG.11");
my @lines;
while(<$FLH>) {
  my ($GLOBAL_MTPT, $SYM, $SYM_DEV, $SIZE, $NEWFS) = split;
  print $GLOBAL_MTPT."  ".$SYM."  ".$SYM_DEV;
  print "\n";
}

I already tried perl -d but it didn’t show me anything which can help me to troubleshoot why it didn’t enter the while loop.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T13:44:57+00:00Added an answer on June 16, 2026 at 1:44 pm

    Your while(<>) loop doesn’t have sensible termination conditions. The /q|quit/ regex is buggy.

    1. You exit the whole script if any line contains q or quit. You will also exit, if the device descriptions contains things like quill or acquisition. The effect of typing an accidental q is similar to a CtrlC.

    2. The only way to finish the loop and go on with the script is to send an EOF. This requires the user to punch CtrlD into the keyboard, or a file to simply end. Then your script will continue.

    There are some other things wrong/weird with this script.
    Main criticism: (a) all-uppercase variables are informally reserved for Perl and pragmatic modules. Lowercase or mixed case variables work too. (b) Your script contains quite some redundant code. Either refactor it into subs, or rewrite your logic

    Here is an example rewrite that may be easier to debug / may not contain some of the bugs.

    #!/usr/bin/perl
    use strict;
    use warnings;
    use diagnostics;
    
    use constant DEBUG_FLAG => 1;  # set to false value for release
    my $zoneadm_command = "/usr/sbin/zoneadm list -c";
    my $temp_file_name = "/export/home/ptiwari/scripts/LOG.11";
    
    sub prompt { print "\n", $_[0], "\n"; my $answer = <>; chomp $answer; return $answer }
    sub DEBUG  { print STDERR "DEBUG> ", @_, "\n" if DEBUG_FLAG }
    
    system("clear");
    my $app_name = prompt("Enter the app");
    my $symm_id  = prompt("Enter the Symmitrix ID");
    my $server   = prompt("Enter the server name");
    print "Enter the devices.\n";
    print qq(\tTo terminate the script, type "q" or "quit".\n);
    print qq(\tTo finish the list of devices, type Ctrl+D.\n);
    
    open my $temp_file, ">>", $temp_file_name
        or die "Can't open log file: $!";
    
    while (<>) {
      chomp; # remove trailing newline
      exit if /^q(?:uit)?$/; # terminate the script if the input line *is* `q` or `quit`. 
      my @field = split /:/;
      # grep: select all true values
      @field = grep {$_} ("/${app_name}db/$field[0]", $symm_id, @field[1 .. 3]);
      print $temp_file join("  ", @field), "\n";
    }
    close $temp_file;
    
    DEBUG("finished the reading loop");
    
    # get the zones with only *one* extra process
    my @zones = 
        grep {not /global/}
        grep {/\Q$server\E/i}
        map  {chomp; $_}
            qx($zoneadm_command);
    my $is_zone = @zones ? "yes" : "no";
    
    DEBUG("Am I in the zone? $is_zone");
    
    open my $device_file, "<", $temp_file_name or die "Can't open $temp_file_name: $!";
    
    while (<$device_file>) {
      chomp;
      my ($global_mtpt, $sym, $sym_dev) = split;
      print join("  ", $global_mtpt, $sym, $sym_dev), "\n";
      # or short: print join("  ", (split)[0 .. 2]), "\n";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I did a lot search already but couldn't find a straight anwser. I have
I already read the man page and did some googling. Couldn't find anything. Say
I've already did some release scripts with Fabric, but now the task is over
I'm trying to understand the following code: Pattern.compile((.*?):) I already did some research about
I already did some research and ended up with several autocomplete boxes which have
I have read some threads regarding this and I did already take steps to
There are already a couple of questions on finding cycles, but I did not
Already found this page with some helpful hints. Problem is I need to debug
I am new to node.js and I already did my research with no success,
I did some fairly thorough reading and searching through SO and didn't find anything

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.