use Device::SerialPort; my $port = Device::SerialPort->new( "/dev/ttyS0" ); $port->baudrate(9600); $port->databits(8); $port->stopbits(1); $port->parity("none"); my $string = ''; my $more = 1; while($more) { my $pass = $port->write('S$'); my $end_seen = 0; while ( not $end_seen ) { local $_ = $port->input; if ( $_ ne '' ) { if ( m/S:/ ) { # string start $string = $_; } elsif ( m/:$/ ) { # string end $string .= $_; print $string; # deal with the final string $end_seen=1; $more=0; } else { $string .= $_; } } } }