Hello fellow inmates I've got what is probably the dumbest question ever asked in these hallowed halls but I can't help it - it's began to annoy me so much I feel compelled to ask! (Even if I'm demoted to sewer cleaning!) The following code is just a wee test that I set up to try and have multiple actions after an 'or' statement. In a subroutine I would like to print an error message and then return 0 (False) on encountering a write error - foolish ignorant optimism I know but if you can't have your dreams................
#!/usr/bin/perl -w # sub fred { use strict ; # my $file = 'xxrcdisnaeexist' ; my $TV = 0 ; # open IP, $file or (print "\n\tNo kin d\n" , print "\n\tI bet ye dinna see this\n" , return 0 ) ; # if ($TV) { print "\n\tIt's Twoo It's Twoo\n" ; } # } $fred or die "\n\tThis failed min!!!\n" ;
On running this, I don't get all the expected output -
$ xxrcor.pl Name "main::IP" used only once: possible typo at xxrcor.pl line 9. This failed min!!! $
The multiple actions after the or don't appear to have worked - though clearly a 0 (False) HAS been returned as desired! Why have my print messages failed to appear? If this IS the dumbest question asked I apologise but I can't see why this is happening and It's becoming irritating!
Thanks,
Ronnie

In reply to 'or' Bug Bear by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.