Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: A Macro System for Perl?

by cramdorgi (Acolyte)
on Mar 25, 2008 at 21:41 UTC ( #676248=note: print w/replies, xml ) Need Help??

in reply to A Macro System for Perl?

Is this the solution to my problem? I've been trying to write a Modulino, and wondered what to do if it calls exit...
Tried that:
#!/usr/bin/perl -w sub testrun() { my $r = run('noexit'); print "ret: $r\n"; } sub run { my $noexit = shift; my $retorexit = $noexit ? \&return : \&exit; &$retorexit(1); } testrun();
...but got
Undefined subroutine &main::return called at ./foo line 10.
retorexit could indeed be a macro...


Replies are listed 'Best First'.
Re^2: A Macro System for Perl?
by samtregar (Abbot) on Mar 25, 2008 at 21:47 UTC
      2 letter reply... Could it be that I was too terse?

      I meant obviously:

      macro retorexit() { if ($noexit) { return $_; } else { exit $_; } }

      As I see this as a good example of a useful macro, the only other way I can interpret your reply is that you know an obvious other way to do this elegantly.
      May I ask which?


        Oh sure, that could work. Except that this conversation happened 6 years ago! And went no where!


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://676248]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2017-06-25 00:48 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (563 votes). Check out past polls.