#!/usr/bin/perl -w $carddata = "hello world "; $carddata =~ m/(.*)\s*/; $carddatatruncated = $1; print $carddatatruncated."end"."\n"; $carddatatruncated = $carddata; #$carddatatruncated =~ s/\s{2,}/ /; # two or more white spaces #$carddatatruncated =~ s/(\s){2,}/ /; # same as above #$carddatatruncated =~ s/ \s*/ /; # one space and then zero or more #$carddatatruncated =~ s/ \s*/ /; # two spaces and then zero or more #$carddatatruncated =~ s/\s\s*/ /; # one white space and then zero or more $carddatatruncated =~ s/\s\s\s*/ /; # two white spaces and then zero or more $carddatatruncated =~ s/\s\s\s*/ /; # two white spaces and then zero or more $carddatatruncated =~ s/\s\s\s*/ /; # two white spaces and then zero or more $carddatatruncated =~ s/\s\s\s*/ /; # two white spaces and then zero or more $carddatatruncated =~ s/\s\s\s*/ /; # two white spaces and then zero or more print $carddatatruncated."end"."\n";