in reply to Split into an array
I am not exactly sure what you are trying to do but some part of this should do at least part of it. Assuming the job you want is always the 3rd line of output.
my $arh; my $job; open($arh, "autorep -j $job_name |"); ($job)=(<$arh>)[2]; chop $job; my @job_autorep=split /\s+/, $job;
When I declared my variables $arh and $job on the lines where they first get values assigned, they were left undefined. Moving the declarations to above the open works as I expected. $job gets the third line of output (after the 2 header lines). Then split that and you are set. Be aware that the start and end will be 2 fields each, a date and a time. The parens around $job force array context which is needed to get the 3rd line directly from the output. Also the entire output will be scanned even though all lines other than the 3rd will be ignored. From your post it looks like there will always be exactly 3 lines returned from autorep. I would also strongly recommend that you use the full pathname for autorep or at least set the $ENV{PATH} variable to an explicitly safe value to make sure this perl program gets the data from the correct source.
|
|---|