On Fri, Aug 03, 2007 at 11:24:23PM +0200, Marek Stepanek wrote:
> Hi Michael,
> 
> 
> a simple task. I write in my perl-script my $1 ... But I need this up to $4
> or more. I select my $1, and my filter makes out of it:
> 
> my ($1, $2, $3, $4);
> 
> But you are right: this are reserved scalars (blushing) ...
> 
> so I change my task to:
> 
> 
>     my $scalar1,
> 
> with filter becomes:
> 
>     my ($scalar1, $scalar2, $scalar3, $scalar4);
> 
> 
> 
> Was this clearer? 

I'm not sure why you're going about modifying your Perl script in this
way...  Do you have a lot of occurences to change?  Why can't you just do a
simple find/replace?  Won't you still need to write the code to use the
variables that you're declaring?  You could add the declarations at the
same time.

Anyway...

#!perl -p

s{my (\$scalar)(\d),}{
  'my (' . join(', ', map $1 . ($2 + $_), 0 .. 3) . ');'
 }ge;

__END__

replaces

my $scalar1,

with

my ($scalar1, $scalar2, $scalar3, $scalar4);

and similarly for any $scalarN.

Ronald

-- 
------------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <[EMAIL PROTECTED]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_script.shtml>
List archives: <http://www.listsearch.com/bbeditscripting.lasso>
To unsubscribe, send mail to:  <[EMAIL PROTECTED]>

Reply via email to