$/ is just a newline by default. It's there to break the line and set the next shell prompt back to the far left of the screen.
On 32-bit perl,
$ perl -e'print 1<<$_, $/ for 28..36'
268435456
536870912
1073741824
2147483648
1
2
4
8
16
$
Perl
1<<$n is equivalent to
2**$n, not
2**($n+1). The
<< operator is regarded as bitwise by perl, so forces the result into a bitfield, an unsigned int.
As in C, an overflowed int wraps to its low bits[What was I thinking there?]. On 64-bit perl, the above gives,
$ perl -e'print 1<<$_, $/ for 28..36'
268435456
536870912
1073741824
2147483648
4294967296
8589934592
17179869184
34359738368
68719476736
$
For both 32- and 64-bit Perl,
1<<64 == 1.
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.