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
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:~$