Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Perl Beginners Cgi > Re: Redirect Pr...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 3 Topic 1401 of 1496
Post > Topic >>

Re: Redirect Print

by mritty@[EMAIL PROTECTED] (Paul Lalli) May 30, 2007 at 09:51 AM

On May 30, 11:56 am, Khalid.N...@[EMAIL PROTECTED]
 (Khalid Naji) wrote:
> is there any way to mask a printing, when I call a Function using the
> Command "print" and without to modify this Function:
>
> Like:
>
> My ($Name) = &get_name(12345);
>
> Sub get_name
> {
> $id = @[EMAIL PROTECTED]
> ...
> Print "Blalalalalalalbla...\n";
> Return (Name);
>
> }


You can open a filehandle to the system's /dev/null and then select
that filehandle to make it the default.  Make sure you reselect the
original filehandle when the subroutine is done.  For example:
$ perl -le'
print "Start";
open my $devnull, ">", "/dev/null" or die $!;
my $old_fh = select $devnull;
mysub();
select $old_fh;
print "End";
sub mysub {
   print "In mysub";
}
'
Output:
Start
End


Paul Lalli

P.S.  Please don't use a word processor to compose a post to a
technical list/newsgroup.  Or at the very least, turn off the word
processor's auto-capitalization feature.  You make it impossible for
anyone to copy and paste your code...
 




 3 Posts in Topic:
Redirect Print
Khalid.Naji@[EMAIL PROTEC  2007-05-30 17:56:44 
Re: Redirect Print
sdavis2@[EMAIL PROTECTED]  2007-05-30 12:30:14 
Re: Redirect Print
mritty@[EMAIL PROTECTED]   2007-05-30 09:51:31 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 10:14:55 CST 2008.