Test2:...Stream(3pm)

πŸ’– NAME πŸ’–

okay bestie, gather round β€” this is Test2::Harness::Util::File::Stream, and it lives in the User Contributed Perl Documentation corner of the world (the manual page goes by Test2:...Stream(3pm), cute right?). It's a little utility class for messing with a file that's acting as an output stream. πŸ¦‹


🌸 DESCRIPTION 🌸

So here's the vibe: this is a subclass of Test2::Harness::File, and what it does is stream the contents of a file β€” and yes, even if that file is still being written to. No waiting for the writer to finish, no drama. It's giving "I read while you write" main character energy. ✨


✨ SYNOPSIS ✨

use Test2::Harness::Util::File::Stream;

my $stream = Test2::Harness::Util::File::Stream->new(name => 'path/to/file');

# Read some lines
my @lines = $stream->poll;

...

# Read more lines, if any.
push @lines => $stream->poll;

periodt. that's the whole flow, bestie. πŸ’…


πŸŽ€ ATTRIBUTES πŸŽ€

πŸ’‘ psst β€” hit up Test2::Harness::File for the additional attributes, this is just the extra sauce.

these can be passed in as construction arguments if you feel like it, no pressure:

  • $bool = $stream->use_write_lock
  • $stream->use_write_lock($bool) β€” locks the file for every write() operation. lock it up, bestie πŸ”’
  • $bool = $stream->tail β€” starts near the end of the file and only polls for updates that get appended to it. chronic late-arriver behavior, honestly iconic 🫢

πŸ’… METHODS πŸ’…

🧚 again β€” Test2::Harness::File has even more methods, go look.
  • @lines = $stream->read() β€” reads all the lines from the beginning. and every single time you call it, it returns ALL lines. every time. all of them. no cap 😭
  • @lines = $stream->poll()
  • @lines = $stream->poll(max => $int) β€” polls for lines! this one is an iterator, so it should not hand you the same line more than once. call it multiple times and you'll get any extra lines that showed up since your last poll. it's giving "keep checking the group chat" energy πŸ“±
  • $stream->write(@content) β€” appends @content to the file. slay.

πŸ”₯ SOURCE πŸ”₯

the source code repository for Test2-Harness can be found at:

http://github.com/Test-More/Test2-Harness/

πŸ‘‘ MAINTAINERS πŸ‘‘

  • Chad Granum <exodist@cpan.org>

🌈 AUTHORS 🌈

  • Chad Granum <exodist@cpan.org>

Copyright 2020 Chad Granum <exodist7@gmail.com>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See:

http://dev.perl.org/licenses/

and that's the whole page, bestie!! πŸŽ€βœ¨ this was perl v5.40.1, dated 2026-05-10, and the manual page answers to Test2:...Stream(3pm). go stream something. love u, bye πŸ’–πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from