From: Piotr R. <Pio...@ne...> - 2002-01-30 13:49:31
|
This simple test program produces strange LDIF file (starts with empty line and doesn't contains ending "-"). Why it is different than examples for OpenLDAP? #!/usr/bin/perl use Net::LDAP::Entry; use Net::LDAP::LDIF; use Data::Dumper; $entry = Net::LDAP::Entry->new(); $entry->changetype('modify'); $entry->dn('cn=test'); $entry->add( attr1 => 'value1', attr2 => [qw(value1 value2)] ); $entry->delete('attr3'); $entry->replace( attr4 => 'newvalue', attr5 => [qw(new values)] ); $ldif = Net::LDAP::LDIF->new("-", "w", encode=>'canonical'); $ldif->{change} = 1; $ldif->write_entry($entry); $ldif->done(); -- Piotr Roszatycki, Netia Telekom S.A. .''`. mailto:Pio...@ne... : :' : mailto:de...@de... `. `' `- |
From: Graham B. <gb...@po...> - 2002-01-30 14:09:19
|
There is no need for an ending "-", the "-" is a separator between actions withing one entry. The newline only happens when outputing to stdout, if you change the output to a file you do not see the newline. Graham. On Wed, Jan 30, 2002 at 02:49:18PM +0100, Piotr Roszatycki wrote: > This simple test program produces strange LDIF file (starts with empty > line and doesn't contains ending "-"). Why it is different than examples > for OpenLDAP? > > #!/usr/bin/perl > use Net::LDAP::Entry; > use Net::LDAP::LDIF; > use Data::Dumper; > > $entry = Net::LDAP::Entry->new(); > $entry->changetype('modify'); > > $entry->dn('cn=test'); > > $entry->add( > attr1 => 'value1', > attr2 => [qw(value1 value2)] > ); > > $entry->delete('attr3'); > > $entry->replace( > attr4 => 'newvalue', > attr5 => [qw(new values)] > ); > > $ldif = Net::LDAP::LDIF->new("-", "w", encode=>'canonical'); > $ldif->{change} = 1; > $ldif->write_entry($entry); > $ldif->done(); > > -- > Piotr Roszatycki, Netia Telekom S.A. .''`. > mailto:Pio...@ne... : :' : > mailto:de...@de... `. `' > `- > > |
From: Piotr R. <Pio...@ne...> - 2002-01-30 15:05:48
|
On Wed, 30 Jan 2002, Graham Barr wrote: > The newline only happens when outputing to stdout, if you change > the output to a file you do not see the newline. Why the output for stdout is different? -- Piotr Roszatycki, Netia Telekom S.A. .''`. mailto:Pio...@ne... : :' : mailto:de...@de... `. `' `- |
From: Graham B. <gb...@po...> - 2002-01-30 15:19:50
|
On Wed, Jan 30, 2002 at 04:05:24PM +0100, Piotr Roszatycki wrote: > On Wed, 30 Jan 2002, Graham Barr wrote: > > The newline only happens when outputing to stdout, if you change > > the output to a file you do not see the newline. > > Why the output for stdout is different? perl -le 'print tell(STDOUT);' So Net::LDAP::LDIF thinks it is not at the start of the file and outputs the blank line. It probably nees to be fixed, but it only happens when the output is really to a terminal, so I don't see the urgency. If you redirect to a file its fine perl -le 'warn tell(STDOUT);' > out 0 at -e line 1. Graham. |
From: Piotr R. <Pio...@ne...> - 2002-01-30 15:45:28
|
> perl -le 'print tell(STDOUT);' > > So Net::LDAP::LDIF thinks it is not at the start of the file and > outputs the blank line. > > It probably nees to be fixed, but it only happens when the output > is really to a terminal, so I don't see the urgency. If you redirect > to a file its fine > > perl -le 'warn tell(STDOUT);' > out > 0 at -e line 1. Ah, I see. Unfortunately: perl -le 'warn tell(STDOUT);' | cat > out -1 at -e line 1. Maybe print "\n" if tell($self->{'fh'}) && $self->{'file'} ne "STDOUT"; would help? -- Piotr Roszatycki, Netia Telekom S.A. .''`. mailto:Pio...@ne... : :' : mailto:de...@de... `. `' `- |
From: Graham B. <gb...@po...> - 2002-01-30 17:24:24
|
On Wed, Jan 30, 2002 at 04:45:11PM +0100, Piotr Roszatycki wrote: > > perl -le 'print tell(STDOUT);' > > > > So Net::LDAP::LDIF thinks it is not at the start of the file and > > outputs the blank line. > > > > It probably nees to be fixed, but it only happens when the output > > is really to a terminal, so I don't see the urgency. If you redirect > > to a file its fine > > > > perl -le 'warn tell(STDOUT);' > out > > 0 at -e line 1. > > Ah, I see. > > Unfortunately: > > perl -le 'warn tell(STDOUT);' | cat > out > -1 at -e line 1. Ah. > Maybe > > print "\n" if tell($self->{'fh'}) && $self->{'file'} ne "STDOUT"; > > would help? Why not just print "\n" if tell($self->{'fh'}) > 0; Graham. |
From: Piotr R. <Pio...@ne...> - 2002-01-31 08:39:54
|
> print "\n" if tell($self->{'fh'}) > 0; That works fine. Will you commit this change to CVS? -- Piotr Roszatycki, Netia Telekom S.A. .''`. mailto:Pio...@ne... : :' : mailto:de...@de... `. `' `- |
From: Graham B. <gb...@po...> - 2002-01-31 13:32:35
|
On Thu, Jan 31, 2002 at 09:39:32AM +0100, Piotr Roszatycki wrote: > > print "\n" if tell($self->{'fh'}) > 0; > > That works fine. Will you commit this change to CVS? Actually it will not work :( As for pipes it will always return -1 and so never output the \n I have a different patch that I have commited to CVS. Graham. |