I've got a string input, lets say it's:
junk 0 0 :::1000
junk 0 0 :::1001
junk 0 0 :::1002
junk 0 0 :::1009
I want only the last digit of the 100X number, and I want to place it in a string, and populate an array with these strings.
I have the following code
my @lines = split /^/, $input;
foreach my $line (@lines)
{
my ($garb, $long_ports) = (split /\s*:::\s*/, $line);
my ($garb2, $ports) = (split /10/, $long_ports);
if ($ports < 10)
{
my ($garb3, $ports2) = (split /0/, $ports);
#Add 0 since 0 port is split to empty string
if (length($ports2) == 0)
{
$ports2 = "0$ports2";
}
#Create file name format
@locked_ports = ".X$ports2-lock";
}
}
When I print "@locked_ports" I only get the value .X9-lock, when I want all 4.
How do I make it so @locked_ports contains all 4 of the strings?:
.X0-lock
.X1-lock
.X2-lock
.X9-lock