Wednesday, September 14, 2011

Difference between 'chomp' and 'chop'?

'chop' functiononly removes the last character completely 'from the scaler, where as 'chomp' function only removes the last character if it is a newline. by default,

chomp only removes what is currently defined as the $INPUT_RECORD_SEPARATOR.
whenever you call 'chomp ', it checks the value of a special variable '$/'. whatever the value of '$/' is eliminated from the scaler. by default the value of '$/' is '\n'

No comments: