Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Style, style, style

by Juerd (Abbot)
on Sep 08, 2002 at 01:59 UTC ( [id://195957]=perlmeditation: print w/replies, xml ) Need Help??

Which and why?

while (<>) { ... } or while (my $line = <>) { ... }?

-w or use warnings;?

sub CONSTANT () { ... } or use constant CONSTANT => ...;?

my ($foo, $bar) = @_; or my $foo = shift; my $bar = shift;?

for (@array) { ... } or foreach (@array) { ... }?

print 'foo'; or print('foo');?

'simple string' or "simple string"?

glob '*' or <*>?

readline *FOO or <FOO>?

for (keys %foo) { $_ and $foo{$_} } or while (my ($key, $value) = each %foo) { $key and $value }?

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

Replies are listed 'Best First'.
(jeffa) Re: Style, style, style
by jeffa (Bishop) on Sep 08, 2002 at 03:16 UTC
    1. while (<>) { ... } or while (my $line = <>) { ... }
        The former, unless the code is complex enough warrant explicit readability.
    2. -w or use warnings;
        The former, although i am slowly gravitating to the latter.
    3. sub CONSTANT () { ... } or use constant CONSTANT => ...;
        The latter, it just looks nicer to me.
    4. my ($foo, $bar) = @_; or my $foo = shift; my $bar = shift;
        The former.
    5. for (@array) { ... } or foreach (@array) { ... }
        The former, since they are really the same (barring readability issues), why type more?
    6. print 'foo'; or print('foo');
        The former, unless the print becomes complex enough that parens are necessary, which is not that often for me.
    7. 'simple string'; or "simple string"
        The former, i try to only use double quotes when i need something interpolated.
    8. glob '*' or <*>
        The former, until it bites me and i resort the latter. :D
    9. readline *FOO or <FOO>
        The former, until it bites me and i resort the latter ;)
    10. for (keys %foo) { $_ and $foo{$_} } or while (my ($key, $value) = each %foo) { $key and $value }?
        Depends. If the value is more than a simple scalar or i find my self using the values a lot then i will strongly consider the latter.

    Here is one i have been contemplating lately: print "$foo\n"; or print $foo,$/; :)

    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)
    

        7. 'simple string'; or "simple string" The former, i try to only use double quotes when i need something interpolated.

      Agreed. Why risk a careless update to the string that contains a $ or @ and the associated problems when you intended to print out the literal string?

Re: Style, style, style
by dws (Chancellor) on Sep 08, 2002 at 02:19 UTC
    1. while (<>) { ... } or while (my $line = <>) { ... }? I use both, depending on whim and my assemement of readability. 2. -w or use warnings;? -w, but only because of muscle memory. 3. sub CONSTANT () { ... } or use constant CONSTANT => ...;? use constant CONSTANT => ...; 4. my ($foo, $bar) = @_; or my $foo = shift; my $bar = shift;? I always shift $self. Whether or not to shift the other args or use array assignment kind of depends. Whim again, I'm afraid. 5. for (@array) { ... } or foreach (@array) { ... }? foreach. My undergrad degree was in Math. 6. print 'foo'; or print('foo');? No parens unless needed for precedence. 7. 'simple string'; or "simple string"? Double quotes. 8. glob '*' or <*>? opendir(); readdir(); closedir(); 9. readline *FOO or <FOO>? <FOO> 10. for (keys %foo) { $_ and $foo{$_} } or while (my ($key, $value) = each %foo) { $key and $value }? Depends on whether or not %foo is tied to a DBM. I use the 'each' form on DBMs, having been burned once by pulling all keys into memory on a big DBM.

      4. my ($foo, $bar) = @_; or my $foo = shift; my $bar = shift;?

      What about my ($foo, $bar) = (shift, shift);?
        What about my ($foo, $bar) = (shift, shift);?
        Yuck.

        maybe in Obfuscation, not in production code.

        - cybear

Re: Style, style, style
by dreadpiratepeter (Priest) on Sep 08, 2002 at 02:31 UTC
    Here goes:

    while (<>) { ... } or while (my $line = <>) { ... }?
    In general, in any non trivial situation, I use the latter because is is safer and makes for self-documenting code (assuming that you use an appropriate variable).

    sub CONSTANT () { ... } or use constant CONSTANT => ...;?
    Once again the later, to promote self-documenting code.

    my ($foo, $bar) = @_; or my $foo = shift; my $bar = shift;
    I find the former infinately more readable. It collects the parameters in one place, and looks like a traditional argument list.

    for (@array) { ... } or foreach (@array) { ... }
    I consistantly use for for (;;) loops and foreach for () loops. Self-documenting again.

    'simple string'; or "simple string"
    The former. Why make extra work for the compiler.


    As you can see, I really try to write self-documenting code. I hate writing comments, which is my biggest flaw as a coder, but I try to mitigate it through clear code. I use good variable and procedure names, consistant formatting (yay emacs!), and clear structure. These go thing as far as copious comments in making your code more maintainable.
    Ans I know that they don't replace good commenting, but I am getting better at that, really...

    -pete
    "Pain heals. Chicks dig scars. Glory lasts forever."
      Dear Dread,

      I totally agree... except...
      for (@array) { ... } or foreach (@array) { ... }
      I consistantly use for for (;;) loops and foreach for () loops. Self-documenting again.

      What??

      - cybear

Re: Style, style, style
by sauoq (Abbot) on Sep 08, 2002 at 04:17 UTC
    while (<>) { ... } or while (my $line = <>) { ... }?

    It depends... in general, the former for short scripts the latter for larger projects.

    -w or use warnings;?

    It depends... usually -w because I've got to make things work on 5.005 (and .004 for that matter) much of the time. Again, if it is a larger project and I can control the version of perl, I prefer use warnings especially since they'll provide better granularity if needed.

    sub CONSTANT () { ... } or use constant CONSTANT => ...;?

    use constant CONSTANT => ...;but I confess to secretly wishing that we all still had to use references to literals... ;-)

    my ($foo, $bar) = @_; or my $foo = shift; my $bar = shift;?

    It depends... I use the list assignment by default but there are exceptions. I usually shift $self as dws does. Sometimes I don't need all the args, in which case I may shift only when I need the next one. Rarely, but on occasion, I even find a reason to use $_[0] and friends directly.

    for (@array) { ... } or foreach (@array) { ... }?

    I use for consistently. Whatever is inside the parens can speak for itself. I used to use foreach but I've had one time too often when I've changed (;;) to (@a) and forgot to change the keyword. I've done the reverse too and its kind of embarrassing when someone finds a foreach(;;) in your code. Sure it works but there's no real excuse for it. I found it was easier to just use for all of the time.

    print 'foo'; or print('foo');??

    No parens unless necessary. print( ($a + $b) * $c, "\n" ); is a case where it might be necessary. I use parens with printf() though.

    'simple string'; or "simple string"?

    Single quotes unless it's in a print in which case I usually use doubles because, when I don't, I always end up needing to change them. If I need double quotes elsewhere, I tend to prefer qq().

    glob '*' or <*>?

    Neither recently. I have used <*> but I'd rather not remember those days. I'm with dws on this one too. opendir() et al is "The Right Way™".

    readline *FOO or <FOO>?

    It depends... Ha! Just kidding. I always use: <FOO> ... Perl should look like Perl.

    for (keys %foo) { $_ and $foo{$_} } or while (my ($key, $value) = each %foo) { $key and $value }?

    It depends... I don't use each very often but there have been and will be exceptions.

    -sauoq
    "My two cents aren't worth a dime.";
    
Re: Style, style, style
by Aristotle (Chancellor) on Sep 08, 2002 at 05:10 UTC
    1. while (<>) { ... } or while (my $line = <>) { ... }
      I keep my loops as short as I can, so the former. I usually feel the need for the latter if I already use $_ elsewhere but that's often a sign that I need to simplify.
    2. -w or use warnings;
      The former. I used the latter when it first became available but got bitten by having to run stuff with an older Perl..
    3. sub CONSTANT () { ... } or use constant CONSTANT => ...;
      The latter, no question. Self documenting.
    4. my ($foo, $bar) = @_; or my $foo = shift; my $bar = shift;
      I always shift $self. Occasionally I shift other stuff when I want to work with the rest of @_. Otherwise, which is 98% of th time, the former.
    5. for (@array) { ... } or foreach (@array) { ... }
      for. I only use for(;;) when I'd have to while(){} continue{}, which so far is never.
    6. print 'foo'; or print('foo');
      The former except for once in a blue moon when there are precendence issues.
    7. 'simple string'; or "simple string"
      The former, unless it's a oneliner where the shell gets the single quotes.
    8. glob '*' or <*>
      The former. Angle brackets are for reading a filehandle in my world.
    9. readline *FOO or <FOO>
      See above; the latter.
    10. for (keys %foo) { $_ and $foo{$_} } or while (my ($key, $value) = each %foo) { $key and $value }
      Always the latter when I don't need the elements in a certain order - for data munging I rarely do. The former tends to show up in I/O related code most of the time which plays along nicely with efficiency concerns, as I/O is usually constrained by external factors anyway.

    Makeshifts last the longest.

Re: Style, style, style
by Arien (Pilgrim) on Sep 08, 2002 at 05:51 UTC
    while (<>) { ... } or while (my $line = <>) { ... }?

    The implicit $_, unless spelling things out makes it clearer.

    -w or use warnings;?

    use warnings; whenever the Perl version lets me.

    sub CONSTANT () { ... } or use constant CONSTANT => ...;?

    The latter in general, to avoid confusion about intended use.

    my ($foo, $bar) = @_; or my $foo = shift; my $bar = shift;?

    Option 1, unless there a $self I'll shift of, I'm using default values, or there's a hash being passed by value.

    for (@array) { ... } or foreach (@array) { ... }?

    Both, depending on what I'm doing. It could even be .... for (@array);.

    print 'foo'; or print('foo');?

    No parens please, I'll put them in on the rare occasion I need them.

    'simple string'; or "simple string"?

    Interpolated unless I explicity don't want it.

    glob '*' or <*>?

    Depending on who will see the code. A lot of people don't know about <*>.

    readline *FOO or <FOO>?

    <FOO>.

    for (keys %foo) { $_ and $foo{$_} } or while (my ($key, $value) = each %foo) { $key and $value }?

    That would be door no. 1, please, unless %foo is tied to something like a database, to avoid getting Perl all cranky. :-)

    — Arien

Re: Style, style, style
by strat (Canon) on Sep 08, 2002 at 10:52 UTC
    I never use while (my $line = <FH>) because while (<FH>) is "shorthand" for: while (defined( $_=<FH>)), and the defined can sometimes be important if your last entry in a file is a 0 without \n afterwards. And normally, I don't want to miss a single zero at the end which could even happen with <> if you pipe in a file.
    I don't like <> without a filehandle in larger codes, I prefer doing it the long way round with open(FH, ... while (<FH>) or the like. But with short scripts (or throw-away-scripts) <> often seems ok.

    -w or use warnings: with perl5.0, I prefer -w, with perl >= 5.6 I use warnings because it is not global. But for production code, i remove -w or use warnings with a comment because I don't want an inocent user be confronted with strange "error messages" they don't understand.

    I prefer use constant CONSTANT => ...; because it makes clear that I want to use a constant and not a sub (although internally it all is about the same).

    my ($foo, $bar) = @_; or my $foo = shift; my $bar = shift;?
    I use both, but prefer the first solution, because then I've got an entry in a subroutine at the very beginning, which may keep the code a bit more readable. But if you don't know how many parameters are coming, I sometimes use shift in a loop (with commenting a lot why to do so).

    In bigger codes, I prefer using print as a function (print(...)), but I don't know why. One reason may be that with a good syntax highlighning editor, you can easier find matching parantheses...

    glob '*' or <*>: since I have to work a lot with perl5.005_03, I prefer using the module File::DosGlob. With perl >= 5.6, I prefer glob

    readline *FOO or <FOO>?: I always use <FOO>, because in my eyes, it is more idiomatic. But for a beginner, readline might be easier to understand in an existing code

    foreach vs. while each: It just depends on what I need. If I need some way of sorting, I have to use foreach. If not, then I nearly always use each, because with bigger datastructures, it might be faster, and $key and $value are imho better namens than $key and $foo{$key}.

    Best regards,
    perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32"

      while (<FH>) is "shorthand" for: while (defined( $_=<FH>)), and the defined can sometimes be important if your last entry in a file is a 0 without \n afterwards. And normally, I don't want to miss a single zero at the end which could even happen with <> if you pipe in a file.
      Good worry, but no need to lose sleep since Perl's behaviour has been adapted to do the right thing in the real world a while ago.
      $ perl -MO=Deparse -e'1 while my $line = <>;' '???' while defined(my $line = <ARGV>); -e syntax OK $ perl -v This is perl, v5.6.1 built for i386-linux
      I'm not sure exactly when it changed; perldoc perldelta for 5.6.1 doesn't mention it and I can't seem to find any mention in older versions of the POD found on perldoc.com either. Of course even on older Perls, you can use the my construct by simply adding the defined yourself..
      while(defined(my $line = <>)){ # ... }

      Makeshifts last the longest.

        A most obscure bug discusses the "implied defined" feature, its history, and a bug in its implementation that we caught.

        -Blake

Re: Style, style, style
by Juerd (Abbot) on Sep 08, 2002 at 12:15 UTC

    I completely forgot to post my own preferences :)

    while (<>) { ... } or while (my $line = <>) { ... }?

    Former, unless complicated.

    -w or use warnings;?

    Former. I avoid modules that are not -w-safe, and force myself to write -w-safe code.

    sub CONSTANT () { ... } or use constant CONSTANT => ...;?

    Former, for the same reason I like bless: knowing and using internals is good, syntactic sugar is bad if it doesn't reduce typing a lot.

    my ($foo, $bar) = @_; or my $foo = shift; my $bar = shift;?

    Former, unless @_ is used elsewhere in the sub. In my scripts, you can tell if @_ is going to be used just by looking at the first line: if it shifts, it will.

    for (@array) { ... } or foreach (@array) { ... }?

    Former. Always.

    print 'foo'; or print('foo');?

    Former, unless of course when parens are required. Parens clutter and should be avoided in simple statements.

    'simple string'; or "simple string"?

    Former. I don't mind changing them to doubles later.

    glob '*' or <*>?

    Former. Angelbrackets bite too often.

    readline *FOO or <FOO>?

    I alternate :) In theory, I prefer the former, but I see myself using the latter quite often.

    for (keys %foo) { $_ and $foo{$_} } or while (my ($key, $value) = each %foo) { $key and $value }?

    I prefer the former, but sometimes that is just not useable. I do tend to abuse the gigabyte of RAM modern machines have... :)

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

Re: Style, style, style
by BrowserUk (Patriarch) on Sep 08, 2002 at 03:04 UTC

    Mostly I dont know yet. Still making up my mind. This thread will be interesting to me.

    I seem to be favoring for over foreach and 'simple string' over "simple string", although in the latter case, I find myself having to modify '' to "" as simple strings become less simple as the program develops.

    Definately -w though because I have it set as a default for perl.exe through an assoc/ftype pairing, and must use no warnings to disable it on the rare occasion I need to.


    Well It's better than the Abottoire, but Yorkshire!
Re: Style, style, style
by Nemp (Pilgrim) on Sep 08, 2002 at 14:40 UTC
    Any opinions expressed herein are from someone with about a month's exposure to Perl working with it during what little free time I have. Saying that, here goes from my still "new to Perl" point of view... :)

    while (<>) { ... } or while (my $line = <>) { ... }?

    I generally use the former right now for ease of typing although I'm beginning to have some notions seeping into my head about lexical scoping of $_ which I think I need to learn more about!

    -w or use warnings;?

    I started with -w for my first few programs just because I'd read it on here, then I changed to use warnings; after some interesting discussions on here and due to the fact the Perl code I'm writing is always designed to be run on a version of Perl that supports it.

    sub CONSTANT () { ... } or use constant CONSTANT => ...;?

    This would have to be the latter as I didn't really know about the former until now :) Time to research the differences if any! (Hopefully there will be lots of wise words in this thread)

    my ($foo, $bar) = @_; or my $foo = shift; my $bar = shift;?

    Originally I'd have chosen the first option but since I've been trying to play around with packages and OO programming in Perl I've come to understand that shift isn't as scarey as it first looked so now I'd choose the latter.

    for (@array) { ... } or foreach (@array) { ... }?

    Easy one! The first because it has fewer keystrokes, I'm lazy, and right now I'm the only one who will ever see my Perl so there is nothing to be gained (AFAIK) in using the extra four letters. (Enlightenment is welcomed if there *is* a difference at all)

    print 'foo'; or print('foo');?

    Generally without the parentheses unless I have some scoping issue. Speaking of scoping issues that *really* hurt me the first time it happened but now I'm more wary!

    'simple string' or "simple string"?

    Always single quotes unless I know there is some variable in the string that I want interpolated, just seems safer that way to me right now.

    glob '*' or &lt;*&gt;?

    At the moment I'd pick glob '*' because my limited experience of glob is currently just from reading the Llama book so I like to be reminded that it's there and I still don't "get" what it does 100%

    readline *FOO or &lt;FOO&gt;?

    I'd choose the latter here simply because the former is a notation I hadn't seen much of before.

    for (keys %foo) { $_ and $foo{$_} } or while (my ($key, $value) = each %foo) { $key and $value }?

    Again I'd choose the former but there is still some tingling feeling running up my spine that I'm not entirely conversant with the scoping of $_ and what I can and can't do with it! :)

    Nice thread,
    Neil
Re: Style, style, style
by vek (Prior) on Sep 08, 2002 at 16:07 UTC
    1. while (<>) { ... } or while (my $line = <>) { ... }
    while (<>)

    2. -w or use warnings;
    -w for portability

    3. sub CONSTANT () { ... } or use constant CONSTANT => ...;
    use constant CONSTANT => ...

    4. my ($foo, $bar) = @_; or my $foo = shift; my $bar = shift;
    my ($foo, $bar) = @_;

    5. for (@array) { ... } or foreach (@array) { ... }
    for (@array) { ... }

    6. print 'foo'; or print('foo');
    print 'foo'

    7. 'simple string' or "simple string"
    "simple string"

    8. glob '*' or <*>
    Ha ha, like dws I prefer - opendir(), readdir(), closedir()

    9. readline *FOO or <FOO>
    <FOO>

    10. for (keys %foo) { $_ and $foo{$_} } or while (my ($key, $value) = each %foo) { $key and $value }
    for (keys %foo) { $_ and $foo{$_} }

    -- vek --
Re: Style, style, style
by Zaxo (Archbishop) on Sep 08, 2002 at 19:10 UTC

    Some of your questions compare inequivalent statements, mostly in regard of global variables.

    p>while (<>) { ... } or while (my $line = <>) { ... }?
    They do different things. I tend to take advantage of $_ and avoid named temporaries as much as I can, so I oftener code the former.

    -w or use warnings;?
    They do different things. $^W is global, warnings.pm is lexically scoped. The backward compatibility issue matters. Situational, for me.

    sub CONSTANT () { ... } or use constant CONSTANT => ...;?
    I use constant ... when I'm comfortable with the all-caps convention. For something whose name doesn't follow the convention, or that will be explicitly called like a sub, I define the sub.

    my ($foo, $bar) = @_; or my $foo = shift; my $bar = shift;?
    The two are very different. The former leaves @_ unaltered. I shift when I want to remove items so that @_ can be treated as an array of similar things, as often happens in OO Perl.

    for (@array) { ... } or foreach (@array) { ... }?
    I use for with the pronoun, foreach if named. Blind acceptance of the perldoc recommendations and examples.

    print 'foo'; or print('foo');?
    A list is a list. I prefer the former. I tend to use parens as little as I can. That way, when I see them I know I've defeated operator precedence.

    'simple string' or "simple string"?
    Single quotes. Why invoke interpolation for nothing?

    glob '*' or <*>?
    I've come to prefer glob. No tricky rules about how the argument is interpreted, no confusion with reading from an open handle. I do like the compactness of diamond notation.

    readline *FOO or <FOO>?
    See previous question, I prefer <FOO> for its compactness.

    for (keys %foo) { $_ and $foo{$_} } or while (my ($key, $value) = each %foo) { $key and $value }?
    Like the while question above, I like the pronoun when I can use it. The latter has the advantage when I need to protect $_, or $value is often used in the block.

    After Compline,
    Zaxo

      Some of your questions compare inequivalent statements, mostly in regard of global variables.

      I know. Style and equality have not much to do with eachother. While it is true that all of the pairs display two approaches to the same problem, "use strict; or no strict;?" could easily have been one of the questions.

      Take for example the list assignment vs shifts question. They are not equivalent. Of course they are not - I hope everyone reading this thread realises what the differences are. But it *is* a question of style when @_ is not used elsewhere.

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

Re: Style, style, style
by FoxtrotUniform (Prior) on Sep 08, 2002 at 20:48 UTC
    • while (<>) { ... } or while (my $line = <>) { ... }?

      Almost always the former. Occasionally the latter, if using $_ won't make the loop body any simpler and I'm not dealing with lines as text strings (for instance, while (my $addr = <>) for a file full of IP addresses), but that's a rare thing.

    • -w or use warnings;?

      -w. Most of my scripts target 5.005_03.

    • sub CONSTANT () { ... } or use constant CONSTANT => ...;?

      I don't usually enforce constness. I'm much more likely to say $main::CONSTANT = 'foo'; and just not touch any identifiers in all caps.

    • my ($foo, $bar) = @_; or my $foo = shift; my $bar = shift;?

      Always assign from @_. Less verbose, easier to change, and the list looks more like a formal parameter list to my C-trained eyes.

    • for (@array) { ... } or foreach (@array) { ... }?

      for. It's less than half the length of foreach. Huffman encoding, etc, etc.

    • print 'foo'; or print('foo');?

      Without brackets, unless that induces precedence lossage.

    • 'simple string' or "simple string"?

      I'm trying to avoid double-quoted strings unless there's actually some interpolation going on, but I've already formed the habit of double-quoting all strings. We'll see which one wins.

    • glob '*' or <*>?

      Explicit glob. Angle brackets read from filehandles.

    • readline *FOO or <FOO>?

      <FOO>. Again, angle brackets read from filehandles.

    • for (keys %foo) { $_ and $foo{$_} } or while (my ($key, $value) = each %foo) { $key and $value }?

      Usually for (keys %foo), but more out of habit than anything else.

    In general, I try for the tersest code that doesn't require a comment.

    --
    F o x t r o t U n i f o r m
    Found a typo in this node? /msg me
    The hell with paco, vote for Erudil!

Re: Style, style, style
by cLive ;-) (Prior) on Sep 08, 2002 at 15:32 UTC
    -w or use warnings;?

    Has my memory completely left me, or is -w ignored under NT, hence introduction if pragma?

    .02

    cLive ;-)

    --
    seek(JOB,$$LA,0);

      It is ignored when on the shebang since Win doesn't have the shebang notion. You have to put it in the .pl filetype association in the registry. CGI scripts run by Apache don't have such a problem since the daemon will emulate the shebang notion on Win variants.

      Makeshifts last the longest.

        I can't talk for all perl builds on Windows, but my Activestate 5.6.1 (build 633) + Win2k does translate -w on the shebang to use warnings. It doesn't do it via using the shebang afaik, but just by using some magic on it.

        //: C:\MyScript.pl #!/usr/bin/perl -w $x = "foo"; __END__ output: Name "main::x" used only once: possible typo at scratch.pl line 2 ///~ C:\> MyScript

        tlhf
        xxx

Re: Style, style, style
by rir (Vicar) on Sep 09, 2002 at 01:48 UTC
    I would use  while (<>) { ...} only because it has been
    hammered into me as the idiom.
    This is not an argument for the usage.

    No no warnings; because I use 5.005.

    use constant CONSTANT => "value"; is better for any code where
    the difference might matter. For simple & well contained
    code I have the bad habit of
     my $VAR = "value";     # XXX constant

    Definitely my ($foo, $bar) = @_; this is crystal clear
    and screen space is valuable. I do find that I don't use
    my ($foo, $bar, @valuable) = @_; though.

    Regarding for ( @array) versus foreach (@array) , I don't
    care much. I use foreach for this and use for for C-style loops.
    I'd nearly never use $_ here. I rarely use implicit $_
    except for the most common idioms. Though I'm usually
    using Perl I don't want to develop overly specialized finger
    habits.

    Always print 'foo'; I don't follow print statements with
    more code on the same line.

    Breaking the C habit of using qq quotes had some appeal.
    Then I coded a lot of print statements. qq usage is more
    flexible, save q for when you have to use it.

    glob '*' or <*>
    I would lean toward glob but I have not used either construct.

    Again <FOO> is the standard idiom.

    I find keys is the most natural way to go through a hash.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://195957]
Approved by dws
Front-paged by strat
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2024-04-19 14:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found