The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #6 (permalink)  
Old 02-01-2008
KevinADC KevinADC is offline
Registered User
 

Join Date: Jan 2008
Posts: 338
1. open(OUT,'>','outfile'); #???? can u please tell me wats happening here
2. print OUT @array[4..$#array-2]; #???? and here toooo
3. close OUT; #?????

1. opens a new file for writing or opens an existing file for overwriting. Associates it with filehandle OUT.

2. prints the array minus the first 4 and last 2 elements to filehandle OUT, which in this case means the lines of the file. This is called an array slice: @array[n,n...n]. It would be the same as doing this:

shift @array;
shift @array;
shift @array
shift @array;
pop @array;
pop @array;

but the array slice will be much faster for what you are doing because it does not modify the array.

3. closes the file associated with IN filehandle.
Reply With Quote