Okay, so I'm a primarily Python developer who is trying to pick up a bit of perl. To do this, I'm trying to port old code from python to perl, purely as an exercise. The problem is, I'm guessing, the difference between the typing, or more specifically, trying to do everything to Python way.
I'm currently playing with an old script which removes the slug from blogs downloaded from google cache (Don't ask, it was important at the time
) and renames the file to this. A line in the python:
Code:
self.renamer( file, file.replace("%2F","_").split("+")[0].split(":")[2].rstrip("_") )
is giving me so much trouble in perl. Specifically constructing the second argument. I can get so far, though it looks too bloated, I'm sure there is a better way, but the 'rstrip()' bit is the hardest. I've looked at chop(), God help me I tried to change $/ and use chomp(). I've essentially got as far as
Code:
my $str = $file;
$str =~ s/\%2F/_/g;
@split_string = split(/\+/, $str);
$str = @split_string[0];
@split_string = split(/:/, $str);
$str = @split_string[-1];
renamer( "@_[0]$file", "@_[0]$str" );
Which essentially does the same thing as the single line above without, of course, the 'rstrip()' bit.
Could anybody point me in the right direction? Ideally, without giving me the answer or telling me to read a book or follow a guide. I'm comfortable enough with my basic perl skills, its just stuff like this.
Incidentally, this is the original python script
jamescondron.co.uk/slugger.py