Sponsored Content
Full Discussion: hard question
Top Forums UNIX for Advanced & Expert Users hard question Post 302220966 by redoubtable on Saturday 2nd of August 2008 01:23:34 PM
Old 08-02-2008
I see you're in mktime() paradise.
From the man mktime:
Code:
           struct tm {
               int tm_sec;         /* seconds */
               int tm_min;         /* minutes */
               int tm_hour;        /* hours */
               int tm_mday;        /* day of the month */
               int tm_mon;         /* month */
               int tm_year;        /* year */
               int tm_wday;        /* day of the week */
               int tm_yday;        /* day in the year */
               int tm_isdst;       /* daylight saving time */
           };

 tm_yday
              The number of days since January 1, in the range 0 to 365.

Well, I couldn't get mktime() to work directly, but I still used tm_yday.
Code:
Tsunami julian_days # perl test2.pl 
Enter start date [yyyy/mm/dd]: 20080101
Enter end date [yyyy/mm/dd]: 20080220
A2008041231000.L2
A2008021231000.L2
A2008001231000.L2
Tsunami julian_days # perl test2.pl 
Enter start date [yyyy/mm/dd]: 2008/01/01  
Enter end date [yyyy/mm/dd]: 2008/02/20
A2008041231000.L2
A2008021231000.L2
A2008001231000.L2
Tsunami julian_days #

and the code:

Code:
#!/usr/bin/perl -w

use POSIX;

$| = 1;

my $input;
my (@date_s, @date_e);

opendir(DIR, ".") || die "can't opendir: $!";
@dots = grep { ! /^\./ && /\.L2$/ } readdir(DIR);
closedir DIR;

print "Enter start date [yyyy/mm/dd]: ";
($input = <STDIN>) =~ /(\d{4})\/*-*(\d{2})\/*-*(\d{2})/;
$date_s[0] = mktime (0, 0, 0, $3, ($2-1), ($1-1900), 0, 0);
$date_s[2] = $1;
print "Enter end date [yyyy/mm/dd]: ";
($input = <STDIN>) =~ /(\d{4})\/*-*(\d{2})\/*-*(\d{2})/;
$date_e[0] = mktime (0, 0, 0, $3, ($2-1), ($1-1900), 0, 0);
$date_e[2] = $1;
(undef, undef, undef, undef, undef, undef, undef, $date_s[1] ,undef) = localtime($date_s[0]);
(undef, undef, undef, undef, undef, undef, undef, $date_e[1] ,undef) = localtime($date_e[0]);

foreach my $i (@dots)
{
        $i =~ /^A(\d{4})(\d{3})/;
        print $i . "\n" if (($1 >= $date_s[2] && $1 <= $date_e[2]) && (($2+0) >= $date_s[1] && ($2+0) <= $date_e[1]));  
}

 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Experts Only! Hard Question Ahead!!!!

SunOS5.8 is a radical departure from SunOs4.X in many ways. one of the important differences is the handling of devices. Adding devices under SunOS4.x required a kernel reconfiguration, recompliation and reboot. Under SunOS5.X, this has changed with the ability to add some drivers on the fly.... (1 Reply)
Discussion started by: Foo49272
1 Replies

2. UNIX for Advanced & Expert Users

Please Help.... Desperate need! Hard Question!

I know pipelined processors have issues with interupts.... but why? And does the architecture of the CPU affect the kind of software that can run on it? If someone could help me out that would be awsome. My boss came to me with this question and I can't find anything on the web helping me out.... (1 Reply)
Discussion started by: Sparticus007
1 Replies

3. Filesystems, Disks and Memory

The best partitioning schem for a 250GB Sata hard drive & a 75GB SCSI hard drive

Hi I have 2 75GB SCSI hard drives and 2 250GB SATA hard drives which are using RAID Level 1 respectively. I wana have both FTP and Apache installed on them as services. I'm wondering what's the best partitioning schem? I wana use FC3 as my OS, so, I thought I can use the 75GB hard drive as the /... (0 Replies)
Discussion started by: sirbijan
0 Replies

4. UNIX for Dummies Questions & Answers

hard/soft link question

I am curious about one thing. Lets say I have a file file-a to which new generations are created on demand by simply archiving it (ex: file-a.tar.gz) and having the new one created with the same original filename file-a. Now what I want to know is if I create a hard/soft link to file-a, what... (1 Reply)
Discussion started by: Browser_ice
1 Replies

5. AIX

Hard Drive Question

Good day, I have an rs/6000 server, model 7044-270. I bought a 2nd hard drive for it but im not sure its the right one. (fru:H13060) As you surely know, the 7044-270 hard drives are put in some sort of tray/carrier. There is a cable that will interface the HDD with the tray/carrier so the... (0 Replies)
Discussion started by: Netghost
0 Replies

6. UNIX for Dummies Questions & Answers

[question] hard exercise, help needed

Hello guys. Well, on this exercise i need the average "chargeAmount" per hour (for each hour). with this code : cat getusagesummarywrongmatch | grep -iv MOU2GRTObject | cut -d'|' -f4,14 | grep -i chargeamount | cut -d' ' -f2 http://img227.imageshack.us/img227/5889/65969235do0.jpg i got... (2 Replies)
Discussion started by: EnioMarques
2 Replies

7. Shell Programming and Scripting

Simple question (for you guys, hard for me)

I am trying to exit this script by cd'ing into a particular directory. #!/bin/bash /opt/xxx/xxx/d2h $1 fname=$( /opt/xxx/xxx/d2h $1) cd /opt/xxx1/xxx1 find . -name '*'$fname'*' -ls cd /opt/xxx1/xxx1 Upon execution, it returns to my home directory (where I am running this script from. ... (3 Replies)
Discussion started by: BkontheShell718
3 Replies

8. Shell Programming and Scripting

Recursively hard linking files -- bonehead question

I used to program ksh a while back, but I've been off in Oracle/Windows land (for clients -- not by choice) for so long that I can't remember what should be an easy thing. Here's the scenario: 1)Find all files and directories beneath some directory point (A). 2)If directory, make the... (7 Replies)
Discussion started by: scyphers
7 Replies

9. Shell Programming and Scripting

special question, hard to describe in few words...

dear coders, i need some inspiration again... there is something what i always wanted to know... how to code following: value 1: __________ value 2: __________ important: when my "script" starts the display has to be cleared and two lines are shown (see above), the cursor has to be... (2 Replies)
Discussion started by: pseudocoder
2 Replies

10. UNIX for Beginners Questions & Answers

Question about setting up a hard drive for a videoserver under Linux

Hi there, I'm currently preparing for an exam and came across a question that I don't really know how to answer. "You want to set up a hard drive for a videoserver under linux. - The videofiles will have a size of at least 10MB and a maximum of 8BG. - The hard drive has a disk space of... (1 Reply)
Discussion started by: Eggsy
1 Replies
Gtk2::RcStyle(3)					User Contributed Perl Documentation					  Gtk2::RcStyle(3)

NAME
Gtk2::RcStyle HIERARCHY
Glib::Object +----Gtk2::RcStyle METHODS
rcstyle = Gtk2::RcStyle->new color = $style->base ($state, $new=undef) o $state (Gtk2::StateType) o $new (Gtk2::Gdk::Color or undef) color = $style->bg ($state, $new=undef) o $state (Gtk2::StateType) o $new (Gtk2::Gdk::Color or undef) scalar = $style->bg_pixmap_name ($state, $new=undef) o $state (Gtk2::StateType) o $new (string or undef) rcflags = $style->color_flags ($state, $new=0) o $state (Gtk2::StateType) o $new (Gtk2::RcFlags) rcstyle = $orig->copy color = $style->fg ($state, $new=undef) o $state (Gtk2::StateType) o $new (Gtk2::Gdk::Color or undef) scalar = $style->font_desc ($new=undef) o $new (scalar) scalar = $style->name ($new=undef) o $new (scalar) color = $style->text ($state, $new=undef) o $state (Gtk2::StateType) o $new (Gtk2::Gdk::Color or undef) scalar = $style->xthickness ($new=undef) o $new (scalar) scalar = $style->ythickness ($new=undef) o $new (scalar) ENUMS AND FLAGS
flags Gtk2::RcFlags o 'fg' / 'GTK_RC_FG' o 'bg' / 'GTK_RC_BG' o 'text' / 'GTK_RC_TEXT' o 'base' / 'GTK_RC_BASE' enum Gtk2::StateType o 'normal' / 'GTK_STATE_NORMAL' o 'active' / 'GTK_STATE_ACTIVE' o 'prelight' / 'GTK_STATE_PRELIGHT' o 'selected' / 'GTK_STATE_SELECTED' o 'insensitive' / 'GTK_STATE_INSENSITIVE' SEE ALSO
Gtk2, Glib::Object COPYRIGHT
Copyright (C) 2003-2008 by the gtk2-perl team. This software is licensed under the LGPL. See Gtk2 for a full notice. perl v5.12.1 2010-07-05 Gtk2::RcStyle(3)
All times are GMT -4. The time now is 05:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy