I cannot install PDL at the moment because I'm not on "my" machine, but I was wondering why this should lead to a syntax error.
~/sviluppo/perl> cat prova.pl
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
my $mat = [
[3.4603, 1.7529, 1.6990,2.1181],
[ 2.5459,2.5615,2.2525,2.3606],
[ 2.3606, 2.2515, 2.5628,2.5459],
[ 2.1181,1.6982,1.7537,3.4603], # <-- trailing comma
];
print Dumper($mat);
~/sviluppo/perl> perl prova.pl
$VAR1 = [
[
'3.4603',
'1.7529',
'1.699',
'2.1181'
],
[
'2.5459',
'2.5615',
'2.2525',
'2.3606'
],
[
'2.3606',
'2.2515',
'2.5628',
'2.5459'
],
[
'2.1181',
'1.6982',
'1.7537',
'3.4603'
]
];
Neither errors nor warnings. I think that the list constructor doesn't complain about trailing "hanging" commas because you're able to cut-and-paste lines (like in this example) without the need to treat the last line differently.
Is it different when PDL comes in?
Flavio
perl -ple'$_=reverse' <<<ti.xittelop@oivalf
Don't fool yourself.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.