#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @lines; while () { chomp; if (/^>/) { push @lines, $_; } else { $lines[-1] .= $_; } } print Dumper \@lines; __DATA__ >bob 123456789012345678901234567 8901234567890123 >squeaka TTTGGACCCACAACGTACCACAGGTAT SAJFIJEIFIRVNUTR >trumpet TTTTGAGACCCCCACAAAAGGATTTTT ANDANOTHERLINERT >nautilus AGTCAGTCGATCGTACGTATATAACAC CSADJOIASJNEEESA #### use strict; use warnings; use 5.010; my $return_args; sub RETURN { $return_args = [@_]; no warnings 'exiting'; last 'UNIQUELABEL'; } sub menu { UNIQUELABEL: for (@_) { $_->(); } return @{$return_args} if $return_args; }; say menu sub { say 'go on' }, sub { RETURN 'ended' }, sub { 'never called' },