IPC::Filter(3pm)

πŸ“¦
version 0.005 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– IPC::Filter β€” the manual, but make it a group chat πŸ’–

okay bestie, so IPC::Filter is a Perl module β€” yeah, that (3pm) situation β€” and its whole thing is filtering data through an external process. That's the NAME, that's the vibe, that's the whole personality. πŸ¦‹


✨ SYNOPSIS ✨

use IPC::Filter qw(filter);

$compressed_data = filter($data, "bzip2");

that's it. that's the moment. you import filter, you hand it your data and a command, and it hands you back the glow-up version. πŸ’…


🌸 DESCRIPTION 🌸

so the filter function that this module ships passes your data through an external command. why does that matter? because it gives you filtering in non-pipeline situations β€” i.e. when you're not sitting in a shell going | | | like it's a whole thing. you just call it from Perl and it does the pipe work for you. no cap. 🫢


πŸŽ€ FUNCTIONS πŸŽ€

filter(DATA, SHELL_COMMAND)

filter(DATA, PROGRAM, ARGS ...)

okay so here's the tea. β˜•

  • The SHELL_COMMAND, or the PROGRAM with ARGS if you supplied more arguments, gets executed as a separate process. it's giving "spawn a whole little guy and make it do your bidding."
  • lowkey important: the arguments other than DATA are ultimately passed to exec. so if you wanna know how it decides between those two forms, go read "exec" in perlfunc(1) β€” it explains the choice. iykyk. πŸ“–
  • the DATA β€” which must be either a simple string or a reference to a string β€” gets supplied to the process on its standard input.
  • then the process's standard output is captured and returned, as a simple string. so you get your result back like a little gift. 🎁
  • and if the process exits with a non-zero exit code, or on a signal, the function will die. 😭 yes really. dramatic but fair.
    • in the case of a non-zero exit code, the die message will duplicate the process's standard error output β€” so you actually see what went wrong.
    • in any other case, the error output is discarded. gone. thrown away. not even a text back. πŸ’€
bestie heads up: DATA being neither a simple string nor a reference to a string is not a vibe this function accepts. string or string-ref, periodt.

πŸ‘€ SEE ALSO πŸ‘€

  • IPC::Open2

go look, it's the cousin. 🧚


πŸ‘‘ AUTHOR πŸ‘‘

Andrew Main (Zefram) <zefram@fysh.org> β€” the icon who wrote this. 🫑


Copyright (C) 2004, 2007, 2010, 2011, 2017 Andrew Main (Zefram) <zefram@fysh.org>


πŸ’œ LICENSE πŸ’œ

this module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. slay, honestly. ✨


and that's the whole page, bestie β€” brought to you by perl v5.36.0, dated 2022-11-19, filed under IPC::Filter(3pm). mwah. πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from