Aug 21, 2015, 10:20 AM
Post #1 of 3
Continously pushing variables into array
I am extracting some data, and it is in this form:
1 - content1
2 - content2
I need to store content1 and content2 into an array, and the numbers (1,2) keep going until a maximum of 50. I tried using regular expression to catch content1 and content2, but since they have a similar format, I am only grabbing content2.
Here is my code
im getting multiple instantiations of content1 and content2 in the array when i print it. Any ideas how to do this correctly?
while ($file= <INFO>)
if ($file =~ m/^\s*(\d+)\s*(-)\s*(.*)/)
$number_count = $1;
$violation = $3;
for ($number_count = $1; $number_count < 50 ; $number_count++)
push (@violations_array ,$violation);
(This post was edited by FishMonger on Aug 21, 2015, 10:26 AM)