Sponsored Content
Top Forums Shell Programming and Scripting Perl: code efficiency for gmtime Post 302218926 by KevinADC on Sunday 27th of July 2008 03:09:45 PM
Old 07-27-2008
The function should do all the date formatting and return the string ready to use. And don't use concatenation when simple string constructors will suffice.

Code:
# get datetime
$strdate = format_date((gmtime ())[0..5]);
# write to file
getstore($url, "$strdate.txt") or die "Error: Unable to get page $url";

sub format_date {
   my @t = @_;
   ++$t[4];
   $t[5]+=1900;
   for (@t[0..4]) {
      $_ = $_ < 10 ? "0$_" : $_;
   }
   return "$t[5]$t[4]$t[3]$t[2]$t[1]$t[0]"; 
}

Note that the link in your post is to a well known pirate website. Please do not post links to that website anymore. Thank you.
 

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

efficiency..

how efficient is it, and how practical is it to call outside programs in a shell script (bash) for small tasks? for example, say i have a script that might preform many tasks, one of those tasks may require root access; rather than implementing inside the script a method to use su or sudo to... (11 Replies)
Discussion started by: norsk hedensk
11 Replies

2. Shell Programming and Scripting

Improve program efficiency (awk)

Hi !! I've finished an awk exercise. Here it is: #!/bin/bash function calcula { # Imprimimos el mayor tamaño de fichero ls -l $1 | awk ' BEGIN { max = $5; # Inicializamos la variable que nos guardará el máximo con el tamaño del primer archivo } { if ($5 > max){ #... (8 Replies)
Discussion started by: Phass
8 Replies

3. Shell Programming and Scripting

The efficiency between GREP and SED???

Hello Everyone! I am a newbie. I'd like to get key lines from a big txt file by Reg Exp, The file is nearly 22MB. GREP or SED?which may be the best choice,more efficient way? or any other best practise? Thank you in advance. Ever:) (5 Replies)
Discussion started by: ever
5 Replies

4. Shell Programming and Scripting

File or Folder Efficiency?

I've got this program set up so that it creates files whose unique names specify the jobs their contents describe. In order to retrieve the information inside those files, I have to do a "grep" and awk or sed to extract it. I've just assumed that making a directory with that unique name that... (1 Reply)
Discussion started by: gmark99
1 Replies

5. UNIX for Advanced & Expert Users

About efficiency of parallel memory allocation

Hello, there. I'm a new beginner to Linux kernel and curious about its memory management. When multiple applications apply for memory space at the same time, how Linux kernel solve the resource contending problem for high performance? I have known that there is a buddy system for allocating and... (4 Replies)
Discussion started by: blackwall
4 Replies
Finance::Quote::Cdnfundlibrary(3pm)			User Contributed Perl Documentation		       Finance::Quote::Cdnfundlibrary(3pm)

NAME
Finance::Quote::Cdnfundlibrary - Obtain mutual fund prices from www.fundlibrary.com SYNOPSIS
use Finance::Quote; $q = Finance::Quote->new; %stockinfo = $q->fetch("canadamutual","fundlib-code"); # Can failover to other methods %stockinfo = $q->fetch("fundlibrary","fundlib-code"); # Use this module only. # NOTE: currently no failover methods exist for canadamutual DESCRIPTION
This module obtains information about Canadian Mutual Fund prices from www.fundlibrary.com. The information source "canadamutual" can be used if the source of prices is irrelevant, and "fundlibrary" if you specifically want to use www.fundlibrary.com. FUNDLIB-CODE In Canada a mutual fund does not have a unique global symbol identifier. This module uses an id that represents the mutual fund on an id used by www.fundlibrary.com. There is no easy way of fetching the id except to jump onto the fundlibrary website, look up the fund and view the url for clues to its id number. LABELS RETURNED
Information available from fundlibrary may include the following labels: exchange method link source name currency yield last nav price. The link label will be a url location for a one page snapshot that fundlibrary provides on the fund. SEE ALSO
Fundlibrary website - http://www.fundlibrary.com/ Finance::Quote perl v5.14.2 2012-05-06 Finance::Quote::Cdnfundlibrary(3pm)
All times are GMT -4. The time now is 11:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy