sub shift_until($\@) { #usage: shift_until($somepattern, @list); #this takes a @list and throws away lines until it hits $pattern #$pattern can be a regexp. #if $pattern isn't found, the list is emptied completely. #it's good for parsing through garbage #(hey, i never said it would be useful to everybody) my $pattern = shift; my $array_ref = $_[0]; while (@$array_ref and not $$array_ref[0] =~ /$pattern/) { shift @$array_ref; } (@$array_ref and return 1) or return 0; }