perl var dumper "synopsis"

Q: For simple variables, a perl subroutine dump(‘price’) can dump @price content [1] along with the variable name — “price” in this case. But do we ever need to pass in a reference like dump(\@price, ‘price’)? [1] How about a lexical my $price declared in a nested while inside an if, wrapped in a subroutine?

A: I think sooner or later you may have to pass in ref, perhaps in a very rare and tricky context. To show the variable’s name, u need to pass 2 args in total — ref + name

[1] in dump(), print Data::Dumper->Dump (map {[$_]} @_);

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s