#!/usr/bin/env perl use 5.022; use warnings; use feature 'refaliasing'; no warnings 'experimental::refaliasing'; @::data = (1 .. 3); say "Data before pop_sum: @::data"; say "Sum of data: ", pop_sum(\@::data); say "Data after pop_sum: @::data"; say '---'; say "Data before pop_sum_ref: @::data"; say "Sum of data: ", pop_sum_ref(\@::data); say "Data after pop_sum_ref: @::data"; sub pop_sum { local our @data = @{+shift}; my $total = 0; say "\tTotal: $total; Data: @data"; while (1) { $total += pop @data; say "\tTotal: $total; Data: @data"; last if $#data < 0; } return $total; } sub pop_sum_ref { \local our @data = shift; my $total = 0; say "\tTotal: $total; Data: @data"; while (1) { $total += pop @data; say "\tTotal: $total; Data: @data"; last if $#data < 0; } return $total; } #### Data before pop_sum: 1 2 3 Total: 0; Data: 1 2 3 Total: 3; Data: 1 2 Total: 5; Data: 1 Total: 6; Data: Sum of data: 6 Data after pop_sum: 1 2 3 --- Data before pop_sum_ref: 1 2 3 Total: 0; Data: 1 2 3 Total: 3; Data: 1 2 Total: 5; Data: 1 Total: 6; Data: Sum of data: 6 Data after pop_sum_ref: #### sub pop_sum_ref { \local our @data = shift; #### sub pop_sum_ref { \our @data = shift; #### Message sent Thank you for taking the time to file a bug report! Please note that mailing lists are moderated, your message may take a while to show up. If you do not receive an automated response acknowledging your message within a few hours (check your SPAM folder and outgoing mail) please consider sending an email directly from your mail client to perlbug@perl.org.