[ic] Delete a bunch of scratch variables
Carl Bailey
carl at endpoint.com
Sun Jun 19 18:16:27 UTC 2011
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
. . . . . . . . . . . . . . . . . .
More information about the interchange-users
mailing list