Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

(jeffa) Re: Pronounceable syntax or beloved punctuation?

by jeffa (Bishop)
on May 17, 2002 at 15:07 UTC ( #167323=note: print w/replies, xml ) Need Help??


in reply to Pronounceable syntax or beloved punctuation?

  1. <*.txt> vs. glob '*.txt':
    Depends. A neat trick i lifted from merlyn is to use File::Find to find your target files and push them to @ARGV via:
    push @ARGV, $File::Find::name if /MAGIC_CONDITION/;
    then you can modify their contents via the empty angle brackets: <>. I don't think you can do that with glob ...
  2. readline over angle brackets:
    I tend to use angle brackets - guilty of lazy typing. ;)
  3. backticks
    I try to avoid them anytime i can. When i first started using Perl i used them a lot. Too much. Then i found system and exec, and IO::Pipe among other CPAN modules that can replace backticks.
All in all, i think a good exercise is to force yourself to practice The Other Way. Not necessarily in your production code, but in the throw-away scripts that you write from time to time. Balance is good. :)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re: (jeffa) Re: Pronounceable syntax or beloved punctuation?
by Juerd (Abbot) on May 17, 2002 at 17:20 UTC

    you can modify their contents via the empty angle brackets: <>. I don't think you can do that with glob ...

    Well, this is the one case where I prefer angle brackets (in this special case often refered to as "the diamond operator") over the readline function.

    You were right about this not being able with glob, as empty angle bracket expressions are handled by readline :) <> eq <ARGV> eq readline *ARGV (but only if the three lines (records) are stringologically equal).

    - Yes, I reinvent wheels.
    - Spam: Visit eurotraQ.
    

      Actually, you don't need * in readline *ARGV, readline ARGV is enough.

        Actually, you don't need * in readline *ARGV, readline ARGV is enough.

        strict allows unquoted strings where filehandles are expected. readline creates such context. readline ARGV equals readline 'ARGV'. Like it or not, you're using a symbolic reference!

        So while you are right that the * isn't needed, I strongly advise against using readline with a bareword.

        Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://167323]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2018-08-16 07:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Asked to put a square peg in a round hole, I would:









    Results (167 votes). Check out past polls.

    Notices?