Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Perl oddities

by bluto (Curate)
on Mar 01, 2005 at 16:46 UTC ( #435518=note: print w/ replies, xml ) Need Help??


in reply to Perl oddities

print FH @list

Normally this doesn't bother me unless I have to use parens (due to a parsing or emacs alignment issue)...

print(FH <list>);

... looks even worse.

The other thing I think is odd is how split() removes null fields at the end of a line if you don't give a LIMIT argument. Normally when I process a delimited file I expect each line to have the same number of fields, though some may be empty. For short scripts I tend to write quick sanity checks like this...

my @values = split /:/, $line; die "invalid line: '$line'" unless @values == 7;

It looks nice, but I have to remember to go back and set LIMIT to a negative (or large) number.


Comment on Re: Perl oddities
Select or Download Code
Re^2: Perl oddities
by Mugatu (Monk) on Mar 01, 2005 at 17:15 UTC
    Normally this doesn't bother me unless I have to use parens

    It's also kind of odd when your filehandle is not a simple scalar or bareword:

    open $hash{foo}, ">", "foobar"; print { $hash{foo} } "Test\n";

    Makes me shudder every time.

Re^2: Perl oddities
by ikegami (Pope) on Mar 01, 2005 at 20:53 UTC

    I do it this way:
    print FH ('test', 'ing', 1, 2, 3);

    Actually, I lied. I simply don't use barewords filehandles.

Re^2: Perl oddities
by TimToady (Parson) on Mar 01, 2005 at 21:08 UTC
    In Perl 6 it's probably one of
    print($fh: @list); $fh.print(@list);
    instead, or maybe you'll use pipes:
    @list ==> $fh.print; $fh.print <== @list;

    As for split, we haven't decided yet whether to change the default. I can argue it both ways.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2015-07-03 03:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (47 votes), past polls