dpmott has asked for the wisdom of the Perl Monks concerning the following question:
Since I'm using an eval "" instead of an eval {}, it's a run-time evaluation (and by that I mean that it's parsed at runtime, whereas eval {} has the opportunity to parse some/all of your eval {} statement at compile time).perl -e "print eval qq/require DBI; DBI::SQL_VARCHAR/ || $@;" >>> prints 'DBI::SQL_VARCHAR' perl -e "print eval qq/require DBI; DBI::SQL_XVARCHAR/ || $@;" >>> prints 'DBI::SQL_XVARCHAR' perl -e "print eval qq/require DBI; DBI::SQL_VARCHAR()/ || $@;" >>> prints '12' perl -e "print eval qq/require DBI; DBI::SQL_XVARCHAR()/ || $@;" >>> prints 'Can't locate auto/DBI/SQL_XVARCHA.al...' perl -e "$it=q/SQL_VARCHAR/; print eval qq/require DBI; DBI::$it/ || $ +@;" >>> prints 'DBI::SQL_VARCHAR' perl -e "$it=q/SQL_VARCHAR/; print eval qq/require DBI; DBI::$it()/ || + $@;" >>> prints '12' perl -e "$it=q/SQL_XVARCHAR/; print eval qq/require DBI; DBI::$it/ || +$@;" >>> prints 'DBI::SQL_XVARCHAR' perl -e "$it=q/SQL_XVARCHAR/; print eval qq/require DBI; DBI::$it()/ | +| $@;" >>> prints 'Can't locate auto/DBI/SQL_XVARCHA.al...'
Am I off-base here? Is that the way it works, or is something else going on here?eval "DBI::SQL_VARCHAR"; # is the same as $it='DBI::SQL_VARCHAR'; eval { $it };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: runtime eval() and constants
by Abigail-II (Bishop) on Dec 08, 2003 at 16:40 UTC | |
by dpmott (Scribe) on Dec 08, 2003 at 18:31 UTC | |
|
Re: runtime eval() and constants (order)
by tye (Sage) on Dec 08, 2003 at 16:38 UTC | |
|
Re: runtime eval() and constants
by holo (Monk) on Dec 08, 2003 at 16:36 UTC | |
by Abigail-II (Bishop) on Dec 08, 2003 at 16:46 UTC | |
by ysth (Canon) on Dec 08, 2003 at 17:48 UTC |