Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: trying to identify the exact data stored from dump - [ ' ];

by asham (Novice)
on Jan 12, 2014 at 21:28 UTC ( #1070364=note: print w/ replies, xml ) Need Help??


in reply to Re: trying to identify the exact data stored from dump - [ ' ];
in thread trying to identify the exact data stored from dump - [ ' ];

Hi, Thanks for the help. I was able to resolve \b issue. But now I am running into similar territory again. :(

1) In one of the data (array reference) being obtained by me, I am getting something like below: (Dumper output for an array reference)

$VAR1 = [ " \n" ];

2) the same when printed using Data::Dumper->Dump($arrayReference) gave me following:

$VAR2 = " \n";

And scalar (@$arrayReference) returned 2.

a) Just wondering in what case $VAR1 will not be showing at all? There are two elements and none of the output above, mention about one element at all.

b) What is the best way to get the Data Dump? Am I missing something? till now I had pretty good vibe about Data::Dumper.

Note: here $Data::Dumper::Useqq = 1; too

I am also trying by using $Data::Dumper::Indent=0 to see if that gives me some clue about space or something in Dumper output. But not sure if that will really be helpful for that hidden element.

My sincere apologies for such trivial questions. and thanks a lot for your time.


Comment on Re^2: trying to identify the exact data stored from dump - [ ' ];
Select or Download Code
Re^3: trying to identify the exact data stored from dump - [ ' ];
by moritz (Cardinal) on Jan 13, 2014 at 08:27 UTC

    You get $VAR1 = ...; $VAR2 = ...; when you pass a list or an array to Dumper, and $VAR1 = [...] if you pass an array ref.

    Just wondering in what case $VAR1 will not be showing at all?

    There are two options: with Dump the second parameter specifies how the variable is named; so if you pass a second argument, there'll be now $VAR1.

    The other option is to set the $Data::Dumper::Purity variable, as described in the documentation.

    I personally just use print Dumper $somereference; (and yes, Useqq = 1), which gives the least ambiguous output.

      hi, Thanks a lot for looking into this. Kindly find my replies inline.

      You get $VAR1 = ...; $VAR2 = ...; when you pass a list or an array to Dumper, and $VAR1 = ... if you pass an array ref.

      Asham>>True, I am dealing with an array reference. And I posted two outputs one using Dumper() and one using Dump. Dump showed me only $VAR2, no $VAR1. But it does say 2 elements associated with the arrayReference.

      Just wondering in what case $VAR1 will not be showing at all?

      There are two options: with Dump the second parameter specifies how the variable is named; so if you pass a second argument, there'll be now $VAR1.

      Asham>>I did not pass any second paramter. (thought $VAR and all would be enough). Do you mean that $VAR<xy> where xy is resumed from the last left output? I think for every dump command it will start with $VAR1 unless we pass variable names to second argument of dump? right?

      The other option is to set the $Data::Dumper::Purity variable, as described in the documentation.

      Asham>>let me try this. did not use it as it was mainly for references and I am 100% sure that none of elements in my array being pointed by array reference will be perl command/object/etc.

      I personally just use print Dumper $somereference; (and yes, Useqq = 1), which gives the least ambiguous output.

      Asham>>Till now, I have found them enough but in this case they are not helping. So, what else I could do to identify that hidden element? Did I miss any point you shared above?

Re^3: trying to identify the exact data stored from dump - [ ' ];
by ikegami (Pope) on Jan 14, 2014 at 17:01 UTC
    You should have done Data::Dumper->Dump($arrayReference) as you said you did, but you really did Data::Dumper->Dump(@$arrayReference). If you want to dump an array or hash, pass a reference to it.

      Hi, Thanks for looking into this. But unfortunately I am executing with reference only the same as I quoted earlier i.e. Data::Dumper->Dump($arrayReference) .

      Actually even if one were to try Data::Dumper->Dump(@$arrayReference). They would run into usage error and not an output. But since you asked me that. what was your reason for doubting that? there might be some clue for me in your observation.

      Keeping in mind your doubts. I thought would share with you sample usage and let see if you can point out some error in that.

      #!/usr/bin/perl -w use strict; use Data::Dumper; $Data::Dumper::Useqq = 1; my $abc=['cde','bdef','dummy', " \n"]; print (Data::Dumper->Dump($abc) . "\n"); #this will work fine print (Dumper($abc) . "\n"); #this will work fine print (Data::Dumper->Dump(@$abc) . "\n"); # this will give usage error + as I mentioned earlier. 1;

      Note: this is not my real code. just a simple example of how I am using array reference with this module.

      Output: $VAR1 = "cde"; $VAR2 = "bdef"; $VAR3 = "dummy"; $VAR4 = " \n"; $VAR1 = [ "cde", "bdef", "dummy", " \n" ]; Usage: PACKAGE->new(ARRAYREF, [ARRAYREF]) at /tmp/ab123.pl line 8

      Kindly look into this and let me know if I am missing anything.

      PS: anyway question is

      1) for me why one of the elements(1st element) is not being seen.

      2) what could it possibly be?

      3) and is there any way to identify it?

      Thanks for the help everyone. We were able to resolve the issue by serializing the object in that state to avoid anyone manipulating the output file itself. (was needed as it was remotely execute process.)

      We got all the details using that and helped us identify the data.

      thanks again everyone for your valuable time and suggestions.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2014-12-19 04:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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





    Results (70 votes), past polls