• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Any awesome Perl Programmers?

Status
Not open for further replies.

Ferrio

Banned
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.
 

golem

Member
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

Banned
#!/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.
 
Status
Not open for further replies.
Top Bottom