Home: Perl Programming Help: Intermediate:
what is a different between two variables?



digioleg54
User

Jul 12, 2016, 8:16 AM


Views: 8620
what is a different between two variables?

I have in my function declared variable my $coaa.
Then I have a loop:

foreach my $coa_data ( keys %chart_accounts ) {
$data->{reports}->{$port_code}->{coaa}->{coaa}->{ $coa_data } = 0 ;
}

I want to know difference between $coaa and }->{coaa}->{coaa}-> in the hash. Are they the same or have some difference?


FishMonger
Veteran / Moderator

Jul 12, 2016, 8:38 AM


Views: 8617
Re: [digioleg54] what is a different between two variables?

$coaa is a variable but it's not being used in the code you posted.

The coaa used in that hash key is just a plain simple string. It's not a variable.


(This post was edited by FishMonger on Jul 12, 2016, 8:39 AM)


FishMonger
Veteran / Moderator

Jul 12, 2016, 8:41 AM


Views: 8615
Re: [digioleg54] what is a different between two variables?

Please post beginner level questions like this in the Beginner topic area not the Intermediate area.


digioleg54
User

Jul 12, 2016, 8:44 AM


Views: 8613
Re: [FishMonger] what is a different between two variables?

I understand, but the program is not mi9ne and I don't understand, why DEVELOPER used string instead variable. And more, when I print it using dumper, is says undef


FishMonger
Veteran / Moderator

Jul 12, 2016, 9:03 AM


Views: 8608
Re: [digioleg54] what is a different between two variables?


Quote
I don't understand, why DEVELOPER used string instead variable.


You'll need to ask the developer that question.


Quote
I print it using dumper, is says undef

That would be because it wasn't assigned a value.

I and several others have tried in your other related threads regarding this code to get you to post a more complete sample of the code and the dump output of the hash, but you keep posting small disconnected sections which make it impossible for anyone to help you.

You've been working with perl for more than a year but based on your questions it doesn't appear that you've learned much of anything.


digioleg54
User

Jul 12, 2016, 9:09 AM


Views: 8606
Re: [FishMonger] what is a different between two variables?

That developer is already out. I try to troubleshooting program, which really huge, includes packages and 20 scripts. This particular one parsing txt file and put data to the hash. And I don't understand, why he is trying to put some data, but never did. I can email you the parser and the file, but not sure, if somebody can understand it. He put data into hASH so that then get from hash data and create a report. However, report cannot be, because he is ujsing those string and I don't know why


FishMonger
Veteran / Moderator

Jul 12, 2016, 9:13 AM


Views: 8602
Re: [digioleg54] what is a different between two variables?

Maybe its a typo and he meant to use the $coaa variable but left of the $ sigil.


digioleg54
User

Jul 12, 2016, 9:32 AM


Views: 8600
Re: [FishMonger] what is a different between two variables?

$coaa separate has data, but when I print Dumper
($data->{reports}->{$port_code}->{$coaa}->{ $coa_data }); it says undef.
$coa_data alsop has data.
something is really stupid


FishMonger
Veteran / Moderator

Jul 12, 2016, 9:42 AM


Views: 8597
Re: [digioleg54] what is a different between two variables?

You need to dump each of the vars and inspect the hash structure to verify it has the key structure that you expect based on those vars.


Code
print Dumper($port_code, $coaa, $coa_data, $data);



digioleg54
User

Jul 12, 2016, 10:01 AM


Views: 8595
Re: [FishMonger] what is a different between two variables?

can you tell me how can I put each of them to out file using Dumper on Windows?


FishMonger
Veteran / Moderator

Jul 12, 2016, 10:08 AM


Views: 8592
Re: [digioleg54] what is a different between two variables?

Is this a web app or a command line app?

If it's a command line app, you can use output redirection to redirect the output to a file.

Another option is to open a filehandle and print to that handle instead of the default STDOUT handle