Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am able to fetch yaml file contents but not getting how to make changes in any of the attribute and then save it back. Actually writing the changes in the .yaml file is becoming a pain. Can you help in this?
  • Comment on How to make changes in yaml file thorugh perl

Replies are listed 'Best First'.
Re: How to make changes in yaml file thorugh perl
by daxim (Curate) on Jul 13, 2012 at 12:28 UTC
    Sounds like you are manipulating the file contents instead of using the official API.
    use YAML qw(LoadFile DumpFile); my $ref = LoadFile 'name'; $ref->{modify} = 'something'; DumpFile 'name', $ref;
Re: How to make changes in yaml file thorugh perl
by CountZero (Bishop) on Jul 13, 2012 at 12:26 UTC
    What's wrong with the DumpFile(filepath, list) function of YAML. Does it give you any errors?

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

    My blog: Imperial Deltronics
Re: How to make changes in yaml file thorugh perl
by locked_user sundialsvc4 (Abbot) on Jul 13, 2012 at 16:23 UTC

    Given that a well-defined and well-tested API exists that is known to work both ways ... do not use anything else.