ckj has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks, two days back when I ran this code it was working fine but today when I am running the same code it's not working.
My yaml file i.e. test.yaml:
rootproperty: blah section: one: two three: four Foo: Bar empty: ~
My perl code:
use YAML::Tiny; # Create a YAML file my $yaml = YAML::Tiny->new; # Open the config $yaml = YAML::Tiny->read( 'D:\Perl\bin\test.yaml' ); # Reading properties my $root = $yaml->[0]->{rootproperty}; my $one = $yaml->[0]->{section}->{one}; my $Foo = $yaml->[0]->{section}->{Foo}; # Changing data $yaml->[0]->{newsection} = { this => 'that' }; # Add a section $yaml->[0]->{section}->{Foo} = 'Not Bar!'; # Change a value delete $yaml->[0]->{section}; # Delete a value # Add an entire document $yaml->[1] = [ 'foo', 'bar', 'baz' ]; # Save the file $yaml->write( 'D:\Perl\bin\file.conf' );
It's completely confusing that how the same code is not working today, every time ti is giving the same error:
Can't call method "write" on unblessed reference at D:\Perl\bin\yaml_t +est.pl line 23.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Stucked in YAML::Tiny
by moritz (Cardinal) on Jul 16, 2012 at 07:06 UTC | |
by ckj (Chaplain) on Jul 16, 2012 at 07:28 UTC | |
by moritz (Cardinal) on Jul 16, 2012 at 08:39 UTC | |
by aitap (Curate) on Jul 16, 2012 at 10:14 UTC | |
|
Re: Stucked in YAML::Tiny
by cavac (Prior) on Jul 16, 2012 at 06:59 UTC | |
|
Re: Stucked in YAML::Tiny
by tobyink (Canon) on Jul 16, 2012 at 10:07 UTC | |
|
Re: Stucked in YAML::Tiny
by Anonymous Monk on Jul 16, 2012 at 13:59 UTC | |
by Corion (Patriarch) on Jul 16, 2012 at 14:09 UTC | |
by Anonymous Monk on Aug 07, 2012 at 02:16 UTC | |
by Anonymous Monk on Aug 19, 2012 at 19:36 UTC |