John W. Krahn wrote: > Because when on Windows the CR LF pair is converted to the "\n" > newline character. > perldoc PerlIO > [snip] > :crlf > A layer that implements DOS/Windows like CRLF line endings. On > read converts pairs of CR,LF to a single "\n" newline character. > On write converts each "\n" to a CR,LF pair. Note that this layer > likes to be one of its kind: it silently ignores attempts to be > pushed into the layer stack more than once. >
I see. Well that explains it. > Are you sure that you want to "fix" this? > Certain. I need to find the correct line terminator, and then tell MySQL what it is. > perldoc -f binmode > binmode is what I was after - thanks :) >> # Parse the 1st line of the import file and extract fieldnames >> eval{ >> open SOURCE, $options->{source} >> || die "Failed to open file $options->{source}.\nIs the file >> already open?"; >> }; >> >> if ( $@ ) { >> Gtk2::Ex::Dialogs::ErrorMsg->new_and_run( >> title => "Error opening file!", >> text => $@ >> ); >> return FALSE; >> } >> > > You don't *have* to die if open doesn't work! And besides, using the high > precedence || operator means it won't die even if you wanted it to. > > open SOURCE, '<', $options->{source} or do { > Gtk2::Ex::Dialogs::ErrorMsg->new_and_run( > title => 'Error opening file!', > text => $! > ); > return FALSE; > }; > It's working on my system as-is. I'll check out that precedence thing when I get some spare time. >> if ( substr( $fieldnames, length( $fieldnames ) -2, 2 ) eq "\r\n" ) { >> > > 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 :) -- 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>