in reply to Code Blocks

I'll explain it by two examples:
You want:
open INF, "<$file" or print "\n\tmy message\n" ; "\n\tActual error :: $!\n" ; return 0 ;
You can do:
open INF, "<$file" or do{ print "\n\tmy message\n", "\n\tActual error :: $!\n" ; return 0 ; }
OR:
open INF, "<$file" or (print("\n\tmy message\n", "\n\tActual error : +: $!\n"), return 0)
It will do what you want, if i understood the idea of your dirty, ugly code correctly.

     s;;Just-me-not-h-Ni-m-P-Ni-lm-I-ar-O-Ni;;tr?IerONim-?HAcker ?d;print

Replies are listed 'Best First'.
Re^2: Code Blocks
by Ronnie (Scribe) on Jul 27, 2006 at 13:21 UTC
    Thanks for the help - "do" does the job I was looking for. My dirty ugly code was just knocked up to give a flavour of what I was trying to do - and I had missed a print verb before the "actual error" line - it's not real production code. The comma after the first print should be a semi-colon and there should be a semi-colon after the closing curly bracket, my missing a print verb before the Actual error string probably led to this omission and my confusion! Thanks for the help though I am wondering exactly, typo apart, what is dirty and ugly about it?
    Many thanks
    Ronnie
      typo apart, what is dirty and ugly about it
      IMHO:
      • The comment signs on empty lines are ugly
      • The spaces before semicolons are ugly
      • 2-column indent is ugly
      • Calling subs as &sub is ugly and often simply wrong
      And even,
      open ... or do { #blah blah blah };
      is more ugly than
      unless (open...) { #blah blah blah }
      Perl syntax is very flexible. It even allows to write the whole your program in one long line. But i recommend you to follow the more common coding standarts :) They are described, e.g. in perlstyle.

           s;;Just-me-not-h-Ni-m-P-Ni-lm-I-ar-O-Ni;;tr?IerONim-?HAcker ?d;print