| 1 | #!/usr/bin/perl |
| 2 | |
| 3 | # See: https://rt.cpan.org/Ticket/Display.html?id=105255 |
| 4 | # RT #105255 |
| 5 | |
| 6 | use strict; |
| 7 | use warnings; |
| 8 | |
| 9 | use Test::More tests => 1; |
| 10 | |
| 11 | use Config::IniFiles; |
| 12 | |
| 13 | # Test of handle_trailing_comment enabled |
| 14 | { |
| 15 | my $ini_contents = <<'EOF'; |
| 16 | [MySect] |
| 17 | key=val ; a comment ; further comment |
| 18 | |
| 19 | EOF |
| 20 | |
| 21 | my $cfg = Config::IniFiles->new( |
| 22 | -file => \$ini_contents, |
| 23 | -handle_trailing_comment => 1, |
| 24 | ); |
| 25 | |
| 26 | # TEST |
| 27 | is( scalar( $cfg->val( "MySect", "key" ) ), |
| 28 | "val", "Value with a double trailing comment." ); |
| 29 | } |
| 30 | |
| 31 | __END__ |
| 32 | |
| 33 | =head1 COPYRIGHT & LICENSE |
| 34 | |
| 35 | Copyright 2015 by Shlomi Fish |
| 36 | |
| 37 | This program is distributed under the MIT (X11) License: |
| 38 | L<http://www.opensource.org/licenses/mit-license.php> |
| 39 | |
| 40 | Permission is hereby granted, free of charge, to any person |
| 41 | obtaining a copy of this software and associated documentation |
| 42 | files (the "Software"), to deal in the Software without |
| 43 | restriction, including without limitation the rights to use, |
| 44 | copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 45 | copies of the Software, and to permit persons to whom the |
| 46 | Software is furnished to do so, subject to the following |
| 47 | conditions: |
| 48 | |
| 49 | The above copyright notice and this permission notice shall be |
| 50 | included in all copies or substantial portions of the Software. |
| 51 | |
| 52 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 53 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
| 54 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 55 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
| 56 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
| 57 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 58 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 59 | OTHER DEALINGS IN THE SOFTWARE. |
| 60 | |
| 61 | =cut |