Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package perl-String-Util for openSUSE:Factory checked in at 2023-02-14 16:47:15 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-String-Util (Old) and /work/SRC/openSUSE:Factory/.perl-String-Util.new.27156 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-String-Util" Tue Feb 14 16:47:15 2023 rev:3 rq:1065567 version:1.34 Changes: -------- --- /work/SRC/openSUSE:Factory/perl-String-Util/perl-String-Util.changes 2021-04-12 12:39:33.961522824 +0200 +++ /work/SRC/openSUSE:Factory/.perl-String-Util.new.27156/perl-String-Util.changes 2023-02-14 16:47:55.795330982 +0100 @@ -1,0 +2,6 @@ +Thu Feb 2 03:09:37 UTC 2023 - Tina Müller <timueller+p...@suse.de> + +- updated to 1.34 + see /usr/share/doc/packages/perl-String-Util/Changes + +------------------------------------------------------------------- Old: ---- String-Util-1.32.tar.gz New: ---- String-Util-1.34.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-String-Util.spec ++++++ --- /var/tmp/diff_new_pack.LT1a39/_old 2023-02-14 16:47:56.411334620 +0100 +++ /var/tmp/diff_new_pack.LT1a39/_new 2023-02-14 16:47:56.419334667 +0100 @@ -1,7 +1,7 @@ # # spec file for package perl-String-Util # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2023 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -18,10 +18,10 @@ %define cpan_name String-Util Name: perl-String-Util -Version: 1.32 +Version: 1.34 Release: 0 -Summary: String processing utility functions License: Artistic-1.0 OR GPL-1.0-or-later +Summary: String processing utility functions URL: https://metacpan.org/release/%{cpan_name} Source0: https://cpan.metacpan.org/authors/id/B/BA/BAKERSCOT/%{cpan_name}-%{version}.tar.gz Source1: cpanspec.yml @@ -33,8 +33,8 @@ %{perl_requires} %description -String::Util provides a collection of small, handy functions for processing -strings in various ways. +*String::Util* provides a collection of small, handy functions for +processing strings in various ways. %prep %autosetup -n %{cpan_name}-%{version} ++++++ String-Util-1.32.tar.gz -> String-Util-1.34.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/String-Util-1.32/Build.PL new/String-Util-1.34/Build.PL --- old/String-Util-1.32/Build.PL 2021-03-26 22:06:02.000000000 +0100 +++ new/String-Util-1.34/Build.PL 2023-02-01 17:13:07.000000000 +0100 @@ -2,6 +2,6 @@ use strict; use warnings; -use 5.010; +use v5.14.0; use Module::Build::Tiny 0.034; Build_PL(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/String-Util-1.32/Changes new/String-Util-1.34/Changes --- old/String-Util-1.32/Changes 2021-03-26 22:06:02.000000000 +0100 +++ new/String-Util-1.34/Changes 2023-02-01 17:13:07.000000000 +0100 @@ -1,4 +1,14 @@ -1.32 2021-03-26 14:06:00 PDT +1.34 2023-02-01 08:13:06 PST + +1.34 2023-02-01 + + - Re-release because the required Perl version was wrong + +1.33 2023-01-31 + + - Remove a bunch of old deprecated functions: crunch, cellfill, define, randword, fullchomp, randcrypt, equndef, neundef + + - Update documentation 1.32 2021-03-26 09:27:35 PDT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/String-Util-1.32/LICENSE new/String-Util-1.34/LICENSE --- old/String-Util-1.32/LICENSE 2021-03-26 22:06:02.000000000 +0100 +++ new/String-Util-1.34/LICENSE 2023-02-01 17:13:07.000000000 +0100 @@ -292,21 +292,21 @@ - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through - textual modification. + textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright - Holder. + Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for - the package. + the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the - computing community at large as a market that must bear the fee.) + computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they - received it. + received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you @@ -373,7 +373,7 @@ 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF -MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/String-Util-1.32/MANIFEST new/String-Util-1.34/MANIFEST --- old/String-Util-1.32/MANIFEST 2021-03-26 22:06:02.000000000 +0100 +++ new/String-Util-1.34/MANIFEST 2023-02-01 17:13:07.000000000 +0100 @@ -1,4 +1,4 @@ -# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.015. +# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.030. Build.PL Changes LICENSE diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/String-Util-1.32/META.json new/String-Util-1.34/META.json --- old/String-Util-1.32/META.json 2021-03-26 22:06:02.000000000 +0100 +++ new/String-Util-1.34/META.json 2023-02-01 17:13:07.000000000 +0100 @@ -5,7 +5,7 @@ "Miko O'Sullivan <m...@idocs.com>" ], "dynamic_config" : 0, - "generated_by" : "Dist::Milla version v1.0.20, Dist::Zilla version 6.015, CPAN::Meta::Converter version 2.150010", + "generated_by" : "Dist::Milla version v1.0.21, Dist::Zilla version 6.030, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], @@ -32,13 +32,13 @@ }, "develop" : { "requires" : { - "Dist::Milla" : "v1.0.20", + "Dist::Milla" : "v1.0.21", "Test::Pod" : "1.41" } }, "runtime" : { "requires" : { - "perl" : "5.010" + "perl" : "v5.14.0" } }, "test" : { @@ -59,13 +59,13 @@ "web" : "https://github.com/scottchiefbaker/String-Util" } }, - "version" : "1.32", + "version" : "1.34", "x_contributors" : [ "Dan Book <gri...@gmail.com>", "Scott Baker <scott.ba...@directlink.coop>" ], "x_generated_by_perl" : "v5.26.3", - "x_serialization_backend" : "Cpanel::JSON::XS version 4.25", + "x_serialization_backend" : "Cpanel::JSON::XS version 4.28", "x_spdx_expression" : "Artistic-1.0-Perl OR GPL-1.0-or-later", "x_static_install" : 1 } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/String-Util-1.32/META.yml new/String-Util-1.34/META.yml --- old/String-Util-1.32/META.yml 2021-03-26 22:06:02.000000000 +0100 +++ new/String-Util-1.34/META.yml 2023-02-01 17:13:07.000000000 +0100 @@ -8,7 +8,7 @@ configure_requires: Module::Build::Tiny: '0.034' dynamic_config: 0 -generated_by: 'Dist::Milla version v1.0.20, Dist::Zilla version 6.015, CPAN::Meta::Converter version 2.150010' +generated_by: 'Dist::Milla version v1.0.21, Dist::Zilla version 6.030, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html @@ -23,12 +23,12 @@ - t - xt requires: - perl: '5.010' + perl: v5.14.0 resources: bugtracker: https://github.com/scottchiefbaker/String-Util/issues homepage: https://github.com/scottchiefbaker/String-Util repository: https://github.com/scottchiefbaker/String-Util.git -version: '1.32' +version: '1.34' x_contributors: - 'Dan Book <gri...@gmail.com>' - 'Scott Baker <scott.ba...@directlink.coop>' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/String-Util-1.32/README new/String-Util-1.34/README --- old/String-Util-1.32/README 2021-03-26 22:06:02.000000000 +0100 +++ new/String-Util-1.34/README 2023-02-01 17:13:07.000000000 +0100 @@ -29,9 +29,6 @@ spaces. Also removes all leading and trailing whitespace. Undefined input results in undefined output. - Note: crunch() is an alias to this function. It is considered - deprecated. It may be removed in future versions. - $var = collapse(" Hello world! "); # "Hello world!" hascontent($scalar), nocontent($scalar) @@ -56,7 +53,6 @@ trim($string), ltrim($string), rtrim($string) Returns the string with all leading and trailing whitespace removed. - Trim on undef returns "". $var = trim(" my string "); # "my string" @@ -116,91 +112,13 @@ print repeat('Fred', 3), "\n"; Note that repeat() was created a long time based on a misunderstanding - of how the perl operator 'x' works. The following command using 'x' - would perform exactly the same as the above command. + of how the perl operator 'x' works. The following command using x would + perform exactly the same as the above command. print 'Fred' x 3, "\n"; Use whichever you prefer. - randword($length, %options) - - Returns a random string of characters. String will not contain any - vowels (to avoid distracting dirty words). First argument is the length - of the return string. So this code: - - foreach my $idx (1..3) { - print randword(4), "\n"; - } - - would output something like this: - - kBGV - NCWB - 3tHJ - - If the string 'dictionary' is sent instead of an integer, then a word - is randomly selected from a dictionary file. By default, the dictionary - file is assumed to be at /usr/share/dict/words and the shuf command is - used to pull out a word. The hash %String::Util::PATHS sets the paths - to the dictionary file and the shuf executable. Modify that hash to - change the paths. So this code: - - foreach my $idx (1..3) { - print randword('dictionary'), "\n"; - } - - would output something like this: - - mustache - fronds - browning - - option: alpha - - If the alpha option is true, only alphabetic characters are returned, - no numerals. For example, this code: - - foreach my $idx (1..3) { - print randword(4, alpha=>1), "\n"; - } - - would output something like this: - - qrML - wmWf - QGvF - - option: numerals - - If the numerals option is true, only numerals are returned, no - alphabetic characters. So this code: - - foreach my $idx (1..3) { - print randword(4, numerals=>1), "\n"; - } - - would output something like this: - - 3981 - 4734 - 2657 - - option: strip_vowels - - This option is true by default. If true, vowels are not included in the - returned random string. So this code: - - foreach my $idx (1..3) { - print randword(4, strip_vowels=>1), "\n"; - } - - would output something like this: - - Sk3v - pV5z - XhSX - eqq($scalar1, $scalar2) Returns true if the two given values are equal. Also returns true if @@ -211,9 +129,6 @@ $var = eqq('x', undef); # False $var = eqq(undef, undef); # True - Note: equndef() is an alias to this function. It is considered - deprecated. It may be removed in future versions. - neqq($scalar1, $scalar2) The opposite of neqq, returns true if the two values are *not* the @@ -223,9 +138,6 @@ $var = neqq('x', undef); # True $var = neqq(undef, undef); # False - Note: neundef() is an alias to this function. It is considered - deprecated. It may be removed in future versions. - ords($string) Returns the given string represented as the ascii value of each @@ -328,6 +240,12 @@ $str = file_get_contents("/tmp/file.txt"); # Return a string @lines = file_get_contents("/tmp/file.txt", 1); # Return an array + Note: If you opt to return an array, carriage returns and line feeds + are removed from the end of each line. + + Note: File is read in UTF-8 mode, unless $FGC_MODE is set to an + appropriate encoding. + COPYRIGHT AND LICENSE Copyright (c) 2012-2016 by Miko O'Sullivan. All rights reserved. This diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/String-Util-1.32/cpanfile new/String-Util-1.34/cpanfile --- old/String-Util-1.32/cpanfile 2021-03-26 22:06:02.000000000 +0100 +++ new/String-Util-1.34/cpanfile 2023-02-01 17:13:07.000000000 +0100 @@ -1,2 +1,2 @@ -requires 'perl' => '5.010'; +requires 'perl' => 'v5.14'; test_requires 'Test::More' => '0.88'; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/String-Util-1.32/lib/String/Util.pm new/String-Util-1.34/lib/String/Util.pm --- old/String-Util-1.32/lib/String/Util.pm 2021-03-26 22:06:02.000000000 +0100 +++ new/String-Util-1.34/lib/String/Util.pm 2023-02-01 17:13:07.000000000 +0100 @@ -3,11 +3,11 @@ use strict; use warnings; use Carp; -use 5.014; +use v5.14; # version -our $VERSION = '1.32'; - +our $VERSION = '1.34'; +our $FGC_MODE = 'UTF-8'; #------------------------------------------------------------------------------ # opening POD @@ -15,11 +15,11 @@ =head1 NAME -String::Util -- String processing utility functions +B<String::Util> -- String processing utility functions =head1 DESCRIPTION -String::Util provides a collection of small, handy functions for processing +B<String::Util> provides a collection of small, handy functions for processing strings in various ways. =head1 INSTALLATION @@ -55,21 +55,18 @@ # the following functions accept a value and return a modified version of # that value push @EXPORT_OK, qw[ - collapse crunch htmlesc trim ltrim - rtrim define repeat unquote no_space - nospace fullchomp randcrypt jsquote cellfill - crunchlines file_get_contents + collapse htmlesc trim ltrim + rtrim repeat unquote no_space + nospace jsquote crunchlines + file_get_contents ]; # the following functions return true or false based on their input push @EXPORT_OK, qw[ - hascontent nocontent eqq equndef neqq neundef - startswith endswith contains sanitize + hascontent nocontent eqq neqq + startswith endswith contains sanitize ]; -# the following function returns a random string of some type -push @EXPORT_OK, qw[ randword ]; - # the following function returns the unicode values of a string push @EXPORT_OK, qw[ ords deords ]; @@ -89,9 +86,6 @@ Also removes all leading and trailing whitespace. Undefined input results in undefined output. -B<Note:> C<crunch()> is an alias to this function. It is considered deprecated. -It may be removed in future versions. - $var = collapse(" Hello world! "); # "Hello world!" =cut @@ -108,9 +102,6 @@ return $val; } -sub crunch { - return collapse(@_); -} # # collapse #------------------------------------------------------------------------------ @@ -122,7 +113,7 @@ =head2 hascontent($scalar), nocontent($scalar) -hascontent() returns true if the given argument is defined and contains +C<hascontent()> returns true if the given argument is defined and contains something besides whitespace. An undefined value returns false. An empty string returns false. A value @@ -177,13 +168,12 @@ =head2 trim($string), ltrim($string), rtrim($string) Returns the string with all leading and trailing whitespace removed. -Trim on undef returns "". $var = trim(" my string "); # "my string" -ltrim() trims B<leading> whitespace only. +C<ltrim()> trims B<leading> whitespace only. -rtrim() trims B<trailing> whitespace only. +C<rtrim()> trims B<trailing> whitespace only. =cut @@ -307,28 +297,6 @@ #------------------------------------------------------------------------------ -# cellfill -# - -sub cellfill{ - my ($val) = @_; - - carp("cellfill() is deprecated and will be removed in future versions"); - - if (hascontent($val)) { - $val = htmlesc($val); - } else { - $val = ' '; - } - - return $val; -} -# -# cellfill -#------------------------------------------------------------------------------ - - -#------------------------------------------------------------------------------ # jsquote # @@ -419,30 +387,6 @@ #------------------------------------------------------------------------------ -# define -# - -sub define { - carp("define() is deprecated and may be removed in future version"); - - my ($val) = @_; - - # if overloaded object, get return value and - # concatenate with string (which defines it). - if (ref($val) && overload::Overloaded($val)) { - local $^W = 0; - $val = $val . ''; - } - - defined($val) or $val = ''; - return $val; -} -# -# define -#------------------------------------------------------------------------------ - - -#------------------------------------------------------------------------------ # repeat # @@ -453,8 +397,8 @@ print repeat('Fred', 3), "\n"; -Note that repeat() was created a long time based on a misunderstanding of how -the perl operator 'x' works. The following command using 'x' would perform +Note that C<repeat()> was created a long time based on a misunderstanding of how +the perl operator 'x' works. The following command using C<x> would perform exactly the same as the above command. print 'Fred' x 3, "\n"; @@ -473,195 +417,6 @@ #------------------------------------------------------------------------------ -# randword -# - -=head2 randword($length, %options) - -Returns a random string of characters. String will not contain any vowels (to -avoid distracting dirty words). First argument is the length of the return -string. So this code: - - foreach my $idx (1..3) { - print randword(4), "\n"; - } - -would output something like this: - - kBGV - NCWB - 3tHJ - -If the string 'dictionary' is sent instead of an integer, then a word is -randomly selected from a dictionary file. By default, the dictionary file -is assumed to be at /usr/share/dict/words and the shuf command is used to -pull out a word. The hash %String::Util::PATHS sets the paths to the -dictionary file and the shuf executable. Modify that hash to change the paths. -So this code: - - foreach my $idx (1..3) { - print randword('dictionary'), "\n"; - } - -would output something like this: - - mustache - fronds - browning - -B<option:> alpha - -If the alpha option is true, only alphabetic characters are returned, no -numerals. For example, this code: - - foreach my $idx (1..3) { - print randword(4, alpha=>1), "\n"; - } - -would output something like this: - - qrML - wmWf - QGvF - -B<option:> numerals - -If the numerals option is true, only numerals are returned, no alphabetic -characters. So this code: - - foreach my $idx (1..3) { - print randword(4, numerals=>1), "\n"; - } - -would output something like this: - - 3981 - 4734 - 2657 - -B<option:> strip_vowels - -This option is true by default. If true, vowels are not included in the -returned random string. So this code: - - foreach my $idx (1..3) { - print randword(4, strip_vowels=>1), "\n"; - } - -would output something like this: - - Sk3v - pV5z - XhSX - -=cut - -# path information for WC -our %PATHS = ( - wc => '/usr/bin/wc', - shuf => '/usr/bin/shuf', - words => '/usr/share/dict/words', - head => '/usr/bin/head', - tail => '/usr/bin/tail', -); - -sub randword { - my ($count, %opts) = @_; - my ($rv, $char, @chars, $paths); - $rv = ''; - - # check syntax - defined($count) or croak 'syntax: randword($count)'; - - # dictionary word - if ($count =~ m|^dict|si) { - # loop until acceptable word is found - DICTIONARY: - while (1) { - my ($cmd, $line_count, $line_num, $word); - - # use Encode module - require Encode; - - # get line count - $cmd = qq|$PATHS{'wc'} -l "$PATHS{'words'}"|; - ($line_count) = `$cmd`; - $line_count =~ s|\s.*||s; - - # get random line - $line_num = rand($line_count); - - # untaint line number - unless ($line_num =~ m|^([0-9]+)$|s) { die "invalid line number: $line_num" } - $line_num = $1; - - # get random word - $cmd = qq[$PATHS{'head'} -$line_num "$PATHS{'words'}" | $PATHS{'tail'} -1]; - ($word) = `$cmd`; - $word =~ s|\s.*||si; - $word =~ s|'.*||si; - $word = lc($word); - - # only allow words that are all letters - if ($opts{'letters_only'}) { - unless ($word =~ m|^[a-z]+$|s) - { next DICTIONARY } - } - - # check for max length - if ($opts{'maxlength'}) { - if ( length($word) > $opts{'maxlength'} ) - { next DICTIONARY } - } - - # encode unless specifically opted not to do so - unless ( defined($opts{'encode'}) && (! $opts{'encode'}) ) - { $word = Encode::encode_utf8($word) } - - # return - return $word; - } - } - - # alpha only - if ($opts{'alpha'}) - { @chars = ('a' .. 'z', 'A' .. 'Z') } - - # else alpha and numeral - else - { @chars = ('a' .. 'z', 'A' .. 'Z', '0' .. '9') } - - # defaults - defined($opts{'strip_vowels'}) or $opts{'strip_vowels'} = 1; - - while (length($rv) < $count) { - $char = rand(); - - # numerals only - if ($opts{'numerals'}) { - $char =~ s|^0.||; - $char =~ s|\D||g; - } - - # character random word - else { - $char = int( $char * ($#chars + 1) ); - $char = $chars[$char]; - next if($opts{'strip_vowels'} && $char =~ m/[aeiouy]/i); - } - - $rv .= $char; - } - - return substr($rv, 0, $count); -} -# -# randword -#------------------------------------------------------------------------------ - - - -#------------------------------------------------------------------------------ # eqq # formerly equndef # @@ -669,21 +424,15 @@ =head2 eqq($scalar1, $scalar2) Returns true if the two given values are equal. Also returns true if both -are undef. If only one is undef, or if they are both defined but different, +are C<undef>. If only one is C<undef>, or if they are both defined but different, returns false. Here are some examples and what they return. $var = eqq('x', 'x'); # True $var = eqq('x', undef); # False $var = eqq(undef, undef); # True -B<Note:> equndef() is an alias to this function. It is considered deprecated. -It may be removed in future versions. - =cut -# alias equndef to eqq -sub equndef { return eqq(@_) } - sub eqq { my ($str1, $str2) = @_; @@ -712,22 +461,15 @@ =head2 neqq($scalar1, $scalar2) -The opposite of neqq, returns true if the two values are *not* the same. +The opposite of C<neqq>, returns true if the two values are *not* the same. Here are some examples and what they return. $var = neqq('x', 'x'); # False $var = neqq('x', undef); # True $var = neqq(undef, undef); # False -B<Note:> neundef() is an alias to this function. It is considered deprecated. -It may be removed in future versions. - =cut -sub neundef { - return eqq(@_) ? 0 : 1; -} - sub neqq { return eqq(@_) ? 0 : 1; } @@ -737,41 +479,6 @@ #------------------------------------------------------------------------------ -# fullchomp -# - -sub fullchomp { - carp("fullchomp() is deprecated and may be removed in future versions"); - - my ($line) = @_; - defined($line) and $line =~ s|[\r\n]+$||s; - defined(wantarray) and return $line; - $_[0] = $line; -} -# -# fullchomp -#------------------------------------------------------------------------------ - - -#------------------------------------------------------------------------------ -# randcrypt -# - -sub randcrypt { - carp("randcrypt() is deprecated and may be removed in future versions"); - - my $pw = shift(); - my $ret; - $ret = crypt($pw, randword(2)); - - return $ret; -} -# -# randcrypt -#------------------------------------------------------------------------------ - - -#------------------------------------------------------------------------------ # ords # @@ -864,7 +571,7 @@ =head2 deords($string) -Takes the output from ords() and returns the string that original created that +Takes the output from C<ords()> and returns the string that original created that output. $var = deords('{72}{101}{110}{100}{114}{105}{120}'); # 'Hendrix' @@ -1064,23 +771,37 @@ $str = file_get_contents("/tmp/file.txt"); # Return a string @lines = file_get_contents("/tmp/file.txt", 1); # Return an array +B<Note:> If you opt to return an array, carriage returns and line feeds are +removed from the end of each line. + +B<Note:> File is read in B<UTF-8> mode, unless C<$FGC_MODE> is set to an +appropriate encoding. + =cut sub file_get_contents { my ($file, $ret_array) = @_; open (my $fh, "<", $file) or return undef; - - my $ret; - while (<$fh>) { - $ret .= $_; - } + binmode($fh, ":encoding($FGC_MODE)"); if ($ret_array) { - return split(/\r?\n/,$ret); - } + my @ret; - return $ret; + while (my $line = readline($fh)) { + $line =~ s/[\r\n]*$//; # Remove CR/LF + push(@ret, $line); + } + + return @ret; + } else { + my $ret = ''; + while (my $line = readline($fh)) { + $ret .= $line; + } + + return $ret; + } } # return true diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/String-Util-1.32/t/test.t new/String-Util-1.34/t/test.t --- old/String-Util-1.32/t/test.t 2021-03-26 22:06:02.000000000 +0100 +++ new/String-Util-1.34/t/test.t 2023-02-01 17:13:07.000000000 +0100 @@ -145,20 +145,20 @@ #------------------------------------------------------------------------------ -# eq_undef, neundef +# eqq, neqq # -ok(equndef('a' , 'a') , 'equndef same'); -ok(equndef(undef , undef) , 'equndef undef'); -ok(!equndef('a' , 'b') , 'equndef diff'); -ok(!equndef('a' , undef) , 'equndef a and undef'); +ok(eqq('a' , 'a') , 'eqq same'); +ok(eqq(undef , undef) , 'eqq undef'); +ok(!eqq('a' , 'b') , 'eqq diff'); +ok(!eqq('a' , undef) , 'eqq a and undef'); -ok(!neundef('a' , 'a') , 'nequndef same'); -ok(!neundef(undef , undef) , 'nequndef undef'); -ok(neundef('a' , 'b') , 'nequndef diff'); -ok(neundef('a' , undef) , 'nequndef a and undef'); +ok(!neqq('a' , 'a') , 'neqq same'); +ok(!neqq(undef , undef) , 'neqq undef'); +ok(neqq('a' , 'b') , 'neqq diff'); +ok(neqq('a' , undef) , 'neqq a and undef'); # -# eq_undef, neundef +# eq_undef, neqq #------------------------------------------------------------------------------ @@ -222,14 +222,6 @@ is(sanitize("Hello there!!!", '.') , 'Hello.there' , 'Sanitize with a custom separator'); -#------------------------------------------------------------------------------ -# randword -# Not sure how to test this besides making sure it actually runs. -# - -$val = randword(20); -ok(defined($val) && (length($val) == 20), 'randword'); - # # randword #------------------------------------------------------------------------------