PDA

View Full Version : Any awesome Perl Programmers?


Ferrio
06-18-2004, 07:43 AM
Gimme tips.

Tenguman
06-18-2004, 07:45 AM
whatta ya need?

r - b - x
06-18-2004, 07:47 AM
timtowdi

Ferrio
06-18-2004, 07:55 AM
Tricks of the trade I don't know?


In brief I have to parse through a directory, get the file names strip stuff off. Use the file name to know how I should manipulate the image.

Just though someone could give some nice beggining tips about perl. I already got my program to make an array of files in a directory.

Ferrio
06-18-2004, 08:49 PM
This crap isnt' fun to read.

golem
06-18-2004, 09:05 PM
hmm if you've already extracted just the filenames from the directory, just use 'split' to split the filename and the extension, then write some if clauses to handle each different extension

Ferrio
06-18-2004, 09:27 PM
They're all the same extension.

I need to parse the actual filename for data.

Ferrio
06-19-2004, 02:05 AM
#!/usr/bin/perl

use strict;


my $DIR = "../EPPIM_images/";
opendir (D, "$DIR") or die "Can't open $DIR: $!\n";
my @files = grep { $_ ne '.' && $_ ne '..' } readdir D;
close(D);
@files = sort @files;



foreach my $file (@files) {

my $hour = $file;
$hour =~ s/\w+-//;
my $min = $hour;

$hour =~ s/\.\w+//g;
$hour = $hour * 60;
$min =~ s/\w+\.//;
$min =~ s/\.\w+//;
$min = $min + $hour;

my $degrees = $min*.25 + 90;

`convert -colors 24 -rotate $degrees ../EPPIM_images/$file ./rotated/$file`;

`convert ./rotated/$file ./rotated/$file.gif`;

`rm ./rotated/*.png`;
}



I know I can fix up all that horrible pattern matching, but i'm weak int he ways of perl.