I am trying to convert the `map` and `grep` code totally to `foreach` loop, but I am facing trouble when I do it.

Here is the array code to get the events

```
my @events = [
  {
    Sponsor => ’Saash’,
    Time => ’05:00’,
    Date => ’01-03-2021’,
  },
  {
    Sponsor => ’Saash Tech’,
    Time => ’03:00’,
    Date => ’01-03-2021’,
  },
  {
    Sponsor => ’Saash Technology’,
    Time => ’04:00’,
    Date => ’01-03-2021’,
  },
  {
    Sponsor => ’Saash Techs’,
    Time => ’05:00’,
    Date => ’01-03-2021’,
  },
];

my $time = ’05:00’;

```

Here is the code used in grep and map:

```
my $data = [
    map
    {
        my $hide;
        if ($_->{'sponsor'}) {
            $_->{'sponsor'} =~ ‘SaAsh’;
            $_->{‘sponsor'} = ‘Saash’ if $_->{’sponsor’} eq 'Saash Techs';
            if ($_->{‘time'} eq ’04:00’ && $_->{‘sponsor'} eq ‘SaAsh’) ) {
                $hide = 1;
            }
        }
        $hide ? () : ( $_ );
    }
    grep { $_->{‘time} =~ $time } @{events}
];

```

Below is the code where I have converted from grep map to `foreach`

```
my $data;
foreach my $event (@events) {
    if ($event->{‘time’} =~ ’07:00’) {
        my $hide;
        if ($event->{‘sponsor’}) {
            $event->{‘sponsor'} =~ ‘SaAsh’;
            $event->{'sponsor'} = ‘Saash’ if $event->{’sponsor’} eq ‘Saash Techs';
            if ($event->{'time'} eq '04:00' && $event->{'sponsor'} eq ‘SaAsh’) ) {
                $hide = 1;
            }
        }
        $hide ? () : ( $event );
    }
}
$data = [$event];

```

I am not getting the same output in foreach code when compared to the code of grep and map.

Can someone help where am I going wrong ?