Re: Is foo qw (arg1 arg2) equivalent to foo (arg1, arg2)?
On Nov 6, Dan Anderson said: > >> Dan> So: foo->bar qw(foo bar); is equivalent to foo->bar("foo","bar"); ? >> >> Only in recent Perls. > >Do you know exactly how recent? Are we talking 5 or better or 3 or >better? Without check perldeltas, I'd say 5.6. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ what does y/// stand for? why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Is foo qw (arg1 arg2) equivalent to foo (arg1, arg2)?
> Dan> So: foo->bar qw(foo bar); is equivalent to foo->bar("foo","bar"); ? > > Only in recent Perls. Do you know exactly how recent? Are we talking 5 or better or 3 or better? Thanks in advance, -Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Is foo qw (arg1 arg2) equivalent to foo (arg1, arg2)?
> "Dan" == Dan Anderson <[EMAIL PROTECTED]> writes: Dan> So: foo->bar qw(foo bar); is equivalent to foo->bar("foo","bar"); ? Only in recent Perls. The mapping of qw(...) to a (...) list at compile time is a modern addition. Older Perls replaced it with a runtime split on the string, and probably would not accept it as the arglist of a method call. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 <[EMAIL PROTECTED]> http://www.stonehenge.com/merlyn/> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Is foo qw (arg1 arg2) equivalent to foo (arg1, arg2)?
[sorry about that first post, I got ^X-happy] On Nov 5, Dan Anderson said: >use Data::Dump qw(dump); >foo->bar qw(foo bar); >Am I correct in assuming that if I have a subroutine foo (or method if >called with a package name), and I use qw() it takes all words seperated >by spaces, and passes them in as arguments. > >So: foo->bar qw(foo bar); is equivalent to foo->bar("foo","bar"); ? The qw() operator changes your source code at compile-time, which is why you can say $object->method qw(...) when ordinarily you'd need $object->method(...) When you use qw(this that those), Perl changes that to ('this', 'that', 'those') Perl splits the qw(...) on spaces, and returns the raw data, single-quoted. This means no variables. You can't even escape a space: qw( abc\ def ) becomes ('abc\\', 'def') That is all. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ what does y/// stand for? why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Is foo qw (arg1 arg2) equivalent to foo (arg1, arg2)?
On Nov 5, Dan Anderson said: >I've noticed that in code examples something like the following will be >used: > >use Data::Dump qw(dump); >foo->bar qw(foo bar); > >(Syntax may not be 100% correct). > >Am I correct in assuming that if I have a subroutine foo (or method if >called with a package name), and I use qw() it takes all words seperated >by spaces, and passes them in as arguments. > >So: foo->bar qw(foo bar); is equivalent to foo->bar("foo","bar"); ? > >Thanks in advance, > >Dan > > -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ what does y/// stand for? why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Is foo qw (arg1 arg2) equivalent to foo (arg1, arg2)?
Dan Anderson wrote: > I've noticed that in code examples something like the following will be > used: > > use Data::Dump qw(dump); > foo->bar qw(foo bar); > > (Syntax may not be 100% correct). > > Am I correct in assuming that if I have a subroutine foo (or method if > called with a package name), and I use qw() it takes all words seperated > by spaces, and passes them in as arguments. > > So: foo->bar qw(foo bar); is equivalent to foo->bar("foo","bar"); ? almost: foo->bar ('foo', 'bar') qq (foo bar) would render ("foo", "bar") It does make a difference. Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Is foo qw (arg1 arg2) equivalent to foo (arg1, arg2)?
I've noticed that in code examples something like the following will be used: use Data::Dump qw(dump); foo->bar qw(foo bar); (Syntax may not be 100% correct). Am I correct in assuming that if I have a subroutine foo (or method if called with a package name), and I use qw() it takes all words seperated by spaces, and passes them in as arguments. So: foo->bar qw(foo bar); is equivalent to foo->bar("foo","bar"); ? Thanks in advance, Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]