⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mutate.pl

📁 rsync的核心代码库。主要作用是比较二进制文件
💻 PL
字号:
#! /usr/bin/perl -w# librsync -- the library for network deltas# $Id: mutate.pl,v 1.1 2002/01/25 21:08:25 bje Exp $## Copyright (C) 1999, 2000 by Martin Pool <mbp@samba.org># Copyright (C) 1999 by Andrew Tridgell <tridge@samba.org>## This program is free software; you can redistribute it and/or# modify it under the terms of the GNU Lesser General Public License# as published by the Free Software Foundation; either version 2.1 of# the License, or (at your option) any later version.## This program is distributed in the hope that it will be useful, but# WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU# Lesser General Public License for more details.## You should have received a copy of the GNU Lesser General Public# License along with this program; if not, write to the Free Software# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.# mutate: makes a random smalll change to an input file and writes it# to stdout.use strict;if ($#ARGV != 1) {  print STDERR "usage: mutate.pl SEED MUTATIONS <BASIS\n";  exit 1;}srand shift @ARGV;my $n_muts = 1 + int rand shift @ARGV;undef $/;                       # slurp whole filemy $corpus = <STDIN>;printf STDERR "%d mutations\n", $n_muts;while ($n_muts-- > 0) {  my $in_len = length($corpus);  my $from_off = int rand $in_len;  my $from_len = int(rand(1.0) * rand($in_len));  my $to_off = int rand $in_len;  my $to_len = int(rand(1.0) * rand($in_len));  my $op = rand 3;  if ($op < 1.0) {    printf STDERR "copy and overwrite";    substr($corpus, $to_off, $to_len) = substr($corpus, $from_off, $from_len);  } elsif ($op < 2.0) {    print STDERR "copy and insert";    substr($corpus, $to_off, 0) = substr($corpus, $from_off, $from_len);  } else {    print STDERR "delete";    substr($corpus, $to_off, $to_len) = '';  }  printf STDERR " (%d, %d) -> (%d, %d)\n", $from_off, $from_len, $to_off, $to_len;}print $corpus;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -