> On Wed, 8 Sep 2004, jason corbett wrote: > > > As a newbie, I have seen the statement "foo(bar)" mentioned in books > > and and even on this site. I haven't yet seen what this actually mean > > as I can assume that its just for examples. If I am wrong please > > explain in detail what this is about. > > Is your question about the names, or the syntax & construction? > > The names "foo" and "bar" (and variants -- "baz", "bat", "foobar", etc) > are common stubs that are often used in throwaway code, for demos and > examples, for names to be filled in later, etc. > > Just as algebra problems often use "x" and "n" for arbitrary variables, > many Perl programmers use "foo" and "bar" for arbitrary variables. >
Not just Perl programmers: http://jargon.watson-net.com/jargon.asp?w=metasyntactic%20variable http://jargon.watson-net.com/jargon.asp?w=foo > As for the construct, `this( that )` is a subroutine / function call, > where the language defined function or the programmer defined sub (or > library module defined method) called "this" is being called with the > parameter / argument "that". Or, in your example, "foo" and "bar" > instead of "this" and "that". > > Generally, if you see the phrase "foo(bar)", exactly like that, in > documentation, then the writer is just making some kind of example, > perhaps about what typical subroutine calls look like. (Note though that > this example probably wouldn't actually work, because 'bar' here is a > bareword, rather than a quoted string or a variable, so Perl might > complain about passing it as an argument because it's not clear what > should be done with bar; if it should be treated as a string, it should > be wrapped in single- or double-quotes, and if it is a variable then it > needs a prefix ($ @ % &). ) > 'Sigil' rather than 'prefix'... (distinguishing the two will eventually become necessary it seems) > Make sense, or is something still unclear ? > > http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>