Push value from one array to another array
#!/usr/bin/perl
use warnings;
my @array = ("One", "Two", "Three", undef, "Five", "Six");
my @newarray = ();
foreach my $element (@array) {
last unless defined ($element);
push @newarray, $element;
}
foreach (@newarray) {
print $_." \n";
}
Related examples in the same category