sub getconf { while() { chomp; CASE: { /^\[Section1\]$/ && do{&parse_section1(\*CONF); last CASE;}; # More calls like the above }; } } sub parse_section1 { $CONF=shift; while(<$CONF>) { if (/^\[.*\]$/) { #Oops, we reached another section! #Now the next section delimiter is in $_ #Can I put it back in <$CONF>? return; } #Otherwise do something with the input } } #### [Section1] var1=one var2=two var3=three [Section2] user1:pass1:50 user2:pass2:51