Benchmark in Perl – replace

if you want to check whats the fastest way to replace a string in Perl you could use the Benchmark-Module.I compared 4 different ways  :

the result looks like:

Always check you sub results (Line 1-5) and make more test cases,

at the first case (Line 6) we see that for single character the best solution is to use regex.If you want to replace a longer string better use a C function.But in both cases its better to use the /o flag for regex to optimize, but then you cant interpolate a string in to the regex.And if you only want to replaxe use tr its the fastest.

Brute Force with Perl

This script is a brute force Perl-Script for sha256 password with a length of 4.You can edit the characters and the length.

Result looks like this :

 

Don’t try to use  this :

its much slower …..

 

Perl Preprocessor

I want to modify Perl for 3 things.

  1. Preprocessor
  2. if,for,while without brackets
  3. Useful things like current ram or average load

For this three things I wrote this script :

if you want to test it you have to save it at “/usr/bin/perlp”.

In line 4-7 I define some values for replace.

Line 10 you cant print the current free ram, for this the script replace the token via bash script Free Ram or Load Average .

Line 13 and 16 you see that you can use if without brackets.

Line 18-21 it prints the changed values.

Generate Preview Jpeg/gif from Video

I use this Perl-Function to create a Thumbnail Gif and a Preview JPEG for my videos.If you want to switch the image with mouse over in HTML see this script.

I use the standard variable $$  (Prozess-ID)  to create a own folder for each process then convert, optimize and then delete.

 

Perl Sitemap Generator

I think everyone has the problem to make a sitemap if you have more than 1M videos …this script counts the packets (40k) in line 19 and then make the packets to generate a sitemap.

Perl FTP

If you want to Upload files via Perl and FTP. you could use this script:

main.pl

the main script gets triggered from the WATCHDOG.pl script and is able to use the keywords on the page.

Line 6 start the phantom js

Line 11 Keywords

Line 15 Main Page crawl

Line 22 Keyword crawl

 

WATCHDOG

This is my Watchdog script to regulate the crawling scripts …..

Line 5-6 is to reset the scripts

Line 8 is to start the selenium server

Line 11 is my proxy port pointer … i user several ports ant to set the port I let the pointer iterate ….

Line 13-12 i count the phantomjs and main.pl

Line 15-16 is to remove the line break ….

Line 18-21 check the maximum values the start the script and let the pointer iterate ….

then sleep and redo the work ….