--- "Kipp, James" <[EMAIL PROTECTED]> wrote: > Could someone enlighten me on when it is necessary > to chomp an array. It seems when i write scripts > that have a foreach or a while to iterate through > an array sometimes the chomp is necessary and > sometimes it is not.
chomp(@array); # What are you iterating for? :) chomp(@array = <STDIN>); In short, chomp when you need to get rid of newlines at the end of strings. There is no harm doing it multiple times (just wasteful), and sometimes it is just the last array element that needs chomped. Easily fixed with: chomp($array[-1]); But usually I chomp on the loop, like most people: while (<>) { chomp; ... } If your algorithm doesn't care about the newline, and you are outputing it again then leaving the newline in isn't much of a problem (until you get to the last line - which may/may not have a final newline). Jonathan Paton ===== s''-//--/\\///|-\/\|--\--/-\-/\-//\-|/\\\|/\///|-\--\\\\', s''/-\\\/|///|-|/|/--\--/--//\|\/\||/|/-/\\\-/\///|-\-\-', y'|\/-'3210',$_=join qq\\,map{s|2|10|||s|3|11|||s|^|0|;$_} m|.|g;map{print chr unpack'N',pack'B32','0'x24 .$_}/.{8}/g __________________________________________________ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]