perl next, last, regular expression 实用场景

 

#!/usr/local/bin/perl -w
use strict;
use v5.10;
my $torrent = shift; foreach ( `btcheck -li 2>/dev/null $torrent` ) { /Torrent Hash : ([a-f0-9]{40})$/i; next unless $1; chomp $1; say "magnet:?xt=urn:btih:$1"; last; }

 

btcheck -li 2>/dev/null $torrent

无法在tcsh中运行,因为redirection 2>/dev/null在tcsh中不支持。只能在bash中运行

 

posted @ 2024-03-05 23:55  profesor  阅读(2)  评论(0编辑  收藏  举报