I'm fairly new to Perl and my searches for an answer to this question drew thousands of irrelevant matches due to the vagueness of my issue. I was toying with repeating a sequence and Perl appears to be doing arithmetic with the 'x' operator:
#!/usr/bin/perl use strict; use warnings; print "Enter some strings:\n"; my @lines = <>; print 0..9 x 2, "\n"; foreach (@lines) { printf "%20s", $_; }
This produces a header line:
$ ./ex05-02.pl Enter some strings: asdfasdfasdf asdfa asdfasdfasd asdf 0123456789101112131415161718192021222324252627282930313233343536373839 +404142434445464748495051525354555657585960616263646566676869707172737 +475767778798081828384858687888990919293949596979899 asdfasdfasdf asdfa asdfasdfasd asdf
Not 01234567890123456789 as I had expected it to, ultimately I wanted a 20 character header but 0..9 x 2 is being interpreted unexpectedly for me. I would love for anyone to be able to shed some light on why this happening.
In reply to Seemingly odd behavior of sequence by jar00n
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |