Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Determine new line number in revised file given old line number

by shmem (Chancellor)
on Mar 29, 2017 at 19:31 UTC ( [id://1186426]=note: print w/replies, xml ) Need Help??


in reply to Determine new line number in revised file given old line number

syntax error at 1186417.pl line 33, near "$1 :"

patch:

- $new_to_old[$_] += ( $4 ? $4 : $5 ) - $5 + $2 - ( $1 : $1 ? $2 ) + ( + $3 cmp 'c' ) + $new_to_old[$_] += ( $4 ? $4 : $5 ) - $5 + $2 - ( $1 ? $1 : $2 ) + ( + $3 cmp 'c' )
It seems a little convoluted.

For starters, to remove a bit convolutedness, I'd drop that ternary constructs and rewrite that line as

$new_to_old[$_] += ( $4 || $5 ) - $5 + $2 - ( $1 || $2 ) + ( $3 cmp 'c +' )
perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

Replies are listed 'Best First'.
Re^2: Determine new line number in revised file given old line number
by ExReg (Priest) on Mar 29, 2017 at 19:49 UTC

    Thanks for catching the typo. I love the improvement for the ternaries. I always thought it looked ugly.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2024-03-28 10:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found