Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^4: Dereference inside a regex

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


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

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!

Cheers
Tobias

Update
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 !

:-)
Cheers!
Tobias


Comment on Re^4: Dereference inside a regex
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1038003]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (10)
As of 2014-12-29 11:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (186 votes), past polls