background preloader

Perl

Facebook Twitter

Apache

Tcl. Downloading YouTube videos with a Perl one-liner - good coders c. Last time I explained how YouTube videos can be downloaded with gawk programming language by getting the YouTube page where the video is displayed and finding out how the flash video player retrieves the FLV (flash video) media file.

This time I'll use Perl programming language which is my favorite language at the moment and write a one-liner which downloads a YouTube video. Instead of parsing the YouTube video page, let's look how an embedded YouTube video player on a 3rd party website gets the video. Let's go to this cool video and look at the embed html code: For this video it looks as following: 95% of this code is boring, the only interesting part is this URL: Let's load this in a browser, and as we do it, we get redirected to some other URL: So far we have no information how the flash player will retrieve the video, the only thing we know that 'iurl' stands for 'image url' and is the location of the thumbnail image.

Exploring Programming Language Architecture in Perl. Stately Scripting with mod_perl - The Perl Journal, Spring 1998. Lincoln Stein and Doug MacEachern One of the minor miracles of the World Wide Web is that it makes client/server network programming easy. With the Common Gateway Interface (CGI), anyone can become a network programmer, creating dynamic Web pages, front-ends for databases, and even complex intranet applications with ease. If you're like many Web programmers, you started out by writing CGI scripts in Perl. With its powerful text-processing facilities, forgiving syntax, and tool-oriented design, Perl lends itself to the small programs for which CGI was designed. Unfortunately the love affair between Perl and CGI doesn't last forever.

As your scripts get larger and your server more heavily loaded, you inevitably run into the performance wall. If your applications go beyond simple dynamic pages, you might have run into the limitations of the CGI protocol itself. Sadly, choosing among these technologies is a no-win situation. The Apache server offers you a way out. Installing mod_perl Figure 1. Ruby for Perl programmers. Practical mod_perl. SAGE ;login: - Effective Perl Programming. 20-PERL-Tips at Programmers Heaven.

Style. PerlMonks - The Monastery Gate. Perlopentut - tutorial on opening things i. Perlopentut - tutorial on opening things in Perl Perl has two simple, built-in ways to open files: the shell way for convenience, and the C way for precision. The choice is yours. Perl's open function was designed to mimic the way command-line redirection in the shell works. Here are some basic examples from the shell: $ myprogram file1 file2 file3 $ myprogram < inputfile $ myprogram > outputfile $ myprogram >> outputfile $ myprogram | otherprogram $ otherprogram | myprogram And here are some more advanced examples: $ otherprogram | myprogram f1 - f2 $ otherprogram 2>&1 | myprogram - $ myprogram <&3 $ myprogram >&4 Programmers accustomed to constructs like those above can take comfort in learning that Perl directly supports these familiar constructs using virtually the same syntax as the shell.

Simple Opens For example: open(INFO, "datafile") || die("can't open datafile: $! ") If you prefer the low-punctuation version, you could write that this way: A few things to notice. Pipe Opens The Minus File. Object-Oriented Perl. I've recently started learning to play the game of Go. Go and Perl have many things in common -- the basic stuff of which they are made, the rules of the game, are relatively simple, and hide an amazing complexity of possibilities beneath the surface.

But I think the most interesting thing I've found that Go and Perl have in common is that there are various different stages in your development as you learn either one. It's almost as if there are several different plateaus of experience, and you have to climb up a huge hill before getting onto the next plateau. For instance, a Go player can play very simply and acquit himself quite decently, but to stop being a beginner and really get into the game, he has to learn how to attack and defend economically. Then, to move on to the next stage, he has to master fighting a repetitive sequence called a "ko.

" So what is it? The same code, written in an object-oriented style, would look a little different: What's going on here? Why is it a win? #! #! Perl, SQL, and Web Publishing Security. Perl Programming - Free computer book. Perl is a dynamic programming language created by Larry Wall and first released in 1987. Perl borrows features from a variety of other languages including C, shell scripting (sh), AWK, sed and Lisp. Structurally, Perl is based on the brace-delimited block style of AWK and C, and was widely adopted for its strengths in string processing, and lack of the arbitrary limitations of many scripting languages at the time. Larry Wall began work on Perl in 1987, while working as a programmer at Unisys,[3] and released version 1.0 to the comp.sources.misc newsgroup on December 18, 1987.

The language expanded rapidly over the next few years. Perl 2, released in 1988, featured a better regular expression engine. Until 1991, the only documentation for Perl was a single (increasingly lengthy) man page. Perl 4 went through a series of maintenance releases, culminating in Perl 4.036 in 1993. Initial design of Perl 5 continued into 1994. Perl 5 was released on October 17, 1994. The Perl Directory - perl.org. Mod perl - Wikipedia, the free encyclopedi. Mod_perl can emulate a Common Gateway Interface (CGI) environment, so that existing Perl CGI scripts can benefit from the performance boost without having to be re-written.

See also[edit] External links[edit] The Magic of mod_perl. By Frank Wiles NOTE: This article first appeared in SysAdmin Magazine in January 2005. The mod_perl API has changed since that time and the following code examples will require slight modification to work I often run into people who are confused about what mod_perl is. Some people think mod_perl is only useful to speed up CGI scripts. In short, mod_perl embeds a Perl interpretor directly into your Apache web server. When a browser requests a page from an Apache server, the request goes through several processing phases. The power of mod_perl is that it gives you the ability to replace the default behaviors of any of these phases with your own phase handlers. mod_perl handlers can be thought of as true Apache modules, plugged directly into the server, rather than a script or other outside process.

Here are some examples of mod_perl's abilities: Installation Installing mod_perl is a relatively easy task. Configuration use lib qw(/path/to/perl/libs); use Apache2; 1; Speeding up CGIs Conclusion. KinoSearch.