##############################################################################\r\n# This system is a restricted access system. #\r\n# If collected security information reveals possible criminal activity that #\r\n# exceeds privileges, evidence of such activity may be provided to the rele- #\r\n# vantauthorities for further action. By continuing past this point, you #\r\n# expressly consent to this security monitoring. #\r\n##############################################################################\r\n\r\nhostname: ~#
####
use strict;
use Expect;
my $re1 = '(([#%:>~\$\] ])(?!\2)){3,4}|([\w\-\.]*)\$ *$|(\w[@\/]\w|sftp).*?[#%>~\$\]]|^[#%\$>\:]~] *$';
my $test;
open($test,"<","chain.txt");
my $exp = Expect->exp_init($test);
$exp->expect(1,
[ $re1 => sub {
my $exp = shift;
print "Match before : ",$exp->before(),"\n";
print "Match : ",$exp->match(),"\n";
print "Match after : ",$exp->after(),"\n";
}]
);
close $test;
##
##
hans@hans-desktop ~ perl -v
This is perl 5, version 30, subversion 0 (v5.30.0) built for x86_64-linux-gnu-thread-multi
hans@hans-desktop ~ perl -MExpect -e 'print $Expect::VERSION ."\n";'
1.21
perl test.pl
Match before : ##############################################################################\r\n# This system is a restricted access system. #\r\n# If collected security information reveals possible criminal activity that #\r\n# exceeds privileges, evidence of such activity may be provided to the rele- #\r\n# vantauthorities for further action. By continuing past this point, you #\r\n# expressly consent to this security monitoring. #\r\n##############################################################################\r\n\r\nhostname
Match : : ~#
Match after :
##
##
[hans@fedora ~]$ perl -v
This is perl 5, version 34, subversion 0 (v5.34.0) built for x86_64-linux-thread-multi
[hans@fedora ~]$ perl -MExpect -e 'print $Expect::VERSION ."\n";'
1.35
[hans@fedora ~]$ perl test.pl
Match before : ##############################################################################\r\n# This system is a restricted access system.
Match : #
Match after : \r\n# If collected security information reveals possible criminal activity that #\r\n# exceeds privileges, evidence of such activity may be provided to the rele- #\r\n# vantauthorities for further action. By continuing past this point, you #\r\n# expressly consent to this security monitoring. #\r\n##############################################################################\r\n\r\nhostname: ~#