spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

Perl adding date/time to a file name


There is no easy way to do that. The best you can do is to make a temporary directory, fetch the file there using the default name, then rename it to the name you need. Use File::Temp::tempdir:

use File::Fetch;
use DateTime qw();
use File::Temp qw( tempdir );

sub getDateUtility {
    return
DateTime->now->strftime('%m_%d_%Y')
}

sub fetchFile {
        my ($url, $destination) = @_;
        my $tempdir = tempdir( CLEANUP => 1 );
        my $fetcher = File::Fetch->new(
                uri => $url,
                to  => $tempdir,
        );
        my $fetched = $fetcher->fetch() or die
$fetcher->error;
        rename($fetched, $destination);
}

fetchFile('http://ec2-54-169-147-210.ap-southeast-1.compute.amazonaws.com/export.php?test=141121_5N_39140a1bc54a1cf78c9b131ed52f8654',
getDateUtility() . '.txt');

Please note that I changed your getDateUtility function to use underscores _ as a separators, not slashes /, as you cannot use slashes in a file name.

See also: this question.


Categories : Perl

Related to : Perl adding date/time to a file name
Automatic adding the common part to function of a class without explicitly adding those to every function
You can define two methods that do the common logic, for example - preProcess() and postProcess(). If the methods that execute this common logic are instnace methods of ObjectUtils, you can even override the common methods in sub-classes of ObjectUtils if you want to alter the common logic. If the methods that share the common logic are static methods, preProcess() and postProcess() would also b

Categories : Java
Adding li to ul
Updated. Probably this is what you wanna achieve? var str_list = "abc,cvb,zxcv,ert,wer"; var list = str_list.split(','); $.each(list, function(item){ $('ul').append('<li>' + item + '</li>'); })

Categories : Javascript
Adding Sub-queries
SELECT athlete.athlete_id, athlete.name, race.place FROM athlete INNER JOIN race ON race.athlete_id = athelete.athlete_id WHERE race.place IN (1, 2, 3); GROUP BY athlete.athlete_id HAVING count(athlete.athlete_id) >= 2 Try this.

Categories : Mysql
Adding a date in DIV in PHP
With date function: $output .= '<li><div class="time icon-clock">'.$needed_info[0].'</div> <div>'.date("Y-m-d H:i:s").'</div> <div class="ticket hover_right"><a href="'.$new_button_link.'" class="icon-ticket">'.$new_button_text.'</a></div><div class="event_auditory">' . __('Venue:', 'vh') . $value['theatre'].', '.$needed_info[1].'</di

Categories : PHP
Adding two variables - php
Instead of using a string to determine the number of people why not just use an int Here is a complete program <form action="" method="POST"> <select name="party"> <option value="1">1 People (+£5)</option> <option value="2">2 People (+£10)</option> <!-- ... --> <option value="10">10+ People (+£50)</option&

Categories : PHP
Recently Add
SSL error calling Perl web service via https using LWP
SOAP::Lite always faults in debug mode
perl referencing a hash outside of the scope that populated it (histogram)
Perl script to print out all the lines containing a keyword and the line below it
PERL Unicode Escape string pass from command line argument wrong output
Perl process crashes after handling signal
Marpa: Can I explicitly disallow keywords as identifiers?
Perl: Import text, containing ÅÄÖ, from file
error using perl - Proc::ProcessTable. works in cmd line, not in .pl file
DBIx::Class chaining resultsets with same table in prefetch
Time as input, print timetable in Perl
compare values of different tables perl
Automatically increasing ID generation using PERL
Syntax Error, first line after dostuff
Delete files in a folder using Perl
Perl '-d' operator is not detecting a directory
Perl appending text to new line
write_timeout in IO::Socket::Timeout
Using ForkManager and Perl properly?
Is a cyclic dependency solved with require?
Posting metric to google analytics from perl script
How can I check if a user enters my page the first time?
Sorting arrays of intervals in perl?
Perl: How to get the link target of a soundcloud feed mp3
Uninitialized value in concatenation
Perl code - pipe "|" in `open()` statement
perl command line backticks with matrix
Perl OO - Creating a list of objects
extract gene-id + function annotation from .gff
How to receive parameters and values from POST method in Perl CGI?
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.