perl next, last, regular expression 實用場景

profesor發表於2024-03-05

#!/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中執行

相關文章