more transliterations

# unicode is just another aspect
# of "scalar"


binmode(STDOUT, ":utf8");
print u"M\x{0101}ori"  # Māori

#arrays
@x = (1, 2, 'three')
push @x, 'IV';
pop @x;  # 'IV'
shift @x;  # 1
unshift  @x, 1;
splice @x, 1, 2, 'f', 'u';
@x[1] = \@x; 
@x = sort @x;
#unicode has it's own type: unicode
u"unicode literal"
x = unicode('hello world') # u'hello world'
str(x)    # 'hello world'

print u"M\u0101ori"  # Māori

#lists
x = [1, 2, 'three']
x.append('IV')
x.pop()  # 'IV'
x.pop(0) # 1
x.insert(0, 1) # [1, 2, 'three']
x[1:2] = 'fu'  # [1, 'f', 'u']
x[1] = x       
x.sort() #sorts in place, returns None

Python lists methods generally have perl function equivalents.

map
grep

map {$_ ** 2} (0..9);
grep {$_ ** 2 
      if ($_ * 7) =~ /4/} (0..9);
# [4, 36, 49]

map      # no longer considered cool
filter   # so 20th century
# List comprehensions:
[x ** 2 for x in range(10)]
[x ** 2 for x in range(10)
    if '4' in str(x * 7)]
# [4, 36, 49]