Extending and Embedding Perl

Total Page:16

File Type:pdf, Size:1020Kb

Extending and Embedding Perl Extending and Embedding Perl Extending and Embedding Perl TIM JENNESS SIMON COZENS MANNING Greenwich (74° w. long.) For online information and ordering of this and other Manning books, go to www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact: Special Sales Department Manning Publications Co. 209 Bruce Park Avenue Fax: (203) 661-9018 Greenwich, CT 06830 email: [email protected] ©2003 by Manning Publications Co. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps. Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end. Manning Publications Co. Copyeditor: Tiffany Taylor 209 Bruce Park Avenue Typesetter: Dottie Marsico Greenwich, CT 06830 Cover designer: Leslie Haimes ISBN 1930110820 Printed in the United States of America 12345678910–VHG–0605040302 To the Perl open source community contents preface xiii acknowledgments xv about this book xvi author online xix about the cover illustration xx 1 C for Perl programmers 1 1.1 Hello, world 1 1.2 The C compiler 2 1.3 Header files 3 1.4 The main function 4 1.5 Variables and functions 6 Function parameters 6 ✦ Automatic variables 7 Global variables 8 ✦ Static variables 9 1.6 Data types 10 C types 11 ✦ Types defined in Perl 15 1.7 Casting 16 1.8 Control constructs 17 Statements and blocks 17 ✦ The break and continue statements 18 ✦ The switch statement 19 1.9 Macros and the C preprocessor 20 1.10 Library functions 23 1.11 Summary 23 2 Extending Perl: an introduction 24 2.1 Perl modules 24 Module distributions 26 vii 2.2 Interfacing to another language: C from XS 30 The Perl module 30 ✦ The XS file 31 ✦ Example: “Hello, world” 32 Return values 36 ✦ Arguments and return values 37 2.3 XS and C: taking things further 38 Modifying input variables 38 ✦ Output arguments 39 Compiler constants 40 2.4 What about Makefile.PL? 44 It really is a Perl program 47 2.5 Interface design: part 1 47 Status and multiple return arguments 48 ✦ Don’t supply what is already known 48 ✦ Don’t export everything 49 Use namespaces 49 ✦ Use double precision 49 2.6 Further reading 50 2.7 Summary 50 3Advanced C51 3.1 Arrays 51 3.2 Pointers 53 Pointers and arrays 55 ✦ Pointers to functions 57 3.3 Strings 58 Arrays of strings 59 3.4 Structures 60 3.5 File I/O 62 3.6 Memory management 63 Allocating memory at runtime 64 ✦ Altering the size of memory 65 Manipulating memory 65 ✦ Memory manipulation and Perl 67 3.7 C Traps for the Perl programmer 68 3.8 Further reading 69 3.9 Summary 69 4Perl’s variable types70 4.1 General concepts 70 Reference counting 71 ✦ Looking inside: Devel::Peek 71 ✦ The flag system 72 4.2 Scalar variables 74 The SvNULL type 74 ✦ SvRV: references 76 ✦ SvPV: string values 76 ✦ SvPVIV: integers 78 ✦ SvPVNV: floating-point numbers 79 ✦ SvIV and SvNV 80 ✦ SvOOK: offset strings 80 4.3 Magic variables: SvPVMG 81 viii CONTENTS 4.4 Array variables 85 4.5 Hashes 87 4.6 Globs 91 4.7 Namespaces and stashes 94 4.8 Lexical “my” variables 95 4.9 Code blocks 96 Important CV flags 97 4.10 Further reading 99 4.11 Summary 99 5 The Perl 5 API 100 5.1 Sample entry 101 5.2 SV functions 101 Special SVs 101 ✦ Creating SVs 103 ✦ Accessing data 110 Manipulating data 119 ✦ String functions 124 ✦ References 129 5.3 AV functions 132 Creation and destruction 132 ✦ Manipulating elements 136 Testing and changing array size 142 5.4 HV functions 144 Creation and destruction 144 ✦ Manipulating elements 146 5.5 Miscellaneous functions 150 Memory management 150 ✦ Unicode data handling 155 Everything else 158 5.6 Summary 162 6 Advanced XS programming 163 6.1 Pointers and things 164 6.2 Filehandles 166 6.3 Typemaps 167 6.4 The argument stack 169 6.5 C structures 170 C structures as black boxes 170 ✦ C structures as objects 176 C structures as hashes 179 6.6 Arrays 183 Passing numeric arrays from Perl to C 183 ✦ Passing numeric arrays from C to Perl 190 ✦ The Perl Data Language 192 Benchmarks 198 ✦ Character strings 199 CONTENTS ix 6.7 Callbacks 202 Immediate callbacks 203 ✦ Deferred callbacks 206 ✦ Multiple callbacks 207 6.8 Other languages 209 Linking Perl to C++ 209 ✦ Linking Perl to Fortran 216 Linking Perl to Java 223 6.9 Interface design: part 2 223 6.10 Older Perls 224 6.11 What’s really going on? 225 What does xsubpp generate? 226 6.12 Further reading 230 6.13 Summary 230 7 Alternatives to XS 231 7.1 The h2xs program 232 7.2 SWIG 233 Data structures 236 7.3 The Inline module 238 What is going on? 239 ✦ Additional Inline examples 240 Inline and CPAN 245 ✦ Inline module summary 246 7.4 The PDL::PP module 247 The .pd file 248 ✦ The Makefile.PL file 249 ✦ Pure PDL 251 7.5 Earlier alternatives 251 7.6 Further reading 252 7.7 Summary 253 8 Embedding Perl in C 254 8.1 When to embed 254 8.2 When not to embed 255 8.3 Things to think about 255 8.4 “Hello C” from Perl 255 Compiling embedded programs 257 8.5 Passing data 257 8.6 Calling Perl routines 259 Stack manipulation 261 ✦ Context 263 ✦ Trapping errors with eval 263 ✦ Calling Perl methods in C 264 ✦ Calling Perl statements 265 8.7 Using C in Perl in C 265 8.8 Embedding wisdom 266 8.9 Summary 267 x CONTENTS 9 Embedding case study 268 9.1 Goals 268 9.2 Preparing the ground 269 9.3 Configuration options 270 9.4 Testing options 273 Binary options 273 ✦ Quad-state options 274 ✦ String options 275 9.5 Summary 276 10 Introduction to Perl internals 277 10.1 The source tree 277 The Perl library 277 ✦ The XS library 278 ✦ The I/O subsystem 278 The Regexp engine 278 ✦ The parser and tokenizer 278 ✦ Variable handling 279 ✦ Runtime execution 279 10.2 The parser 279 BNF and parsing 279 ✦ Parse actions and token values 281 Parsing some Perl 281 10.3 The tokenizer 282 Basic tokenizing 282 ✦ Sublexing 284 ✦ Tokenizer summary 285 10.4 Op code trees 285 The basic op 285 ✦ The different operations 286 ✦ Different flavors of ops 286 ✦ Tying it all together 288 ✦ PP Code 290 The opcode table and opcodes.pl 293 ✦ Scratchpads and targets 293 The optimizer 294 ✦ Op code trees summary 294 10.5 Execution 295 10.6 The Perl compiler 295 What is the Perl compiler? 296 ✦ B:: modules 296 ✦ What B and O provide 299 ✦ Using B for simple tasks 300 10.7 Further reading 303 10.8 Summary 303 11 Hacking Perl 304 11.1 The development process 304 Perl versioning 304 ✦ The development tracks 305 ✦ The perl5-porters mailing list 305 ✦ Pumpkins and pumpkings 305 ✦ The Perl repository 306 11.2 Debugging aids 306 Debugging modules 307 ✦ The built-in debugger: perl -D 307 Debugging functions 310 ✦ External debuggers 310 11.3 Creating a patch 317 How to solve problems 317 ✦ Autogenerated files 318 ✦ The patch itself 319 Documentation 320 ✦ Testing 320 ✦ Submitting your patch 320 CONTENTS xi 11.4 Perl 6: the future of Perl 321 A history 321 ✦ Design and implementation 322 What happens next 323 ✦ The future for Perl 5 323 11.5 Further reading 323 11.6 Summary 323 A: Perl’s typemaps 324 B: Further reading 348 C: Perl API index 350 index 355 xii CONTENTS preface Perl is a wonderful language. We, along with at least a million other programmers, love it dearly. It’s great for all kinds of applications: text processing, network programming, system administra- tion, and much more. But there are times when we need to go beyond the core of the language and do something not provided by Perl. Sometimes we do this without noticing it: several modules that ship with Perl call out to C routines to get their work done, as do some of the most commonly used CPAN modules. Other times, we do it deliberately: the various modules for building graphical applications in Perl almost all, directly or indirectly, use external C libraries. Either way, writing extensions to Perl has his- torically been a bit of a black art. We don’t believe this situation is fair, so we’ve written this book to attempt to demystify the process of relating Perl and C. That’s not to say we’re fed up with writing modules in Perl. Both of us write many of our mod- ules in Perl, and although sometimes it might be easier to interface to C, we’ve decided to stick with Perl. In fact, writing a module in Perl has a number of advantages over using other languages: • It is far easier to write portable cross-platform code in Perl than in C. One of the successes of Perl has been its support of varied operating systems.
Recommended publications
  • Learning to Program in Perl
    Learning to Program in Perl by Graham J Ellis Languages of the Web Learning to Program in Perl version 1.7 Written by Graham Ellis [email protected] Design by Lisa Ellis Well House Consultants, Ltd. 404, The Spa, Melksham, Wiltshire SN12 6QL England +44 (0) 1225 708 225 (phone) +44 (0) 1225 707 126 (fax) Find us on the World Wide Web at: http://www.wellho.net Or contact us at: [email protected] Copyright © 2003 by Well House Consultants, Ltd. Printed in Great Britain. Printing History May 1999 1.0 First Edition February 2000 1.1 Minor additions June 2000 1.2 Compliation of modules October 2000 1.3 Name change, revisions April 2002 1.4 Added modules September 2002 1.5 Added modules January 2003 1.6 Updated modules February 2003 1.7 Updated modules This manual was printed on 21 May 2003. Notice of Rights All rights reserved. No part of this manual, including interior design, may be reproduced or translated into any language in any form, or transmitted in any form or by any means electronic, mechanical, photocopying, recording or otherwise, without prior written permission of Well House Consultants except in the case of brief quotations embodied in critical articles and reviews. For more information on getting permission for reprints and excerpts, contact Graham Ellis at Well House Consultants. This manual is subject to the condition that it shall not, by way of trade or otherwise, be lent, sold, hired out or otherwise circulated without the publisher's prior consent, incomplete nor in any form of binding or cover other than in which it is published and without a similar condition including this condition being imposed on the subsequent receiver.
    [Show full text]
  • How to Secure Your Web Site Picked up SQL Injection and Cross-Site Scripting As Sample Cases of Failure Because These Two Are the Two Most Reported Vulnerabilities
    How to Secure your Website rd 3 Edition Approaches to Improve Web Application and Web Site Security June 2008 IT SECURITY CENTER (ISEC) INFORMATION-TECHNOLOGY PROMOTION AGENCY, JAPAN This document is a translation of the original Japanese edition. Please be advises that most of the references referred in this book are offered in Japanese only. Both English and Japanese edition are available for download at: http://www.ipa.go.jp/security/english/third.html (English web page) http://www.ipa.go.jp/security/vuln/websecurity.html (Japanese web page) Translated by Hiroko Okashita (IPA), June 11 2008 Contents Contents ......................................................................................................................................... 1 Preface ........................................................................................................................................... 2 Organization of This Book ........................................................................................................... 3 Intended Reader ......................................................................................................................... 3 Fixing Vulnerabilities – Fundamental Solution and Mitigation Measure - .................................... 3 1. Web Application Security Implementation ............................................................................... 5 1.1 SQL Injection .................................................................................................................... 6 1.2
    [Show full text]
  • Mod Perl 2.0 Source Code Explained 1 Mod Perl 2.0 Source Code Explained
    mod_perl 2.0 Source Code Explained 1 mod_perl 2.0 Source Code Explained 1 mod_perl 2.0 Source Code Explained 15 Feb 2014 1 1.1 Description 1.1 Description This document explains how to navigate the mod_perl source code, modify and rebuild the existing code and most important: how to add new functionality. 1.2 Project’s Filesystem Layout In its pristine state the project is comprised of the following directories and files residing at the root direc- tory of the project: Apache-Test/ - test kit for mod_perl and Apache2::* modules ModPerl-Registry/ - ModPerl::Registry sub-project build/ - utilities used during project build docs/ - documentation lib/ - Perl modules src/ - C code that builds libmodperl.so t/ - mod_perl tests todo/ - things to be done util/ - useful utilities for developers xs/ - source xs code and maps Changes - Changes file LICENSE - ASF LICENSE document Makefile.PL - generates all the needed Makefiles After building the project, the following root directories and files get generated: Makefile - Makefile WrapXS/ - autogenerated XS code blib/ - ready to install version of the package 1.3 Directory src 1.3.1 Directory src/modules/perl/ The directory src/modules/perl includes the C source files needed to build the libmodperl library. Notice that several files in this directory are autogenerated during the perl Makefile stage. When adding new source files to this directory you should add their names to the @c_src_names vari- able in lib/ModPerl/Code.pm, so they will be picked up by the autogenerated Makefile. 1.4 Directory xs/ Apache2/ - Apache specific XS code APR/ - APR specific XS code ModPerl/ - ModPerl specific XS code maps/ - tables/ - Makefile.PL - 2 15 Feb 2014 mod_perl 2.0 Source Code Explained 1.4.1 xs/Apache2, xs/APR and xs/ModPerl modperl_xs_sv_convert.h - modperl_xs_typedefs.h - modperl_xs_util.h - typemap - 1.4.1 xs/Apache2, xs/APR and xs/ModPerl The xs/Apache2, xs/APR and xs/ModPerl directories include .h files which have C and XS code in them.
    [Show full text]
  • Red Hat Enterprise Linux 8 Installing, Managing, and Removing User-Space Components
    Red Hat Enterprise Linux 8 Installing, managing, and removing user-space components An introduction to AppStream and BaseOS in Red Hat Enterprise Linux 8 Last Updated: 2021-06-25 Red Hat Enterprise Linux 8 Installing, managing, and removing user-space components An introduction to AppStream and BaseOS in Red Hat Enterprise Linux 8 Legal Notice Copyright © 2021 Red Hat, Inc. The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/ . In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version. Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law. Red Hat, Red Hat Enterprise Linux, the Shadowman logo, the Red Hat logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries. Linux ® is the registered trademark of Linus Torvalds in the United States and other countries. Java ® is a registered trademark of Oracle and/or its affiliates. XFS ® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries. MySQL ® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
    [Show full text]
  • Typedef in C
    CC -- TTYYPPEEDDEEFF http://www.tutorialspoint.com/cprogramming/c_typedef.htm Copyright © tutorialspoint.com The C programming language provides a keyword called typedef, which you can use to give a type a new name. Following is an example to define a term BYTE for one-byte numbers: typedef unsigned char BYTE; After this type definitions, the identifier BYTE can be used as an abbreviation for the type unsigned char, for example:. BYTE b1, b2; By convention, uppercase letters are used for these definitions to remind the user that the type name is really a symbolic abbreviation, but you can use lowercase, as follows: typedef unsigned char byte; You can use typedef to give a name to user defined data type as well. For example you can use typedef with structure to define a new data type and then use that data type to define structure variables directly as follows: #include <stdio.h> #include <string.h> typedef struct Books { char title[50]; char author[50]; char subject[100]; int book_id; } Book; int main( ) { Book book; strcpy( book.title, "C Programming"); strcpy( book.author, "Nuha Ali"); strcpy( book.subject, "C Programming Tutorial"); book.book_id = 6495407; printf( "Book title : %s\n", book.title); printf( "Book author : %s\n", book.author); printf( "Book subject : %s\n", book.subject); printf( "Book book_id : %d\n", book.book_id); return 0; } When the above code is compiled and executed, it produces the following result: Book title : C Programming Book author : Nuha Ali Book subject : C Programming Tutorial Book book_id : 6495407 typedef vs #define The #define is a C-directive which is also used to define the aliases for various data types similar to typedef but with following differences: The typedef is limited to giving symbolic names to types only where as #define can be used to define alias for values as well, like you can define 1 as ONE etc.
    [Show full text]
  • [PDF] Beginning Raku
    Beginning Raku Arne Sommer Version 1.00, 22.12.2019 Table of Contents Introduction. 1 The Little Print . 1 Reading Tips . 2 Content . 3 1. About Raku. 5 1.1. Rakudo. 5 1.2. Running Raku in the browser . 6 1.3. REPL. 6 1.4. One Liners . 8 1.5. Running Programs . 9 1.6. Error messages . 9 1.7. use v6. 10 1.8. Documentation . 10 1.9. More Information. 13 1.10. Speed . 13 2. Variables, Operators, Values and Procedures. 15 2.1. Output with say and print . 15 2.2. Variables . 15 2.3. Comments. 17 2.4. Non-destructive operators . 18 2.5. Numerical Operators . 19 2.6. Operator Precedence . 20 2.7. Values . 22 2.8. Variable Names . 24 2.9. constant. 26 2.10. Sigilless variables . 26 2.11. True and False. 27 2.12. // . 29 3. The Type System. 31 3.1. Strong Typing . 31 3.2. ^mro (Method Resolution Order) . 33 3.3. Everything is an Object . 34 3.4. Special Values . 36 3.5. :D (Defined Adverb) . 38 3.6. Type Conversion . 39 3.7. Comparison Operators . 42 4. Control Flow . 47 4.1. Blocks. 47 4.2. Ranges (A Short Introduction). 47 4.3. loop . 48 4.4. for . 49 4.5. Infinite Loops. 53 4.6. while . 53 4.7. until . 54 4.8. repeat while . 55 4.9. repeat until. 55 4.10. Loop Summary . 56 4.11. if . ..
    [Show full text]
  • Enum, Typedef, Structures and Unions CS 2022: Introduction to C
    Enum, Typedef, Structures and Unions CS 2022: Introduction to C Instructor: Hussam Abu-Libdeh Cornell University (based on slides by Saikat Guha) Fall 2009, Lecture 6 Enum, Typedef, Structures and Unions CS 2022, Fall 2009, Lecture 6 Numerical Types I int: machine-dependent I Standard integers I defined in stdint.h (#include <stdint.h>) I int8 t: 8-bits signed I int16 t: 16-bits signed I int32 t: 32-bits signed I int64 t: 64-bits signed I uint8 t, uint32 t, ...: unsigned I Floating point numbers I float: 32-bits I double: 64-bits Enum, Typedef, Structures and Unions CS 2022, Fall 2009, Lecture 6 Complex Types I Enumerations (user-defined weekday: sunday, monday, ...) I Structures (user-defined combinations of other types) I Unions (same data, multiple interpretations) I Function pointers I Arrays and Pointers of the above Enum, Typedef, Structures and Unions CS 2022, Fall 2009, Lecture 6 Enumerations enum days {mon, tue, wed, thu, fri, sat, sun}; // Same as: // #define mon 0 // #define tue 1 // ... // #define sun 6 enum days {mon=3, tue=8, wed, thu, fri, sat, sun}; // Same as: // #define mon 3 // #define tue 8 // ... // #define sun 13 Enum, Typedef, Structures and Unions CS 2022, Fall 2009, Lecture 6 Enumerations enum days day; // Same as: int day; for(day = mon; day <= sun; day++) { if (day == sun) { printf("Sun\n"); } else { printf("day = %d\n", day); } } Enum, Typedef, Structures and Unions CS 2022, Fall 2009, Lecture 6 Enumerations I Basically integers I Can use in expressions like ints I Makes code easier to read I Cannot get string equiv.
    [Show full text]
  • Other Topics 1 Other Topics
    Other topics 1 Other topics 1 Other topics 15 Feb 2014 1 1.1 Description 1.1 Description Where to learn more about other topics that are useful for mod_perl developers and users. 1.2 Perl The Perl Documentation http://perldoc.perl.org/ The Perl Home Page http://www.perl.com/ The Perl Monks http://www.perlmonks.org/ What Perl Monks is: Our attempt to make learning Perl as nonintimidating and easy to use as possi- ble. A place for you and others to polish, improve, and showcase your Perl skills. A community which allows everyone to grow and learn from each other. The Perl Journal http://www.tpj.com/ The Perl Review http://theperlreview.com/ The Perl Review is a magazine for the Perl community by the Perl community produced with open source tools. CPAN - Comprehensive Perl Archive Network http://cpan.org and http://search.cpan.org/ Perl Module Mechanics http://world.std.com/~swmcd/steven/perl/module_mechanics.html - This page describes the mechan- ics of creating, compiling, releasing and maintaining Perl modules. Creating (and Maintaining) Perl Modules http://www.mathforum.com/~ken/perl_modules.html XS tutorials 2 15 Feb 2014 Other topics 1.3 Perl/CGI Perl manpages: perlguts, perlxs, and perlxstut manpages. Dean Roehrich’s XS CookBookA and CookBookB http://search.cpan.org/search?dist=CookBookA http://search.cpan.org/search?dist=CookBookB a series of articles by Steven McDougall: http://world.std.com/~swmcd/steven/perl/pm/xs/intro/index.html http://world.std.com/~swmcd/steven/perl/pm/xs/concepts.html http://world.std.com/~swmcd/steven/perl/pm/xs/tools/index.html http://world.std.com/~swmcd/steven/perl/pm/xs/modules/modules.html http://world.std.com/~swmcd/steven/perl/pm/xs/nw/NW.html Advanced Perl Programming By Sriram Srinivasan.
    [Show full text]
  • "This Book Was a Joy to Read. It Covered All Sorts of Techniques for Debugging, Including 'Defensive' Paradigms That Will Eliminate Bugs in the First Place
    Perl Debugged By Peter Scott, Ed Wright Publisher : Addison Wesley Pub Date : March 01, 2001 ISBN : 0-201-70054-9 Table of • Pages : 288 Contents "This book was a joy to read. It covered all sorts of techniques for debugging, including 'defensive' paradigms that will eliminate bugs in the first place. As coach of the USA Programming Team, I find the most difficult thing to teach is debugging. This is the first text I've even heard of that attacks the problem. It does a fine job. Please encourage these guys to write more." -Rob Kolstad Perl Debugged provides the expertise and solutions developers require for coding better, faster, and more reliably in Perl. Focusing on debugging, the most vexing aspect of programming in Perl, this example-rich reference and how-to guide minimizes development, troubleshooting, and maintenance time resulting in the creation of elegant and error-free Perl code. Designed for the novice to intermediate software developer, Perl Debugged will save the programmer time and frustration in debugging Perl programs. Based on the authors' extensive experience with the language, this book guides developers through the entire programming process, tackling the benefits, plights, and pitfalls of Perl programming. Beginning with a guided tour of the Perl documentation, the book progresses to debugging, testing, and performance issues, and also devotes a chapter to CGI programming in Perl. Throughout the book, the authors espouse defensible paradigms for improving the accuracy and performance of Perl code. In addition, Perl Debugged includes Scott and Wright's "Perls of Wisdom" which summarize key ideas from each of the chapters, and an appendix containing a comprehensive listing of Perl debugger commands.
    [Show full text]
  • EN-Google Hacks.Pdf
    Table of Contents Credits Foreword Preface Chapter 1. Searching Google 1. Setting Preferences 2. Language Tools 3. Anatomy of a Search Result 4. Specialized Vocabularies: Slang and Terminology 5. Getting Around the 10 Word Limit 6. Word Order Matters 7. Repetition Matters 8. Mixing Syntaxes 9. Hacking Google URLs 10. Hacking Google Search Forms 11. Date-Range Searching 12. Understanding and Using Julian Dates 13. Using Full-Word Wildcards 14. inurl: Versus site: 15. Checking Spelling 16. Consulting the Dictionary 17. Consulting the Phonebook 18. Tracking Stocks 19. Google Interface for Translators 20. Searching Article Archives 21. Finding Directories of Information 22. Finding Technical Definitions 23. Finding Weblog Commentary 24. The Google Toolbar 25. The Mozilla Google Toolbar 26. The Quick Search Toolbar 27. GAPIS 28. Googling with Bookmarklets Chapter 2. Google Special Services and Collections 29. Google Directory 30. Google Groups 31. Google Images 32. Google News 33. Google Catalogs 34. Froogle 35. Google Labs Chapter 3. Third-Party Google Services 36. XooMLe: The Google API in Plain Old XML 37. Google by Email 38. Simplifying Google Groups URLs 39. What Does Google Think Of... 40. GooglePeople Chapter 4. Non-API Google Applications 41. Don't Try This at Home 42. Building a Custom Date-Range Search Form 43. Building Google Directory URLs 44. Scraping Google Results 45. Scraping Google AdWords 46. Scraping Google Groups 47. Scraping Google News 48. Scraping Google Catalogs 49. Scraping the Google Phonebook Chapter 5. Introducing the Google Web API 50. Programming the Google Web API with Perl 51. Looping Around the 10-Result Limit 52.
    [Show full text]
  • A Style Guide
    How to Program Racket: a Style Guide Version 6.11 Matthias Felleisen, Matthew Flatt, Robby Findler, Jay McCarthy October 30, 2017 Since 1995 the number of “repository contributors” has grown from a small handful to three dozen and more. This growth implies a lot of learning and the introduction of inconsistencies of programming styles. This document is an attempt leverage the former and to start reducing the latter. Doing so will help us, the developers, and our users, who use the open source code in our repository as an implicit guide to Racket programming. To help manage the growth our code and showcase good Racket style, we need guidelines that shape the contributions to the code base. These guidelines should achieve some level of consistency across the different portions of the code base so that everyone who opens files can easily find their way around. This document spells out the guidelines. They cover a range of topics, from basic work (commit) habits to small syntactic ideas like indentation and naming. Many pieces of the code base don’t live up to the guidelines yet. Here is how we get started. When you start a new file, stick to the guidelines. If you need to edit a file, you will need to spend some time understanding its workings. If doing so takes quite a while due to inconsistencies with the guidelines, please take the time to fix (portions of) the file. After all, if the inconsistencies throw you off for that much time, others are likely to have the same problems.
    [Show full text]
  • Name Description
    Perl version 5.10.0 documentation - perlnewmod NAME perlnewmod - preparing a new module for distribution DESCRIPTION This document gives you some suggestions about how to go about writingPerl modules, preparing them for distribution, and making them availablevia CPAN. One of the things that makes Perl really powerful is the fact that Perlhackers tend to want to share the solutions to problems they've faced,so you and I don't have to battle with the same problem again. The main way they do this is by abstracting the solution into a Perlmodule. If you don't know what one of these is, the rest of thisdocument isn't going to be much use to you. You're also missing out onan awful lot of useful code; consider having a look at perlmod, perlmodlib and perlmodinstall before coming back here. When you've found that there isn't a module available for what you'retrying to do, and you've had to write the code yourself, considerpackaging up the solution into a module and uploading it to CPAN so thatothers can benefit. Warning We're going to primarily concentrate on Perl-only modules here, ratherthan XS modules. XS modules serve a rather different purpose, andyou should consider different things before distributing them - thepopularity of the library you are gluing, the portability to otheroperating systems, and so on. However, the notes on preparing the Perlside of the module and packaging and distributing it will apply equallywell to an XS module as a pure-Perl one. What should I make into a module? You should make a module out of any code that you think is going to beuseful to others.
    [Show full text]