Blog Archives
Search Blog Archives
Category Archives: Perl
Perl – Writing the Linux ‘cat’ Utility
The below Perl code will give you similar results compared to the Linux ‘cat’ utility. At the command prompt, just enter “perl [scriptname] [filename1] [filename2] etc …
Perl – File-Test Operators
In Perl, file-test operators are useful for determining the status of a file. Some of the operators below refer to the “real user” which is the User ID specified at login rather than “effectve User ID” which refers to the … Continue reading
Perl – Converting the Time from 24 hr to 12 hr Format
Below is a Perl script that demonstrates how to appropriately convert the current time from 24 hr format to 12 hr format. The ‘convertToTwelveHr’ subroutine does all the work here. The 24 hr input value is passed into the subroutine … Continue reading
Posted in Perl, Programming Languages, Technology
Tagged 24 hour to 12 hour, 24 hr to 12 hr, Converting the time from 24 hr to 12 hr format, localtime, localtime function, localtime subroutine, perl, Perl 24 hour to 12 hour, Perl script, Perl script that converts time from 24 hr to 12 hr
Leave a comment
Perl – merging files
Below I demonstrate a quick method of merging two files into a third file using Perl. The program merges two files together into a third file by writing one line from file one to file three and then writing one … Continue reading
Posted in Perl, Programming Languages
Tagged combine files, file merge, merge two files, merging files, perl, perl code
Leave a comment
Perl – Initial Values and Context Based Evaluation
It’s important to remember that in Perl all scalar variables have an initial value of the null string, “”. You do not need to define a value for scalar variables unless you are using “strict” mode. Knowing this, what do … Continue reading
Screen Scraping with Perl to get the top 25 Websites and the Web Servers they use
This was a really fun little script I wrote that I thought I would share with everyone. I basically wrote a Perl script using the popular LWP Perl module to screen scrape and obtain the top 25 sites and the … Continue reading
Posted in Data Mining, Hacks, Perl, Programming Languages, Technology
Tagged alexa, alexa.com, bot, bots, download webpage, hack, hacking, HTTP, HTTP header, HTTP request, HTTP response, Library for WWW in Perl, libwww-perl, LWP, LWP::Simple, LWP::UserAgent, perl, screen scraping, script, scripts, server, Simple, top 25 websites, UserAgent, web server. web servers. automate
3 Comments
Perl – Get files and directories with the glob function
Recently, as part of a larger Perl application, I had to get all the files and sub-directories of the working directory. Using the built-in ‘glob’ function, I was able to quickly implement a subroutine to do this and also differentiate … Continue reading
Posted in Perl, Programming Languages
Tagged get directories, get files, get sub-directories, glob, glob function, perl, perl glob, perl glob function
3 Comments
Use Perl’s regex to count the # of words in a file
In the below code I use Perl’s regex capabilites to count the # of words in a file. Notice I used “\s” in the regex expression to account for not only spaces but also tab and new line characters. In … Continue reading
Posted in Perl, Programming Languages
Tagged count words, file word count, file word counter, open file, perl, perl close file, perl code, perl file input, perl open file, perl read file, perl regex, perl regular expressions, perl word count code, regex, regex expression, regular expressions, whitespace, word counter
Leave a comment
How Perl/Python Scripts on Force10 S60 Switches Can Access the Internet
Let’s say you have a Force10 S60 switch [FTOS 8.3.3.4] hooked-up at a datacenter that currently has a console connection connected to a management switch that provides external Internet access. The natted IP address is 10.0.8.10/24 and the external IP … Continue reading
Posted in Force10 Networks, Labs, Networking, Perl, Programming Languages, Python, Technology
Tagged console, default route, external Internet access, Force10, Force10 Networks, management interface, management port, management route, management switch, nat, natted IP, perl, Python, router, S60, S60 Switch, switch
Leave a comment