Nov 25, 2003 #1 sparc20 Programmer Mar 13, 2002 56 GB How can i use the substitution operator for a string variable, lets say $name="John"; with just the initial of the name and "." so it will end up $name="J." ? many thanks
How can i use the substitution operator for a string variable, lets say $name="John"; with just the initial of the name and "." so it will end up $name="J." ? many thanks
Nov 25, 2003 #2 raklet MIS Aug 19, 2003 370 US #Save the first char in memory and then find the rest. Replace everything found in first segment by the saved char and a period $name = "John"; $name =~ s/^(.).+/$1\./; print $name; Upvote 0 Downvote
#Save the first char in memory and then find the rest. Replace everything found in first segment by the saved char and a period $name = "John"; $name =~ s/^(.).+/$1\./; print $name;