You are very close! First enable run time warnings (the -w flag) and use strict (first 2 lines of code below). There is no sub called main{} in a Perl program this is not Java. I wouldn't put these checks for undef input parameters. The runtime warnings will show error if that happens. Basically have have the right idea and your code runs!
#!/usr/bin/perl -w
use strict;
my @broken = (1,2,3);
my $location = "/home/user/";
find_broken_links( $location, \@broken );
foreach my $var (@broken)
{
print "Returned: $var\n";
}
sub find_broken_links
{
my ($location, $broken_links) = @_;
# other code not shown here
my $var ='X';
push @$broken_links, $var;
}
#prints:
#Returned: 1
#Returned: 2
#Returned: 3
#Returned: X
Update:I see some other posts while I was writing mine. The "stringification" as AnomalousMonk points out is a problem. The code I
wrote just automatically didn't have that condition and so it worked. I would caution against this type of "silent program error". These sub input params will be undefined if there is an error in the calling program. If that is the case, you want to know about it! Otherwise your code would just simply return with apparently no broken links found, which probably is not what you want to have happen!