I have Perl script menu.pl. One of the argument I put from command line of menu is queue = 3. I checked it. Then menu calls function function.pl In this function args->{queue} = 1. I cannot understand why. I don't do anything with it. In menu it is args_100{queue}. In function I put args->{queue}. Where is my mistake?

Can I ask you in a different way. my $que = pop(ARGV); it gives 3. How can I put $que into $args->{queue}?

2 options:

Code

$args->{queue} = $que;

or

Code

$args->{queue} = \$que;

Those 2 statements have slightly different effects/results.

The first one copies the current value of $que and the 2nd one creates a reference to the $que var. If you use the 2nd example, if $que is altered after that assignment, then so too will the value of $args->{queue} change since it's a reference to the $que var.

I use it in a different program. But after that statement print args->{queue} = 1, but supposed to be different. And I don't know why.the line is:

if (!GetOptions($args,"help","dir=s","dev","port=s","end_date=s","pam","xrun","tb","nav","use_pos","basis=s","env=s","final","dev","journals","journals_load","close","no_glck","calc_nav","recycle","check_mzpx","performance","queue") || !$args->{end_date} || !$args->{port} ) { usage(" -port and -end_date are required parameters"); } I print exactly after the line and get 1.Something is wrong.

That is difficult to read, and difficult to maintain. At the very least you should add vertical whitespace i.e., put each option on a separate line.

Here's a cleaned up version.

Code

#!/usr/bin/perl

use strict; use warnings FATAL => 'all'; use Getopt::Long; use Data::Dumper;

I've gone back over this thread and your PM's to me and as I've pointed out several times none of the code you've posted demonstrates your problem and it's clear that you have a minimal level of perl knowledge and probably won't be able to troubleshoot this on your own.

So, I will make this offer; if you provide me (via PM) a zip archive of your scripts and modules, I will spend a reasonable amount of time looking them over to see if I can find where your code is modifying that hash value. I'm assuming your code does lots of things that I can't reasonably duplicate so I may or may not be able to find the cause of the problem.

I don't know why I missed this earlier, maybe it was due to the poor formatting of that code, but the "queue" option is defined as a Boolean flag instead of an an integer. That is why it's being assigned a 1 instead of the 3.

The problem is that I have menu. The menu ask questions, I put my answers as args. I catch $job_queue=pop(@ARGV); 16th element is queue and it is =3, or any number I put. But if I put GetOpts 'dueue=i', program crushes