Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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

by shmem (Chancellor)
on Mar 29, 2017 at 19:31 UTC ( #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? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2022-01-20 00:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (56 votes). Check out past polls.

    Notices?