in reply to Re: Perl Regex \A or ^ Not Working
in thread Perl Regex \A or ^ Not Working
I added data::dumper and warnings Output with auditmy $pattern = '\\Aaudit'; my $no_file_error ="TRUE"; my @dir_files = $ftp->dir($ftp_directory); $Data::Dumper::Useqq=1; print Dumper($pattern); my $netrc = Net::Netrc->lookup($ftp_server) or die ("Could not find lo +gin info in .netrc for $ftp_server"); my $ftp = Net::FTP->new($ftp_server, Port => $ftp_server_port, De +bug => 1) or die ('Could not create ftp object'); $ftp->login($netrc->login, $netrc->password) or die ('Could not l +og in'), $ftp->message; $ftp->binary(); #print directory of files before command print "--------------------First List all files------------------ +\n"; my @dir_files = $ftp->dir($ftp_directory); foreach my $list(@dir_files){ print "$list\n"; } @dir_files = grep { $_ =~ /$pattern/ } @dir_files; if (@dir_files == 0) { if ($no_file_error eq "TRUE") { print "No files exist with that $pattern\n"; } else { print "Send Email: Cannot find files to GET for parameter $pat +tern"; }} else { for my $list(@dir_files){ print "$ftp_command $list\n"; } }
This list is what is outputted with ^audit$VAR1 = "audit"; Net::FTP>>> Net::FTP(2.77) Net::FTP>>> Exporter(5.63) Net::FTP>>> Net::Cmd(2.29) Net::FTP>>> IO::Socket::INET(1.31) Net::FTP>>> IO::Socket(1.31) Net::FTP>>> IO::Handle(1.28) Net::FTP=GLOB(0xaec9e8)<<< 220 Titan FTP Server 11.20.2264 Ready. Net::FTP=GLOB(0xaec9e8)>>> USER xupromgr Net::FTP=GLOB(0xaec9e8)<<< 331 User name okay, need password. Net::FTP=GLOB(0xaec9e8)>>> PASS .... Net::FTP=GLOB(0xaec9e8)<<< 230-Welcome xupromgr from 10.253.2.119. You + are now logged in to the server. Net::FTP=GLOB(0xaec9e8)<<< 230 User logged in, proceed. Net::FTP=GLOB(0xaec9e8)>>> TYPE I Net::FTP=GLOB(0xaec9e8)<<< 200 Type set to I. --------------------First List all files------------------ Net::FTP=GLOB(0xaec9e8)>>> PASV Net::FTP=GLOB(0xaec9e8)<<< 227 Entering Passive Mode (10,253,1,56,236, +13). Net::FTP=GLOB(0xaec9e8)>>> LIST /AS/testftp Net::FTP=GLOB(0xaec9e8)<<< 150 File status okay; about to open data co +nnection. Net::FTP=GLOB(0xaec9e8)<<< 226 Closing data connection. Transferred 41 +5 bytes. drw-rw---- 1 xupromgr xupromgr 512 Mar 29 08:04 . drw-rw---- 1 xupromgr xupromgr 512 Mar 28 13:54 .. -rw-rw---- 1 xupromgr xupromgr 18 Feb 27 14:21 no_audit.txt -rw-rw---- 1 xupromgr xupromgr 18 Feb 27 14:21 no_audit_date +.txt -rw-rw---- 1 xupromgr xupromgr 10 Feb 27 14:08 auditsample.t +xt -rw-rw---- 1 xupromgr xupromgr 11 Feb 27 14:21 audit_date.tx +t get -rw-rw---- 1 xupromgr xupromgr 18 Feb 27 14:21 no_audit. +txt get -rw-rw---- 1 xupromgr xupromgr 18 Feb 27 14:21 no_audit_ +date.txt get -rw-rw---- 1 xupromgr xupromgr 10 Feb 27 14:08 auditsamp +le.txt get -rw-rw---- 1 xupromgr xupromgr 11 Feb 27 14:21 audit_dat +e.txt
This is with the variable set to \\Aaudit$VAR1 = "^audit"; Net::FTP>>> Net::FTP(2.77) Net::FTP>>> Exporter(5.63) Net::FTP>>> Net::Cmd(2.29) Net::FTP>>> IO::Socket::INET(1.31) Net::FTP>>> IO::Socket(1.31) Net::FTP>>> IO::Handle(1.28) Net::FTP=GLOB(0x1cdf9e8)<<< 220 Titan FTP Server 11.20.2264 Ready. Net::FTP=GLOB(0x1cdf9e8)>>> USER xupromgr Net::FTP=GLOB(0x1cdf9e8)<<< 331 User name okay, need password. Net::FTP=GLOB(0x1cdf9e8)>>> PASS .... Net::FTP=GLOB(0x1cdf9e8)<<< 230-Welcome xupromgr from 10.253.2.119. Yo +u are now logged in to the server. Net::FTP=GLOB(0x1cdf9e8)<<< 230 User logged in, proceed. Net::FTP=GLOB(0x1cdf9e8)>>> TYPE I Net::FTP=GLOB(0x1cdf9e8)<<< 200 Type set to I. --------------------First List all files------------------ Net::FTP=GLOB(0x1cdf9e8)>>> PASV Net::FTP=GLOB(0x1cdf9e8)<<< 227 Entering Passive Mode (10,253,1,56,235 +,244). Net::FTP=GLOB(0x1cdf9e8)>>> LIST /AS/testftp Net::FTP=GLOB(0x1cdf9e8)<<< 150 File status okay; about to open data c +onnection. Net::FTP=GLOB(0x1cdf9e8)<<< 226 Closing data connection. Transferred 4 +15 bytes. drw-rw---- 1 xupromgr xupromgr 512 Mar 29 08:04 . drw-rw---- 1 xupromgr xupromgr 512 Mar 28 13:54 .. -rw-rw---- 1 xupromgr xupromgr 18 Feb 27 14:21 no_audit.txt -rw-rw---- 1 xupromgr xupromgr 18 Feb 27 14:21 no_audit_date +.txt -rw-rw---- 1 xupromgr xupromgr 10 Feb 27 14:08 auditsample.t +xt -rw-rw---- 1 xupromgr xupromgr 11 Feb 27 14:21 audit_date.tx +t No files exist with that ^audit
$VAR1 = "\\Aaudit"; Net::FTP>>> Net::FTP(2.77) Net::FTP>>> Exporter(5.63) Net::FTP>>> Net::Cmd(2.29) Net::FTP>>> IO::Socket::INET(1.31) Net::FTP>>> IO::Socket(1.31) Net::FTP>>> IO::Handle(1.28) Net::FTP=GLOB(0x18539e8)<<< 220 Titan FTP Server 11.20.2264 Ready. Net::FTP=GLOB(0x18539e8)>>> USER xupromgr Net::FTP=GLOB(0x18539e8)<<< 331 User name okay, need password. Net::FTP=GLOB(0x18539e8)>>> PASS .... Net::FTP=GLOB(0x18539e8)<<< 230-Welcome xupromgr from 10.253.2.119. Yo +u are now logged in to the server. Net::FTP=GLOB(0x18539e8)<<< 230 User logged in, proceed. Net::FTP=GLOB(0x18539e8)>>> TYPE I Net::FTP=GLOB(0x18539e8)<<< 200 Type set to I. --------------------First List all files------------------ Net::FTP=GLOB(0x18539e8)>>> PASV Net::FTP=GLOB(0x18539e8)<<< 227 Entering Passive Mode (10,253,1,56,236 +,32). Net::FTP=GLOB(0x18539e8)>>> LIST /AS/testftp Net::FTP=GLOB(0x18539e8)<<< 150 File status okay; about to open data c +onnection. Net::FTP=GLOB(0x18539e8)<<< 226 Closing data connection. Transferred 4 +15 bytes. drw-rw---- 1 xupromgr xupromgr 512 Mar 29 08:04 . drw-rw---- 1 xupromgr xupromgr 512 Mar 28 13:54 .. -rw-rw---- 1 xupromgr xupromgr 18 Feb 27 14:21 no_audit.txt -rw-rw---- 1 xupromgr xupromgr 18 Feb 27 14:21 no_audit_date +.txt -rw-rw---- 1 xupromgr xupromgr 10 Feb 27 14:08 auditsample.t +xt -rw-rw---- 1 xupromgr xupromgr 11 Feb 27 14:21 audit_date.tx +t No files exist with that \Aaudit
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Perl Regex \A or ^ Not Working
by haukex (Archbishop) on Mar 29, 2019 at 12:35 UTC | |
by thundercat (Novice) on Mar 29, 2019 at 13:54 UTC | |
by thundercat (Novice) on Mar 29, 2019 at 17:18 UTC |