John W. Krahn wrote: > Daniel Kasak wrote: > >> John W. Krahn wrote: >> >>> perldoc -f binmode >>> >> binmode is what I was after - thanks :) >> > > Then don't forget to use the correct characters for this: "\015" for Carriage > Return and "\012" for Line Feed; as using "\n" may get translated to something > other than just "\012". >
Thanks for that tip. I'll do that. > That depends on what your definition of "working" is. Precedence means that: > > open SOURCE, $options->{source} || die "message ..."; > > will only die if $options->{source} contains the string '' or '0' or the > number 0 or the value 'undef'. You need to either add parentheses: > > open( SOURCE, $options->{source} ) || die "message ..."; > > or use the low precedence 'or' operator: > > open SOURCE, $options->{source} or die "message ..."; > Ah. Yes I see what you're saying now. Thanks. > You should also include the $! or the $^E variable in the error message so you > will know *why* the file could not be opened. > > The point I should have made originally and that I will make now is that you > shouldn't use eval() to print an error message from a built-in function. When > open() fails it returns undef and puts the error message in $!. eval() will > not catch this or the error message. eval() will only catch the die() and its > message but since it won't die when open fails... But since you don't > actually want the program to die, why use die in the first place? > I'm reading up on the $! and $^E thing now. I'm still relatively new to this :) >>> You don't have to call the length() function, you can just use a negative >>> number: >>> >>> if ( substr( $fieldnames, -2, 2 ) eq "\r\n" ) { >>> >> Now *that* is useful. Thanks :) >> > > And since the offset -2 can only be two characters long you can omit the > length argument as well: > > if ( substr( $fieldnames, -2 ) eq "\r\n" ) { > Thanks for your tips John. You've pointed me in the right direction on a number of issues :) Dan -- Daniel Kasak IT Developer NUS Consulting Group Level 5, 77 Pacific Highway North Sydney, NSW, Australia 2060 T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989 email: [EMAIL PROTECTED] website: http://www.nusconsulting.com.au -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>