Skip to content

Commit

Permalink
using 'use' instead of 'require'
Browse files Browse the repository at this point in the history
  • Loading branch information
z448 committed Jan 22, 2024
1 parent 368cedf commit aec961b
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 46 deletions.
7 changes: 4 additions & 3 deletions lib/App/trrr.pm
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ sub get_content {
close $ph;
} else {
eval {
require HTTP::Tiny;
HTTP::Tiny->import();
1;
#require HTTP::Tiny;
#HTTP::Tiny->import();
#1;
use HTTP::Tiny;
};
my $response = '';
if($cacert){
Expand Down
78 changes: 38 additions & 40 deletions lib/App/trrr/HotKey.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,43 @@

@ISA = qw(Exporter);
@EXPORT = qw(cbreak cooked readkey);
use strict;

my $load = eval {
require POSIX;
POSIX->import(':termios_h');
1;
};
unless($load){ return 1 } else {
no strict;
my ($term, $oterm, $echo, $noecho, $fd_stdin);

$fd_stdin = fileno(STDIN);
$term = POSIX::Termios->new();
$term->getattr($fd_stdin);
$oterm = $term->getlflag();

$echo = ECHO | ECHOK | ICANON;
$noecho = $oterm & ~$echo;

sub cbreak {
$term->setlflag($noecho);
$term->setcc(VTIME, 1);
$term->setattr($fd_stdin, TCSANOW);
}

sub cooked {
$term->setlflag($oterm);
$term->setcc(VTIME, 0);
$term->setattr($fd_stdin, TCSANOW);
}

sub readkey {
my $key = '';
cbreak();
sysread(STDIN, $key, 1);
cooked();
return $key;
}

END { cooked() }
use POSIX qw< :termios_h >;

no strict;



my ($term, $oterm, $echo, $noecho, $fd_stdin);

$fd_stdin = fileno(STDIN);
$term = POSIX::Termios->new();
$term->getattr($fd_stdin);
$oterm = $term->getlflag();

$echo = ECHO | ECHOK | ICANON;
$noecho = $oterm & ~$echo;

sub cbreak {
$term->setlflag($noecho);
$term->setcc(VTIME, 1);
$term->setattr($fd_stdin, TCSANOW);
}

sub cooked {
$term->setlflag($oterm);
$term->setcc(VTIME, 0);
$term->setattr($fd_stdin, TCSANOW);
}

sub readkey {
my $key = '';
cbreak();
sysread(STDIN, $key, 1);
cooked();
return $key;
}

END { cooked() }


1;
7 changes: 4 additions & 3 deletions trrr
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,9 @@ sub wait_key {
# print colored(['white on_grey3'],'P') . colored(['grey5 on_white'],'RESS') . colored(['white on_grey3'],'K') . colored(['grey5 on_white'],'EY') . "\n";
print ' ' . colored(['grey5 on_white'],'P') . colored(['white on_grey3'],'RESS') . colored(['grey5 on_white'],'K') . colored(['white on_grey3'],'EY') . "\n";

require App::trrr::HotKey;
App::trrr::HotKey->import( 'readkey' ) ;
#require App::trrr::HotKey;
#App::trrr::HotKey->import( 'readkey' ) ;
use App::trrr::HotKey qw< readkey >;
$opt->{key} = uc readkey();
get_torrent($result);
}
Expand Down Expand Up @@ -252,7 +253,7 @@ App::trrr - search torrents
=head1 VERSION
This document describes trrr version 0.21
This document describes trrr version 0.23
=head1 DESCRIPTION
Expand Down

0 comments on commit aec961b

Please sign in to comment.