#!perl -w
use strict;
use WWW::Mechanize::Firefox;
use Getopt::Long;
use Pod::Usage;
use Cwd qw(getcwd);
GetOptions(
'mozrepl|m:s' => \my $mozrepl,
'tab:s' => \my $tab,
'current|c' => \my $use_current_tab,
'close|q' => \my $close,
'title|t:s' => \my $title,
'type:s' => \my $encode_type,
#'focus|f' => \my $focus,
) or pod2usage();
$tab = $use_current_tab ? 'current'
: $tab ? qr/$tab/
: undef
;
$title ||= getcwd;
my $mech = WWW::Mechanize::Firefox->new(
tab => $tab,
repl => $mozrepl,
create => 1,
autoclose => $close,
);
local $/;
binmode STDIN;
my $html = <>;
# Find out whether we have HTML:
if (! $encode_type) {
if ($html =~ /^\s* '<',
'>' => '>',
'&' => '&',
);
$html =~ s/([<>&])/$map{$1} || $1/ge;
$html =~ s/\r?\n/
/g;
$html = "
$html"; }; $mech->update_html($html); =head1 NAME bcat.pl - cat HTML to browser =head1 SYNOPSIS bcat.pl