[ic] Delete a bunch of scratch variables
Rick Bragg
lists at gmnet.net
Mon Jun 20 20:49:49 UTC 2011
On Sun, 2011-06-19 at 14:16 -0400, Carl Bailey wrote:
> On Jun 19, 2011, at 1:55 PM, Rick Bragg wrote:
>
> > Hi,
> >
> > I have a pretty simple perl problem with deleting a set of scratch
> > variables.
> >
> > During a session, I am setting variables such as the following as the
> > user browses around
> >
> > [tmp item_sku]ItemA[/tmp]
> > [calc]$Scratch->{product_[scratch item_sku]_position} = '100'; return; [/calc]
> > [tmp item_sku]ItemD[/tmp]
> > [calc]$Scratch->{product_[scratch item_sku]_position} = '150'; return; [/calc]
> > [tmp item_sku]ItemF[/tmp]
> > [calc]$Scratch->{product_[scratch item_sku]_position} = '182'; return; [/calc]
> >
> > I need a way to simple delete all the "product_[scratch
> > item_sku]_position" variables at once, but I don't know what the
> > [scratch item_sku]'s are or how many of there there might be.Basically
> > something like a wild card such as:
> >
> > [calc]$Scratch->{product_*_position} = ''; return; [/calc]
> >
> > I think there is simple way to delete these. Can anyone give me a
> > simple solution to this?
> >
> > Thanks!
> > Rick
>
>
> Rick,
>
> How about something like this?
>
> [calc]
>
> foreach (keys $Scratch)
> {
> if (m/product_.*_position/) {
> delete $Scratch->{$_};
> }
> }
>
> '';
>
> [/calc]
>
> Carl
> . . . . . . . . . . . . . . . . . .
> Carl Bailey
> End Point Corp.
> t: 919-323-8025
> f: 212-929-6927
> . . . . . . . . . . . . . . . . . .
>
>
Thanks Carl and Peter! Works perfect. I'm using the grep method. I have
positionX, positionY, etc...
More information about the interchange-users
mailing list