Updated code
if ($remove) { $remove = lc($remove); my %remove_cmd = ( remove => "rmquedev -d $remove -q $remove" ); print "Are you sure you want to remove print queue \"$remove\" [Y/ +n]?"; $_ = <>; chomp($_); $_ = "Y" if ( length($_) == 0 ); if ( $_ =~ /[Yy]/ ) { # Wait for user-input system( $remove_cmd {'remove'} ); print "Prepairing to remove \"$remove\" from the CC_print.printers file.\n"; sleep 2; my $removeq = $remove; &cleanthefile($removeq); } else { die "You chose NOT to remove queue \"$remove\"\n"; } }

Sub-Process
sub cleanthefile { my $sourcefile = "/u/ccsys/CC_print.printers"; print $removeq; print "$sourcefile\n"; # Keep a dedicated backup of CC_print.printers if ( -t ne "/root/CC_print.printers.bkp" ) { system("touch /root/CC_print.printers.bkp"); sleep 2; system("cp -R $sourcefile /root/CC_print.printer.bkp"); } if ( -t eq "/root/CC_print.printers.bkp" ) { system("cp -R $sourcefile /root/CC_print.printer.bkp"); # grab the sourcefile and the string to remove as the first and second + arguments my ( $sourcefile, $removeq )= @_; my $tempfile = "/u/ccsys/CC_print.printers.bkp_mkpq"; # create a temporary file if (-e ne "$tempfile") { system("touch /u/ccsys/CC_print.printers.bkp_mkpq"); } # 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 "$tempfile") { #system ("cat $sourcefile \| grep -v $removeq $sourcefile > $t +empfile"); #`grep -v $removeq $sourcefile /dev/null /dev/null > $tempfile +`; sleep 1; print "Waiting to unlink..\n"; # delete source file, then rename working file unlink($sourcefile); rename( $tempfile, $sourcefile ); system("rm -rf $tempfile"); } } }

I placed a print statment for $removeq to me it seems as if $removeq is not being passed correctly. I'm rather new to Perl, I wouldn't doubt this is just product of my inexperience with programming in general. No matter how much I read I can't seem to find a solution to this issue!

In reply to Re^6: 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.