Call to sub-routine
my $removeq = $remove; my $sourcefile = "/u/ccsys/CC_print.printers"; my $tempfile = "/u/ccsys/CC_print.printers.bkp_mkpq"; &cleanthefile( $removeq, $sourcefile, $tempfile );

sub cleanthefile { my @filehandles; my ( $sourcefile, $removeq, $tempfile ) = @filehandles; # Keep a dedicated backup of CC_print.printers if (-e "/root/CC_print.printers.bkp" ) { `cp -R $filehandles[1] $filehandles[2]`; # create a temporary file if (-T ne "$filehandles[2]") { system("touch /u/ccsys/CC_print.printers.tmp"); } # extract lines from $sourcefile which do NOT have the string to + remove # note that the \' inserts ticks so that strings with spaces can + work, too if ( -T "$filehandles[2]") { # system ("cat $sourcefile \| grep -v $removeq $sourcefile > $ +tempfile"); `grep -v $filehandles[0] $filehandles[1] /dev/null /dev/null > + $filehandles[2]`; sleep 1; print "Waiting to unlink..\n"; # delete source file, then rename working file unlink($filehandles[1]); rename( $filehandles[2], $filehandles[1] ); system("rm -rf $filehandles[2]"); } } else { system("touch /u/ccsys/CC_print.printers.bkp"); system("cp -R $filehandles[1] /root/CC_print.printer.bkp"); print "Please re-run the program, had to create a backup\n"; } }
I think you've got me on the right path Kyle, I can actually print the array of elements "@filehandles". It comes out in a order queuename, sourcefile, tempfile. Thanks so much for the help!

In reply to Re^8: Program unsuspectingly dies with no reason why. by misconfiguration
in thread Program unsuspectingly dies with no reason why. -FIXED! by misconfiguration

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.