"Since I am begginer I have so many questions and so many errors that I can not understand fast."

I recommend you read "Perl introduction for beginners".

You haven't shown enough of your test script but, if you're using

push (@request, ($sysDescr,$sysUpTime));

to create the @request array, that document will show you a better way:

my @request = ($sysDescr, $sysUpTime);

Perl will tell you about many of the problems in your code if you ask it to. Often these problems are the result of simple typos and have nothing to do with your proficiency with the language. Just add these two lines at the top of all your scripts (as I always do):

use strict; use warnings;

If you're having difficulties understanding the short messages that are produced by those, you can add this (although I'd advise against leaving that line in production code):

use diagnostics;

Another useful one, if your script is performing any I/O, is this (which I often use):

use autodie;

All of those are documented in Pragmas.

"Well the problem is that I do not exactly understand the reference part ..."

I recommend you read "Perl references short introduction".

Specifically with [\@request], you're taking a reference to @request (i.e. \@request); then you create an anonymous array (with [...]) whose only element is an array reference. By removing the '\' (i.e. [@request]), you create an anonymous array whose elements are the values in @request.

Another way of doing this would have been to remove the brackets instead of the backslash (i.e. change [\@request] to \@request). However, there's a subtle difference: [...] creates a new array reference; \@array creates a reference to an existing array. The following script may help in understanding this.

#!/usr/bin/env perl -l use strict; use warnings; my @array = (1, 2, 3); my $array_ref_1 = \@array; my $array_ref_2 = [@array]; my $array_ref_3 = [1, 2, 3]; my $array_ref_ref = [\@array]; use Data::Dumper; print '*** $array_ref_1 = \@array ***'; print Dumper $array_ref_1; print '*** $array_ref_2 = [@array] ***'; print Dumper $array_ref_2; print '*** $array_ref_3 = [1, 2, 3] ***'; print Dumper $array_ref_3; print '*** $array_ref_ref = [\@array] ***'; print Dumper $array_ref_ref; my $array_ref_1_new = \@array; my $array_ref_2_new = [@array]; my $array_ref_3_new = [1, 2, 3]; print "\n"; print 'SAME: $array_ref_1 and $array_ref_1_new'; print "SAME: $array_ref_1 and $array_ref_1_new"; print "\n"; print 'DIFF: $array_ref_2 and $array_ref_2_new'; print "DIFF: $array_ref_2 and $array_ref_2_new"; print "\n"; print 'DIFF: $array_ref_3 and $array_ref_3_new'; print "DIFF: $array_ref_3 and $array_ref_3_new"; print "\n"; print 'SAME: $array_ref_1 and $array_ref_1_new and $array_ref_ref->[0] +'; print "SAME: $array_ref_1 and $array_ref_1_new and $array_ref_ref->[0] +";

Output:

*** $array_ref_1 = \@array *** $VAR1 = [ 1, 2, 3 ]; *** $array_ref_2 = [@array] *** $VAR1 = [ 1, 2, 3 ]; *** $array_ref_3 = [1, 2, 3] *** $VAR1 = [ 1, 2, 3 ]; *** $array_ref_ref = [\@array] *** $VAR1 = [ [ 1, 2, 3 ] ]; SAME: $array_ref_1 and $array_ref_1_new SAME: ARRAY(0x7fa0f202a628) and ARRAY(0x7fa0f202a628) DIFF: $array_ref_2 and $array_ref_2_new DIFF: ARRAY(0x7fa0f2029c68) and ARRAY(0x7fa0f210e2a8) DIFF: $array_ref_3 and $array_ref_3_new DIFF: ARRAY(0x7fa0f2029d40) and ARRAY(0x7fa0f20ca2f0) SAME: $array_ref_1 and $array_ref_1_new and $array_ref_ref->[0] SAME: ARRAY(0x7fa0f202a628) and ARRAY(0x7fa0f202a628) and ARRAY(0x7fa0 +f202a628)

-- Ken


In reply to Re^3: SNMP get request error by kcott
in thread ERROR: The OBJECT IDENTIFIER value "ARRAY(0x1b80628)" is expected in dotted decimal notation. by thanos1983

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.