Skip to Content
Learning Perl, Fourth Edition
book

Learning Perl, Fourth Edition

by Randal L. Schwartz, Tom Phoenix, brian d foy
July 2005
Beginner
312 pages
9h 23m
English
O'Reilly Media, Inc.
Content preview from Learning Perl, Fourth Edition

Converting Other Languages to Perl

If you’ve got old sed and awk programs that you wish were written in Perl, you’re in luck. Not only can Perl do everything that those can do, it has a conversion program, and it’s probably installed on your system. Check the documentation for s2p (for converting from sed) or a2p (for converting from awk).[399] Since programs don’t write programs as well as people do, the results won’t be the best Perl, but it’s a start and it’s easy to tweak. The translated program may be faster or slower than the original, too. After you’ve fixed up any gross inefficiencies in the machine-written Perl code, it should be comparable.

Do you have C algorithms you want to use from Perl? Luck is on your side; it’s not too hard to put C code into a compiled module that can be used from Perl. In fact, just about any language that compiles to make object code can be used to make a module. See the perlxs manpage and the Inline module, as well as the SWIG system.

Do you have a shell script you want to convert to Perl? Your luck has run out. There’s no automatic way to convert shell to Perl. That’s because the shell hardly does anything by itself; it spends all of its time running other programs. Sure, we could make a program that would mostly call system for each line of the shell, but that would be slower than letting the shell do things in the first place. It takes a human level of intelligence to see how the shell’s use of cut, rm, sed, awk, and grep can be turned into ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Learning Perl, 3rd Edition

Learning Perl, 3rd Edition

Tom Phoenix, Randal L. Schwartz
Learning Perl, 6th Edition

Learning Perl, 6th Edition

Randal L. Schwartz, brian d foy, Tom Phoenix
Mastering Perl

Mastering Perl

brian d foy

Publisher Resources

ISBN: 0596101058Catalog PageErrata