hash in perl

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
#!/usr/bin/env ruby

require 'rubygems'
require 'fruit_processor'

#if __FILE__ == $0

!end excerpt

I never thought of the collision between the shebang line and C-style
preprocessing.  How would this look in perl?  The require's look like
C-style #includes.

Gerry Ford

"The apple was really a peach."
-- Allison Dunn on the garden of eden

Re: hash in perl

Quoted text here. Click to load it

There are three "include" functions in Perl: do, require, and use. See:

perldoc -f do
perldoc -f require
perldoc -f use

Jim Gibson

 Posted Via Usenet.com Premium Usenet Newsgroup Services

Re: hash in perl

Quoted text here. Click to load it

I'm not really familiar with Ruby, so I'm not entirely sure what this is
supposed to do; but I would have thought something like


    if (__FILE__ eq $0) {


would be equivalent. Of course, you don't get the (presumably)
compile-time effect of #if, so perhaps something like

    __FILE__ eq $0 and eval q{

is closer. Note that the usual idiom in Perl for 'am I the top-level
program rather than a used/required module' is

    unless (caller) { ... }

since caller returns undef if and only if this is the top-level program.


Site Timeline