Slice arrays in Perl
arrays, perl, slice, system-calls
Solution
- Array indexes are made with square brackets (`[]`), not parentheses.
- You can get the highest index of an array called `@array` with `$#array`.
- I can't even tell what you're trying to do in your third line, but you probably want to look up the `splice` operator.
That should be enough to complete your assignment.
Problem
I know there are easier ways to do this, but I must demonstrate removing the first seven lines of a system call (top -bn1) and write the results to a file using array slices. I currently am having trouble with the syntax of removing the seven lines, and I'm not sure how to write it to a file. ``` my @top_command = `top -bn1`; @top_command = @top_command(7..@top_command); print @top_command, $file_name; ```