CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [tester_V] failing to copy files: Edit Log



Chris Charley
User

Nov 19, 2017, 11:36 AM


Views: 11028
Re: [tester_V] failing to copy files

Hello,

This example should show you what you need.


Code
#!/usr/bin/perl 
use strict;
use warnings;
use File::Basename 'fileparse';

open my $fh, '<', \<<EOF;
C:/LogFiles-S/Tell_flow_log.2017-10-01.1.log
C:/LogFiles-S/Tell_flow_log.2017-10-01.2.log
C:/LogFiles-S/Tell_flow_log.2017-10-01.3.log
C:/LogFiles-S/Tell_flow_log.2017-10-01.4.log
C:/LogFiles-S/Tell_flow_log.2017-10-01.5.log
C:/LogFiles-S/Tell_flow_log.2017-10-02.1.log
C:/LogFiles-S/Tell_flow_log.2017-10-02.2.log
C:/LogFiles-S/Tell_flow_log.2017-10-02.3.log
C:/LogFiles-S/Tell_flow_log.2017-10-02.4.log
C:/LogFiles-S/Tell_flow_log.2017-10-02.5.log
EOF

my $ndirname1 = "C:/Sixshot_logs/Flow/";

while (my $line = <$fh>) {
chomp $line;
my $filename = fileparse($line);
print "$ndirname1$filename\n";
}


Output:

Code
 
C:\Old_Data\perlp>perl test2.pl
C:/Sixshot_logs/Flow/Tell_flow_log.2017-10-01.1.log
C:/Sixshot_logs/Flow/Tell_flow_log.2017-10-01.2.log
C:/Sixshot_logs/Flow/Tell_flow_log.2017-10-01.3.log
C:/Sixshot_logs/Flow/Tell_flow_log.2017-10-01.4.log
C:/Sixshot_logs/Flow/Tell_flow_log.2017-10-01.5.log
C:/Sixshot_logs/Flow/Tell_flow_log.2017-10-02.1.log
C:/Sixshot_logs/Flow/Tell_flow_log.2017-10-02.2.log
C:/Sixshot_logs/Flow/Tell_flow_log.2017-10-02.3.log
C:/Sixshot_logs/Flow/Tell_flow_log.2017-10-02.4.log
C:/Sixshot_logs/Flow/Tell_flow_log.2017-10-02.5.log



(This post was edited by Chris Charley on Nov 19, 2017, 3:49 PM)


Edit Log:
Post edited by Chris Charley (User) on Nov 19, 2017, 11:40 AM
Post edited by Chris Charley (User) on Nov 19, 2017, 3:49 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives