Nov 21, 2013 #1 brittany1 Technical User Joined Aug 17, 2007 Messages 12 Location US Perl: print substr($thevar,0,-4); print "\n"; The above gives me what I want. But it seems that theres a better way. Perl: print "\n", substr($thevar,0,-4); Doesnt give me what I want. Thanks in advance for any help !!
Perl: print substr($thevar,0,-4); print "\n"; The above gives me what I want. But it seems that theres a better way. Perl: print "\n", substr($thevar,0,-4); Doesnt give me what I want. Thanks in advance for any help !!
Nov 21, 2013 #2 yelworcm MIS Joined Oct 11, 2005 Messages 370 Location US I am not sure I see what the difference is. What is it that you want? Upvote 0 Downvote
Nov 22, 2013 #3 1DMF Programmer Joined Jan 18, 2005 Messages 8,795 Location GB Code: print "\n", substr($thevar,0,-4); is printing in list context so outputs the newline then the substring, where as Code: print substr($thevar,0,-4); print "\n"; is two separate statements executed linearly (one after the other), so the newline is output second after the substring. "In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you." "If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!" Free Electronic Dance Music Upvote 0 Downvote
Code: print "\n", substr($thevar,0,-4); is printing in list context so outputs the newline then the substring, where as Code: print substr($thevar,0,-4); print "\n"; is two separate statements executed linearly (one after the other), so the newline is output second after the substring. "In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you." "If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!" Free Electronic Dance Music