Ok this is driving me nuts. I Thought I could figure it out myself however I think Its time to ask the monks.
So here it is. I got this piece of code:

foreach ($self->{'sections'}) { ..use $_ here to do stuff.. }

But I can't seem to access the value in $_ I tried to figure out what type of value it was by doing this:

print ref($_);

And I got nothing back. SO I googled around and I found the following snipper:

my $val = $_; use Carp qw(confess); if ( ! defined $val ) { return 'null'; } elsif ( ! ref($val) ) { if ( $val =~ /^-?\d+$/ ) { return 'int'; } elsif ( $val =~ /^-?\d+(\.\d+)?$/ ) { return 'float'; } else { return 'string'; } } else { my $type = ref($val); if ( $type eq 'HASH' || $type eq 'ARRAY' ) { return 'array'; } elsif ( $type eq 'CODE' || $type eq 'REF' || $type eq 'GLOB' | +| $type eq 'LVALUE' ) { return $type; } else { # Object... return 'obj'; } }

This code also returned nothing. When I just print $_ I get a value 300 something (I think this is the amount of dimentions the array has). This snipper will show you how the Variable is defined as is.

my $sections = (qx!rabin -Svv $filename!); my @detected_sections = (); while ($sections =~ m/idx\=(\d*) address=(0x(\d|[a-f])*) offset=(0x(\d +|[a-f])*) size=(\d*) align=(0x(\d|[a-f])*) perm=((r|w|x|-){4}) name=( +.*)/gi) { my %section_int = ( index => $1, address => $2, offset => $4, size +=> $6, align => $7, rights => $9, name => $11 ); push (@detected_sections, %section_int); } $report->{'sections'} = @detected_sections;

So am I stupid to guess that the foreach will do foreach array and I would get a hash but I can't use the $_ still in anyway.
So My Question is, What am I doing wrong? And how can I use the $_ in question?


Thanks in advance!
--Robin

In reply to Variable Unusable? by RobinV

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.