#! perl -slw use strict; sub section1{ # Split into lines my @lines = split'\n', $_[0]; print 'Section 1 got:', $_ for @lines; } sub section2{ print 'Section2', @_; } # placeholder code. sub getconf{ local $/= ''; # Set paragraph mode on *locally* while( ) { section1( $_ ), next if /^\[Section1]/; section2( $_ ), next if /^\[Section2]/; } } getconf(); __DATA__ [Section1] var1=one var2=two var3=three [Section2] user1:pass1:50 user2:pass2:51