8 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
use strict;
my %vars = (
v1 => 9.81221,
v2 => 3.13221,
v7 => -1,
h3 => 'a',
x2 => 'ÄÄÄÄ'
);
print $_ for (sort keys %vars);
Quotein perldata von 5.6.1A literal of the form v1.20.300.4000 is parsed as a string composed of characters with the specified ordinals. This provides an alternative, more readable way to construct strings, rather than use the somewhat less readable interpolation form "\x{1}\x{14}\x{12c}\x{fa0}".
This is useful for representing Unicode strings, and for comparing version ``numbers'' using the string comparison operators, cmp, gt, lt etc. If there are two or more dots in the literal, the leading v may be omitted.
print v9786; # prints UTF-8 encoded SMILEY, "\x{263a}"
print v102.111.111; # prints "foo"
print 102.111.111; # same
QuoteThe marginal benefits of v-strings were greatly outweighed by the potential for Surprise and Confusion.
QuoteNote that since Perl 5.8.1 the single-number v-strings (like v65 ) are not v-strings before the => operator (which is usually used to separate a hash key from a hash value), instead they are interpreted as literal strings ('v65').
8 Einträge, 1 Seite |