Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re^2: Dereference inside a regex

by tobias_hofer (Friar)
on Jun 07, 2013 at 16:00 UTC ( #1037695=note: print w/replies, xml ) Need Help??

in reply to Re: Dereference inside a regex
in thread Dereference inside a regex

This is it! Thanks a lot! Thank you for saving me hours of searching!!!
As I am getting blind I will go for weekend now ;-)

Cheers! Tobias

Replies are listed 'Best First'.
Re^3: Dereference inside a regex
by LanX (Bishop) on Jun 08, 2013 at 10:42 UTC
    -- for not using strict! =(

    Cheers Rolf

    ( addicted to the Perl Programming Language)

      I am using strict, warnings and diagnostics - always.
      package MTA::Profile_ARM; use strict; use warnings; use diagnostics; use MTA::MapFileScientist; use vars qw($VERSION @ISA); $VERSION = 1.0; @ISA = qw(MTA::MapFileScientist); my $ProfileInformation = { 'StartLine' => 1, 'ObjAvailable' => 1, 'Compiler' => 'ARM', 'RAMMapping' => { 'RW Data' => 1, 'ZI Data' => 1, }, 'ROMMapping' => { 'Code' => 1, '(inc. data)' => 1, 'RO Data' => 1, } }; sub AnalyseMapFile { my $self = shift; my $MapFile = $self->{MAPFILEINFO}{MAPFILECONTENT}; my $PlaceToPutInformation = $self->{MEMORYMAP}; $self->{MAPFILEINFO}{ProfileInformation} = $ProfileInformation; my $memory_section = ''; my $state = 0; my $memory_size = 0; my $state_symbol = { 1 => 'Image component sizes', 2 => ' Code \(inc\. data\) RO Data RW Data ZI Dat +a Debug Object Name', }; #Each config profile defines its own way how to parse the map-file +. #Process map-file for ( my $iterator = $ProfileInformation->{'StartLine'} ; $iterator < @$MapFile ; $iterator++ ) { chomp($MapFile->[$iterator]); next if (! $MapFile->[$iterator]); if (( $state == 0 ) && ( $MapFile->[$iterator] =~m/$MTA::Profile_ARM::state_symbo +l->{'1'}/)) { ...
      However, it is still not working..
      as soon as I got the issue I will post here what has been
      the root-cause.

      Thanks a lot!


      I have changed the regex from $MTA::Profile_ARM::state_symbol->{'1'} to $state_symbol->{'1'} and its now working fine, without any shouting for not initialized values and stuff. This is because $state_symbol is a function-local scalar, so you cannot refer to it by giving the package-path. This has been the root-cause - quite simple.

      Using strict was showing me at the beginning that I had a typo, it was telling me that $state_smybol was not defined. My mistake has been, that I have not got that its been a typo and extended the scalar by full path to package. Thus I got a different error and I have made things worse by not correctly reading the error msg - sorry for that !


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1037695]
[Discipulus]: see you monks! flying to greece!
[Corion]: Oh, cool! Have fun Discipulus!

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (10)
As of 2018-06-25 18:18 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (128 votes). Check out past polls.