Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Effective way in perl

by QM (Vicar)
on Jul 16, 2009 at 16:03 UTC ( #780762=note: print w/ replies, xml ) Need Help??


in reply to Effective way in perl

Unix tee has always done the job for me. Do you need to append?

Update: added link.

-QM
--
Quantum Mechanics: The dreams stuff is made of


Comment on Re: Effective way in perl
Re^2: Effective way in perl
by RajNaidu (Novice) on Jul 16, 2009 at 18:19 UTC
    I basically need to reduce my two-liner code to single line coz I will be handling similar situations in my remaining code. If I have repetation lines doing the same job , my code length will be too huge. How do I use unix tee in perl script, please advise
      You have:
      `$swlist -l depot @ $depot_locn | $grep $rel_string | $grep $i | $grep + AR >> blah`

      which isn't pure perl code anyway, is it? (It's convenient to call grep 3 times, but might be more efficient to do with Perl's own grep.) Here, you're using perl just like you would use sh.

      But to address your question, try:

      `$swlist -l depot @ $depot_locn | $grep $rel_string | $grep $i | $grep + AR | tee file1 | tee file2 | tee file3 >> tee file4`
      But if you need append, I don't think tee can do that.

      Also take a look at Regexp Quote Like Operators and What's wrong with using backticks in a void context?

      -QM
      --
      Quantum Mechanics: The dreams stuff is made of

        Well, my tee(1)'s (FreeBSD 6 & CentOS 5) have -a, same as --append, option.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://780762]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2014-12-25 15:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (160 votes), past polls