Simple example of using data from a YAML configuration file in a Perl script

后端 未结 3 939
甜味超标
甜味超标 2021-02-06 00:46

I need to create a YAML file to store some configuration data for a Perl script. This seems like it should be really easy but I haven\'t been able to work it out, I think if I h

3条回答
  •  不思量自难忘°
    2021-02-06 01:47

    Try this:

    #!/usr/bin/perl
    
    use strict;
    use warnings;
    use 5.010;
    
    use YAML qw(LoadFile);
    
    my $settings = LoadFile('test.yaml');
    say "The image width is ", $settings->{image_width};
    

    – Michael

提交回复
热议问题