How to get size of array in bytes in perl?
问题 I need get size of array in perl, but size must to be in bytes. I can not find any function for this. Thanks in advance 回答1: You can do this using the Devel::Size module -> https://metacpan.org/pod/Devel::Size #!/usr/bin/perl use strict; use warnings; use Devel::Size qw(total_size); my @arr = (1, 2, 3, "Foo", "Bar", "Baz", [4, 5, 6], {xyz => 2048}); print "Size: ", total_size(\@arr), " bytes.\n"; On my system this prints: bria@hel:~$ ./size.pl Size: 765 bytes. bria@hel:~$ 来源: https:/