Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: [off-site] Bash + Perl oneliners basics

by grinder (Bishop)
on Mar 17, 2005 at 08:22 UTC ( #440296=note: print w/replies, xml ) Need Help??


in reply to Re: [off-site] Bash + Perl oneliners basics
in thread [off-site] Bash + Perl oneliners basics

I know you're just tossing that code off quickly, but I'm curious to know why you chose to write:

while (<>) { my ($f) = (split)[6]; $count{$f}++; }

...rather than...

while (<>) { $count{(split)[6]}++; }

It makes me wonder if there's some robustness principle at work that eludes me. And of course, there is even...

$count{(split)[6]}++ while <>;

... but then we are getting into the realms of the cryptic, and I don't seen a more concise way of printing the top N values that doesn't sacrifice economy.

- another intruder with the mooring in the heart of the Perl

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://440296]
help
Chatterbox?
[marto]: good morning all, TCIF
[gnosti]: I'm reading from ffmpeg lengths of video clips in H:M:S and needing to add them and format them back to H:M:S for feeding back to ffmpeg
[marioroy]: kcott Thanks
[Corion]: gnosti: I would cheat and use my approach instead of dealing with durations as objects, or a module
[Corion]: You could even do the calculation directly - my $duration = $H * 3600+ $M*60 + $S; strftime '%H:%M:%S', timelocal($duratio n)
[Corion]: (and that strftime call is largely superfluous too, converting back to H:M:S isn't hard either)

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (9)
As of 2017-08-18 09:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Who is your favorite scientist and why?



























    Results (297 votes). Check out past polls.

    Notices?