print_r()

M

Mark

Is there anything in Perl that does the equivalent of what print_r()
does in PHP?

Mark
 
B

Brian McCauley

Mark said:
Is there anything in Perl that does the equivalent of what print_r()
does in PHP?

I suppose that would depend on what print_r() does in PHP.

If you can't be bothered to tell us or at least include a URL of a page
that explains what that is, then you shouldn't expect us to be bothered
to punch "PHP print_r" into Google to find out.
 
R

Ric

Mark said:
Is there anything in Perl that does the equivalent of what print_r()
does in PHP?

Mark

Yes:


use Data::Dumper;


print Dumper($yourvar);
print Dumper(%yourhash);

....
 
N

Newsgroups

Le samedi 25 novembre 2006 à 11:04 -0500, Mark a écrit :
Is there anything in Perl that does the equivalent of what print_r()
does in PHP?

I use this :

my $array_or_hash;
use Data::Dumper;
print Dumper($array_or_hash);
 
M

Mumia W. (reading news)

Is there anything in Perl that does the equivalent of what print_r()
does in PHP?

Mark

Yes, use Data::Dumper.

use Data::Dumper;
my @array = ({gander => 'goose', fox => 'vixen'}, 48,
[ 39, 'steps', 'movie' ]);
print Dumper(\@array);
 
J

John Bokma

Tad McClellan said:
What does print_r() do in PHP?

print_r -- Prints human-readable information about a variable. (Which the
OP should have provided)

OP: see if Data::Dumper does what you want.
 
U

Uri Guttman

R> print Dumper($yourvar);
R> print Dumper(%yourhash);

you don't dump hashes like that:

perl -MData::Dumper -e '%h = ( foo =>3, bar => 5 ) ;print Dumper %h'
$VAR1 = 'bar';
$VAR2 = 5;
$VAR3 = 'foo';
$VAR4 = 3;

dumper takes a list to dump which means a hash must be passed as a ref
to dump it.

uri
 
T

Ted Zlatanov

On 26 Nov 2006, (e-mail address removed) wrote:

Tad McClellan said:
print_r -- Prints human-readable information about a variable. (Which the
OP should have provided)

OP: see if Data::Dumper does what you want.

ref $variable

may also be useful. There's a bunch of Devel:: modules that deal with
variable meta-information too.

Ted
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,202
Messages
2,571,055
Members
47,659
Latest member
salragu

Latest Threads

Top