> > Question: > > How to construct the regex so that it subtracts the same amount of white > > space from all the line. Namely, it should memorize the space from the first > > line only - and then subtract it from all the lines. > > > > I know how to do this with 2 regexes. But is there a way to do it in the > > same one substitute (similar to how it is done above)? > > > (my $sql = << '--') =~ s/\A(\s+)(?{$::c = $^N})|^(??{$::c})//gm; > select row_id > from gs_employee_queue g_q > where g_q.YYYYMMDDHHMM = '$YYYYMMDDhhmm' > and g_q.action = 'D' > and g_q.status = 'Unprocessed' > -- > > print $sql; > > __END__ > select row_id > from gs_employee_queue g_q > where g_q.YYYYMMDDHHMM = '$YYYYMMDDhhmm' > and g_q.action = 'D' > and g_q.status = 'Unprocessed' > > > Abigail
Bad Abigail! :) If I ever find: (my $sql = << '--') =~ s/\A(\s+)(?{$::c = $^N})|^(??{$::c})//gm; all over SQL related source code then your head is on the block! Yes, it can be done as you have shown. I'd prefer to see clock cycles needlessly wasted using a function call, like: use disclaimer; # No warranty, nor guarantee of fitness for purpose sub statement ($) { my $sql = shift; # clean sql return $sql; } print statement q< select row_id from gs_employee_queue g_q where g_q.YYYYMMDDHHMM = '$YYYYMMDDhhmm' and g_q.action = 'D' and g_q.status = 'Unprocessed' >; Although making a simple wrapper around the database interface would be my preferred option - implementation depending on whether the database interface is OO or non-OO. This wrapper would remove whitespace for the benefit of... well... the database getting a couple less whitespace characters. It's late, me not thinking much. Ignore me if I missed the point completely. Jonathan Paton ===== s''! v+v+v+v+ J r e P h+h+h+h+ !s`\x21`~`g,s`^ . | ~.*``mg,$v=q. P ! v-v-v-v- u l r e r h-h-h- !12.,@.=m`.`g;do{$.=$2.$1,$.=~s`h E ! v+v+v+ s k e h+h+ !`2`x,$.=~s`v`31`,print$.[$v+=$.] R ! v-v- t H a c h h- !}while/([hv])([+-])/g;print"\xA" L ! A n o t !';$..=$1while/([^!]*)$/mg;eval$. __________________________________________________ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com