in reply to Re: YAML::TINY and module install test
in thread YAML::TINY and module install test

Heh yea thanks, some error reporting would be good :) I get this with the error code added...

sg:~/desktop % perl yaml.pl Couldn't read file: errno() : errstr =Stream does not end with newline + character at yaml.pl line 10.
I don't know what this is refering to.. i haven't used the read() function much, but why is it asking for this mysterious new-line?

I'm on an Mac OS X computer btw.

Learning Perl, one %hash at a time....

Replies are listed 'Best First'.
Re^3: YAML::TINY and module install test
by Anonymous Monk on Feb 11, 2009 at 03:35 UTC
    YAML::Tiny seems to think your yaml file isn't properly formatted. Since you're on OS X, and ysh thinks your yaml is fine, its probably a bug in YAML::Tiny (missing binmode). You could probably work around it with
    use open IN => ':bytes'; use YAML::Tiny; ....
    If that fixes it, you should report the bug.

      Hmm didn't make any difference when i just added that. But then going on the thought that its a file encoding issue I switched from SubethaEdit to vim and remade the customers.yml then reran the script and got a new error :)

      Bad or unsupported hash line at /usr/local/lib/perl5/site_perl/5.10.0/YAML/Tiny.pm line 279.

      Learning Perl, one %hash at a time....
        Hmm, I kind of doubt it :) You probably forgot something again. Try this
        #!/usr/bin/perl -- use strict; use warnings; my( $VAR1, $VAR2 ); $VAR1 = { 'email' => 'goose@gmail.com', 'orders' => [ { 'downloads' => '3', 'order' => 'wb090130', 'item' => '0001', 'price' => '3.98' }, { 'downloads' => '5', 'order' => 'wb090131', 'item' => '0003', 'price' => '3.98' } ], 'total' => '7.96' }; $VAR2 = { 'email' => 'cowboy@bebop.com' }; use open qw' IN :bytes OUT :bytes '; use YAML::Tiny qw[ LoadFile DumpFile ]; use Data::Dumper; $Data::Dumper::Indent=1; warn DumpFile('test.yml', $VAR1, $VAR2); print Dumper(LoadFile( 'test.yml' ));
        Then compare both your failing yml files this YAML::Tiny generated test.yml, use od -tacx1 or hexdump.