#!/usr/bin/perl -l use strict; use warnings; my $str = "this is an example"; $str =~ s/\s+/ /g; print $str;