Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Ordering of print statements

by Marshall (Canon)
on Jun 02, 2018 at 03:03 UTC ( [id://1215716]=note: print w/replies, xml ) Need Help??


in reply to Ordering of print statements

I would do as Paladin suggested, put values into a hash. To print, I would declare an array with the correct order that you want and then use that array in the main loop of a generalized print routine. Of course you might want to think about what happens if for some reason some desired key didn't wind up existing.
#!/usr/bin/perl use strict; use warnings; $|=1; # generated from the if regex statements instead of printing # right away my %values = ( 'Luma Mode' => 'D45_PRED', 'Chroma Mode' => 'UV_CFL_PRED', 'CFL' => 5, 'Luma Angle' => 3, 'Chroma Angle' => 0, ); my @order = ('Luma Mode', 'Luma Angle', 'Chroma Mode', 'CFL', 'Chroma Angle'); foreach my $key (@order) { print "$key:\t $values{$key}\n"; } __END__ Luma Mode: D45_PRED Luma Angle: 3 Chroma Mode: UV_CFL_PRED CFL: 5 Chroma Angle: 0
Oh, I suppose that this code:
if ($line =~ /\s*APP>\sIntraAngleDelta\s:\s(\d+)\s(\d+)/i) { print "Luma Angle : $1\n" } if ($line =~ /\s*APP>\sIntraAngleDelta\s:\s(\d+)\s(\d+)/i) { print "Chroma Angle : $2\n" }
Should be this??:
if ($line =~ /\s*APP>\sIntraAngleDelta\s:\s(\d+)\s(\d+)/i) { $values{'Luma Angle'} = $1; $values{'Chroma Angle'} = $2; }

Replies are listed 'Best First'.
Re^2: Ordering of print statements
by Eshan_k (Acolyte) on Jun 06, 2018 at 06:03 UTC
    Thank you Marshall for your suggestion.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-04-19 18:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found