# File: FuncSed.pm # # Purpose: Registers the sed Function # SPDX-FileCopyrightText: 2021 Pragmatic Software # SPDX-License-Identifier: MIT package Plugins::FuncSed; use parent 'Plugins::Plugin'; use PBot::Imports; sub initialize { my ($self, %conf) = @_; $self->{pbot}->{functions}->register( 'sed', { desc => 'a sed-like stream editor', usage => 'sed s///[Pig]; P preserve case; i ignore case; g replace all', subref => sub { $self->func_sed(@_) } } ); } sub unload { my $self = shift; $self->{pbot}->{functions}->unregister('sed'); } # near-verbatim insertion of krok's `sed` factoid no warnings; sub func_sed { my $self = shift; my $text = "@_"; if ($text =~ /^s(.)(.*?)(?