Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> Perl >> Snippet

print only the first n elements of an array to a file



open (DEST, "test.txt" )
$i = 1;
foreach (DEST) {
   print DEST $_ ;
   last if $i == 9 ;              # print only 9 items
   $i ++ ;
}
close (DEST)