#!/usr/bin/perl -w use strict; my $line = q{ split( '/', $string ) }; $line =~ s/ //g; #compress spaces #now just "split('/',$string)" if ($line =~ m/^split/) # check for the split keyword { # get (parm1, parm2) of the split, ie the two # things separated by commas within the parens my ($parm1,$parm2) = ($line =~ m/\((.*?),(.*?)\)/)[0,1]; # now get stuff between quotes in parm 1 my $inside_quote = ($parm1 =~ m|'(.*?)'|)[0]; # change any / to \/ $inside_quote =~ s|/|\\/|g; #now just print back out print "preg_split('/$inside_quote/',$parm2)\n"; } __END__ Prints: preg_split('/\//',$string)