From 3b22fa8dd66c32c03b1faade433bebf5d1886bf7 Mon Sep 17 00:00:00 2001 From: Ethan Kletschke Date: Wed, 28 Oct 2026 05:28:06 +0200 Subject: [PATCH 01/15] docs: Update `last-updated` --- meta/project.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta/project.yaml b/meta/project.yaml index 6ed64de..7ba6233 100644 --- a/meta/project.yaml +++ b/meta/project.yaml @@ -1,7 +1,7 @@ project-meta: project-name: PerlUtils date-started: 2026-10-20 - last-updated: 2026-10-25 + last-updated: 2026-10-28 languages: - Perl status: Experimental From 1efc6c0e7586f0c4400458d7fe7ddb73f5e58d2e Mon Sep 17 00:00:00 2001 From: Ethan Kletschke Date: Wed, 28 Oct 2026 05:30:47 +0200 Subject: [PATCH 02/15] wip: Add `TextFileHandling` module --- src/lib/Utils/TextFiles/TextFileHandling.pm | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/lib/Utils/TextFiles/TextFileHandling.pm diff --git a/src/lib/Utils/TextFiles/TextFileHandling.pm b/src/lib/Utils/TextFiles/TextFileHandling.pm new file mode 100644 index 0000000..10f37ff --- /dev/null +++ b/src/lib/Utils/TextFiles/TextFileHandling.pm @@ -0,0 +1,13 @@ +package Utils::TextFiles::TextFileHandling; + +use strict; +use warnings; +use Exporter 'import'; + +1; + +__END__ + +=pod + +=cut From 84cd404b171600f48f70651572f032cdd497df13 Mon Sep 17 00:00:00 2001 From: Ethan Kletschke Date: Wed, 28 Oct 2026 07:18:27 +0200 Subject: [PATCH 03/15] ci: Change workflow run conditions for PRs --- .github/workflows/RunModuleTests.yml | 3 +++ .github/workflows/ValidatePod.yml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/RunModuleTests.yml b/.github/workflows/RunModuleTests.yml index 5d05185..fa2c47d 100644 --- a/.github/workflows/RunModuleTests.yml +++ b/.github/workflows/RunModuleTests.yml @@ -6,6 +6,9 @@ on: - main pull_request: types: + - opened + - reopened + - synchronize - ready_for_review branches: - main diff --git a/.github/workflows/ValidatePod.yml b/.github/workflows/ValidatePod.yml index 8b31ba5..1e7c7ed 100644 --- a/.github/workflows/ValidatePod.yml +++ b/.github/workflows/ValidatePod.yml @@ -6,6 +6,9 @@ on: - main pull_request: types: + - opened + - reopened + - synchronize - ready_for_review branches: - main From 58293d6e4cafa22633b3c442f844e2112c47533c Mon Sep 17 00:00:00 2001 From: Ethan Kletschke Date: Wed, 28 Oct 2026 07:33:44 +0200 Subject: [PATCH 04/15] chore: Rename `TextFileHandling` to `Simple` --- src/lib/Utils/TextFiles/{TextFileHandling.pm => Simple.pm} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/lib/Utils/TextFiles/{TextFileHandling.pm => Simple.pm} (63%) diff --git a/src/lib/Utils/TextFiles/TextFileHandling.pm b/src/lib/Utils/TextFiles/Simple.pm similarity index 63% rename from src/lib/Utils/TextFiles/TextFileHandling.pm rename to src/lib/Utils/TextFiles/Simple.pm index 10f37ff..b00114c 100644 --- a/src/lib/Utils/TextFiles/TextFileHandling.pm +++ b/src/lib/Utils/TextFiles/Simple.pm @@ -1,4 +1,4 @@ -package Utils::TextFiles::TextFileHandling; +package Utils::TextFiles::Simple; use strict; use warnings; From 8dcf1032057bf287bdb395e2e0e35b69886f1ade Mon Sep 17 00:00:00 2001 From: Ethan Kletschke Date: Wed, 28 Oct 2026 07:41:23 +0200 Subject: [PATCH 05/15] feat: Add `can_open` and `cant_open` subroutines --- src/lib/Utils/TextFiles/Simple.pm | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/lib/Utils/TextFiles/Simple.pm b/src/lib/Utils/TextFiles/Simple.pm index b00114c..1cafd55 100644 --- a/src/lib/Utils/TextFiles/Simple.pm +++ b/src/lib/Utils/TextFiles/Simple.pm @@ -4,10 +4,37 @@ use strict; use warnings; use Exporter 'import'; +our @EXPORT_OK = qw( + can_open + cant_open +); + +sub can_open { + my ($filename) = @_; + + open my $fh, '<', $filename or return 0; + close $fh or die "Can't close $filename: $!"; + + return 1; +} + +sub cant_open { + my ($filename) = @_; + + open my $fh, '<', $filename or return 1; + close $fh or die "Can't close $filename: $!"; + + return 0; +} + 1; __END__ =pod +=head1 NAME + +C - Simple utilities for handling text files. + =cut From 5f8f057d85712b6b130a985f02685dc06f42e3c4 Mon Sep 17 00:00:00 2001 From: Ethan Kletschke Date: Wed, 28 Oct 2026 17:33:34 +0200 Subject: [PATCH 06/15] fix: Change confusing error message --- src/lib/Utils/TextFiles/LogFileParsing.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/Utils/TextFiles/LogFileParsing.pm b/src/lib/Utils/TextFiles/LogFileParsing.pm index f3742f4..53fa8b8 100644 --- a/src/lib/Utils/TextFiles/LogFileParsing.pm +++ b/src/lib/Utils/TextFiles/LogFileParsing.pm @@ -17,7 +17,7 @@ sub count_logs_by_type { # If the filename is not provided as an argument unless (defined($log_type) && defined($filename)) { # Abort the app (Temporary Code) - die "File name not provided"; + die "Missing Parameter(s)"; } # Open the specified log file for reading ('<') From 68f00d26c48e2424b14196a8b77674a37bdf4f69 Mon Sep 17 00:00:00 2001 From: Ethan Kletschke Date: Thu, 29 Oct 2026 08:51:05 +0200 Subject: [PATCH 07/15] docs: Update `last-updated` --- meta/project.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta/project.yaml b/meta/project.yaml index 7ba6233..4fabbc0 100644 --- a/meta/project.yaml +++ b/meta/project.yaml @@ -1,7 +1,7 @@ project-meta: project-name: PerlUtils date-started: 2026-10-20 - last-updated: 2026-10-28 + last-updated: 2026-10-29 languages: - Perl status: Experimental From 9b9baa40bdd6430a244cc39f909fb4c0c8d41532 Mon Sep 17 00:00:00 2001 From: Ethan Kletschke Date: Thu, 29 Oct 2026 17:17:38 +0200 Subject: [PATCH 08/15] docs: Update Feature Backlog --- meta/BACKLOG.md | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/meta/BACKLOG.md b/meta/BACKLOG.md index 34dc894..7f94574 100644 --- a/meta/BACKLOG.md +++ b/meta/BACKLOG.md @@ -3,11 +3,8 @@ - [ ] `TextFiles` Module - [ ] Log Parsing - [x] Log type counter - - [ ] Log type filter (works like UNIX `grep` but more features(?)) + - [x] Log type filter (works like UNIX `grep` but more features(?)) - [ ] CSV parsing - - [ ] - [ ] General File Handling - - [ ] `can_open()` subroutine - - [ ] `cant_open()` subroutine - - [ ] `file_exists()` subroutine - - [ ] `file_not_exists()` subroutine + - [x] `can_open()` subroutine + - [x] `cant_open()` subroutine From bdb3cf867ac10814f9b21afed282c7ab14c64e11 Mon Sep 17 00:00:00 2001 From: Ethan Kletschke Date: Thu, 29 Oct 2026 17:39:33 +0200 Subject: [PATCH 09/15] wip(docs): Start POD for `TextFiles::Simple` --- src/lib/Utils/TextFiles/Simple.pm | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/lib/Utils/TextFiles/Simple.pm b/src/lib/Utils/TextFiles/Simple.pm index 1cafd55..a8ab8a6 100644 --- a/src/lib/Utils/TextFiles/Simple.pm +++ b/src/lib/Utils/TextFiles/Simple.pm @@ -37,4 +37,21 @@ __END__ C - Simple utilities for handling text files. +=head1 SYNPOSIS + + use Utils::TextFiles::Simple qw(can_open); + + unless (can_open("dev.log")) { + die "Can't open dev.log: $!"; + } + +=head1 DESCRIPTION + +The C module provides utilities for +simple file handling, such as testing if a file can be opened successfully or +testing if it's writable, readable, or a directory. + +=for comment +FINISH DOCS LATER + =cut From f6c76b0db11e024912421dd193b687c5c239628a Mon Sep 17 00:00:00 2001 From: Ethan Kletschke Date: Thu, 29 Oct 2026 17:45:30 +0200 Subject: [PATCH 10/15] docs: Tweak wording in `TextFiles::Simple` POD I realised that file tests can be done with one line, i.e., -r means the file is readable --- src/lib/Utils/TextFiles/Simple.pm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lib/Utils/TextFiles/Simple.pm b/src/lib/Utils/TextFiles/Simple.pm index a8ab8a6..f4a23c4 100644 --- a/src/lib/Utils/TextFiles/Simple.pm +++ b/src/lib/Utils/TextFiles/Simple.pm @@ -48,8 +48,7 @@ C - Simple utilities for handling text files. =head1 DESCRIPTION The C module provides utilities for -simple file handling, such as testing if a file can be opened successfully or -testing if it's writable, readable, or a directory. +simple file handling, such as testing if a file can be opened successfully. =for comment FINISH DOCS LATER From 2b88af0815db53b608b79f288c58665286d79487 Mon Sep 17 00:00:00 2001 From: Ethan Kletschke Date: Thu, 29 Oct 2026 17:46:10 +0200 Subject: [PATCH 11/15] feat: Return boolean values on file open and close failure in `TextFiles::Simple` --- src/lib/Utils/TextFiles/Simple.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/Utils/TextFiles/Simple.pm b/src/lib/Utils/TextFiles/Simple.pm index f4a23c4..3176693 100644 --- a/src/lib/Utils/TextFiles/Simple.pm +++ b/src/lib/Utils/TextFiles/Simple.pm @@ -13,7 +13,7 @@ sub can_open { my ($filename) = @_; open my $fh, '<', $filename or return 0; - close $fh or die "Can't close $filename: $!"; + close $fh or return 0; return 1; } @@ -22,7 +22,7 @@ sub cant_open { my ($filename) = @_; open my $fh, '<', $filename or return 1; - close $fh or die "Can't close $filename: $!"; + close $fh or return 1; return 0; } From 4e98fc413b6977b410f069da9be6374a68f01764 Mon Sep 17 00:00:00 2001 From: Ethan Kletschke Date: Fri, 30 Oct 2026 11:21:33 +0200 Subject: [PATCH 12/15] tests: Write unit tests for `TextFiles::Simple` --- meta/project.yaml | 2 +- src/t/TextFiles.t | 56 +++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 53 insertions(+), 5 deletions(-) diff --git a/meta/project.yaml b/meta/project.yaml index 4fabbc0..f1001d2 100644 --- a/meta/project.yaml +++ b/meta/project.yaml @@ -1,7 +1,7 @@ project-meta: project-name: PerlUtils date-started: 2026-10-20 - last-updated: 2026-10-29 + last-updated: 2026-10-30 languages: - Perl status: Experimental diff --git a/src/t/TextFiles.t b/src/t/TextFiles.t index a310d99..25b4135 100644 --- a/src/t/TextFiles.t +++ b/src/t/TextFiles.t @@ -5,6 +5,11 @@ use strict; use warnings; use Test::More; +use Utils::TextFiles::Simple qw( + can_open + cant_open +); + use Utils::TextFiles::LineCounter qw( linecount non_empty_linecount @@ -15,10 +20,53 @@ use Utils::TextFiles::LogFileParsing qw( filter_logs ); +subtest "Simple" => sub { + subtest "can_open()" => sub { + open my $fh, '>', "Test.tmp" + or die "Could not create Test.tmp: $!"; + print $fh "I can be opened!\n"; + close $fh; + + is( + can_open("Test.tmp"), + 1, + "File can be opened and sub returns 0" + ); + + isnt( + can_open("Doesnt-Exist.tmp"), + 1, + "Non-existent file returns 0" + ); + + unlink "Test.tmp"; + }; + + subtest "cant_open()" => sub { + open my $fh, '>', "Exists.tmp" + or die "Could not open Exists.tmp: $!"; + close $fh; + + is( + cant_open("Exists.tmp"), + 0, + "File does open, and sub returns 0" + ); + + is( + cant_open("Non-Existent-File.tmp"), + 1, + "File cannot open, and sub returns 1" + ); + + unlink "Exists.tmp"; + }; +}; + subtest "LineCounter" => sub { subtest "linecount()" => sub { # Write a test file to test the function results against - open my $fh, ">", "LineCounter.tmp" or die "Could not create LineCounter.tmp: $!\n"; + open my $fh, ">", "LineCounter.tmp" or die "Could not create LineCounter.tmp: $!"; print $fh <<~EOF line 1 line 2 @@ -29,7 +77,7 @@ subtest "LineCounter" => sub { close $fh; # Write an empty test file - open $fh, '>', "empty.txt" or die "Could not create empty.txt: $!\n"; + open $fh, '>', "empty.txt" or die "Could not create empty.txt: $!"; close $fh; # Test that the linecount subroutine correctly returns a count of 4 @@ -63,7 +111,7 @@ subtest "LineCounter" => sub { subtest "non_empty_linecount()" => sub { # Write a test file to test the function results against - open my $fh, ">", "LineCounter.tmp" or die "Could not create LineCounter.tmp: $!\n"; + open my $fh, ">", "LineCounter.tmp" or die "Could not create LineCounter.tmp: $!"; print $fh <<~EOF line 1 line 2 @@ -90,7 +138,7 @@ subtest "LineCounter" => sub { "Doesn't count empty lines" ); - # Delete the testing file + # Delete the testing files unlink "LineCounter.tmp"; unlink "empty.txt"; }; From 4d4f304b96c8d883595c20008b3f4f08d0e7d3d2 Mon Sep 17 00:00:00 2001 From: Ethan Kletschke Date: Sat, 31 Oct 2026 08:13:51 +0200 Subject: [PATCH 13/15] docs: Update README and `last-updated` --- README.md | 2 +- meta/project.yaml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bd5c019..476073e 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Utility modules written in Perl, for Perl. - Author: Ethan Kletschke -- Version: `0.0.1` +- Version: `0.0.5` - Developed on: Ubuntu (WSL) - License: MIT - Project metadata file: [`project.yaml`](./meta/project.yaml) diff --git a/meta/project.yaml b/meta/project.yaml index f1001d2..bfcf027 100644 --- a/meta/project.yaml +++ b/meta/project.yaml @@ -1,12 +1,12 @@ project-meta: project-name: PerlUtils date-started: 2026-10-20 - last-updated: 2026-10-30 + last-updated: 2026-10-31 languages: - Perl status: Experimental license: MIT - version: 0.0.1 + version: 0.0.5 build: dev-environments: From 1b816ab2700f4485f78dd3fe72f9162aa281b418 Mon Sep 17 00:00:00 2001 From: Ethan Kletschke Date: Sat, 31 Oct 2026 18:16:16 +0200 Subject: [PATCH 14/15] docs(src): Finish POD for `TextFiles::Simple` --- src/lib/Utils/TextFiles/Simple.pm | 40 +++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/src/lib/Utils/TextFiles/Simple.pm b/src/lib/Utils/TextFiles/Simple.pm index 3176693..0df57a9 100644 --- a/src/lib/Utils/TextFiles/Simple.pm +++ b/src/lib/Utils/TextFiles/Simple.pm @@ -50,7 +50,43 @@ C - Simple utilities for handling text files. The C module provides utilities for simple file handling, such as testing if a file can be opened successfully. -=for comment -FINISH DOCS LATER +=head1 METHODS + +=head2 can_open + +Tests if a file can be opened successfully. + +=head3 PARAMETERS + +=over 4 + +=item C<$filename> + +The name of the file to try open. + +=back + +=head3 RETURN VALUE + +Returns C<1> if it can, or C<0> if it cannot be opened successfully. + +=head2 cant_open + +Tests if a file B be opened successfully. + +=head3 PARAMETERS + +=over 4 + +=item C<$filename> + +The name of the file to try open. + +=back + +=head3 RETURN VALUE + +Returns C<1> if it cannot be opened successfully, or +C<0> if it can open successfully. =cut From 44ddea04d51c72068eab1b52c25189714f7ee1fe Mon Sep 17 00:00:00 2001 From: Ethan Kletschke Date: Sat, 31 Oct 2026 18:16:57 +0200 Subject: [PATCH 15/15] docs: Add comments to `TextFiles.t` --- src/t/TextFiles.t | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/t/TextFiles.t b/src/t/TextFiles.t index 25b4135..b09f5c4 100644 --- a/src/t/TextFiles.t +++ b/src/t/TextFiles.t @@ -4,22 +4,20 @@ use lib 'lib'; use strict; use warnings; use Test::More; - use Utils::TextFiles::Simple qw( can_open cant_open ); - use Utils::TextFiles::LineCounter qw( linecount non_empty_linecount ); - use Utils::TextFiles::LogFileParsing qw( count_logs_by_type filter_logs ); +# Tests for Simple.pm subtest "Simple" => sub { subtest "can_open()" => sub { open my $fh, '>', "Test.tmp" @@ -63,6 +61,7 @@ subtest "Simple" => sub { }; }; +# Tests for LineCounter.pm subtest "LineCounter" => sub { subtest "linecount()" => sub { # Write a test file to test the function results against @@ -144,6 +143,7 @@ subtest "LineCounter" => sub { }; }; +# Tests for LogFileParsing.pm subtest "LogFileParsing" => sub { subtest "count_logs_by_type()" => sub { # Write a test file to test the function results against @@ -213,4 +213,5 @@ subtest "LogFileParsing" => sub { }; }; -done_testing(); +# Check that the number of executed tests is correct +done_testing(3);