Is it possible to pass parameters to a script being run as a text filter?

I have a perl script that I use to adjust html code that has a number of 
instances like this:

"top: 753px; left: 27px;"
"top: 1928px; left: 776px;"

and add a specified amount to each "top" and "left" value by executing code 
in my replacement regex:

s/top: (\d+)px; left: (\d+)px;/top: @{[ $1+300 ]}px; left: @{[ $2+50 ]}px/g;

to end up with:

"top: 1053px; left: 77px;"
"top: 2228px; left: 826px;"

Currently the addition amounts are hard-coded in the script. Is there a way 
to pass them as variables when executing the text filter? I could do it by 
putting something at the start of the text I'm running the filter on and 
then parsing that at the beginning of my script, but I'd rather not do 
that. Wondering if it's possible to actually pass variables to a text 
filter script, similar to the way you can when running the script in the 
terminal:

perl myscript.pl 300 50

and then in my script I could have:

s/top: (\d+)px; left: (\d+)px;/top: @{[ $1+$ARGV[0] ]}px; left: @{[ 
$2+$ARGV[1] ]}px/g;

Thanks for any help/ideas,
-matt 

-- 
-- 
You received this message because you are subscribed to the 
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem, 
please email "[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>

--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to