use warnings; use strict; my $str = "lhs|rhs"; print join " ", split "|", $str; print "\n" . join " ", split "\|", $str; print "\n" . join " ", split "\\|", $str; prints: l h s | r h s l h s | r h s lhs rhs