#perl - Thu 1 Mar 2007 between 03:53 and 04:00



Jmax-"Even though it looks like a regular function call, it isn't: you can't take a reference to it, such as the incorrect \&CORE::open might appear to produce."
psticknecan't you just no strict and &{"foo"}?
revdiabloIf you want to execute arbitrary code, use eval. If you want to set a variable to refer to a piece of code later, use coderefs.
Jmax-yes, &$foo should work, but i dunno if it works on open for example
guest1234apparently doesnt
psticknehmm
revdiabloIt doesn't work on builtins AFAIK
guest1234i tried $foo = 'readpipe';
$foo->(@arg);
doesnt work
psticknetrying random... wait ;)
revdiabloA lot of builtins use special-case call syntax anyway
pstickneyou could use the indirect notation I suppose...
guest1234which is..?
revdiabloguest1234: Not "standard" syntax
guest1234could you give an example of special-case call syntax please?
Jmax-eval: $foo = 'print'; &$foo('dong1', 'dong2');
buubotJmax-: Error: Undefined subroutine &main::print called at eval line 1.
revdiabloprint { $filehandles{foo} } "bar";
guest1234hmm
revdiablosort byvalue keys %hash;
That's a special case that bites people from time to time
The 'sort SUBNAME LIST' form
guest1234so referring built-in subs using a symbolic ref is not possible?
revdiabloThat is correct
guest1234hmm
revdiabloWhy do you keep asking repeatedly?
guest1234i just wanted to make sure if its possible or not
i thought if its not possible, ill stop banging my head
:/
sorry for the persistence
just wasnt sure what the general consensus was here
pstickneI don't think I'll ever completely understand Perl :(
siliif you told us what the problem, we might be able to give you a solution
revdiabloguest1234: No worries. Just remember that it's not really necessary either
siliit's not impossible to reach a builtin with its name in a string
guest1234its not?
revdiabloeval
siliwe already said: eval
simcop2387eval: $foo = \&CORE::print; {$foo}("Testing");

Page: 5 12 19 26 33 40 47 54 61 68 75 82 89 

IrcArchive