()
たとえば、Perl[]
で使用する場合と、角括弧を使用する場合の配列のサイズをどのように見つけるかの違いは何ですか?
my @myarr = ( # Parenthesis
[ "itemone", "itemoneb", "itemonec" ],
[ "itemtwo", "itemtwob", "itemtwoc" ]
);
my @myarr = [ # Square bracket
[ "itemone", "itemoneb", "itemonec" ],
[ "itemtwo", "itemtwob", "itemtwoc" ]
];
説明ありがとうございます。私はまだこれを理解しようとしていますが、現時点では少し混乱しています。ここでデータを反復処理する方法がまだわかりません。
#!/usr/bin/perl -w
use strict;
use FindBin qw($Bin);
use Cwd;
use Data::Dumper;
my @mynames = (
[ "myname", "mydescription", "mydata"],
[ "myname2", "mydescription2", "mydata2"],
[ "myname3", "mydescription3", "mydata3"],
);
go();
sub go {
start(\@mynames);
}
sub start {
my @input_name = shift;
# This works
#print @input_name->[0][0][0];
#die;
# This Shows
#print Dumper(@input_name);
#$VAR1 = [
# [
# 'myname',
# 'mydescription',
# 'mydata'
# ],
# [
# 'myname2',
# 'mydescription2',
# 'mydata2'
# ],
# [
# 'myname3',
# 'mydescription3',
# 'mydata3'
# ]
# ];
# How do I iterate?
#for my $i (0..@$input_name) {
# my $name = "";
# my $description = "";
# my $data = "";
#
#}
}