我有一个哈希数组,如下所示.
@students= (
    {
        'math' => 95,
        'phy'  => 90,
        'che'  => 85
    },
    {
        'math' => 50,
        'phy'  => 70,
        'che'  => 35
    }
);
我想基于某些条件删除整个哈希,因为我尝试使用下面的代码,但是收到错误说法delete argument is not a HASH or ARRAY element or slice.所以请帮帮我,我该怎么办?
for $i ( 0 .. $#students) {
    for $key ( keys %{ $students[$i] } ) {
        if ($key eq 'che') {
            if ($students->{$key} == 35){
                delete (%{$students[$i]});
            }
        }
    }
}
我已经在纤薄的框架中编写了 REST api。当我从浏览器调用身份验证 API 时,它通过“不允许的方法”。必须是以下之一: POST'。下面是我的代码,请纠正我哪里出错了。
索引.php
<?php
require 'vendor/autoload.php';
require 'Authenticate.php';
$app = new \Slim\App;
$app->post('/api/authenticate', \Authenticate::class);
$app->run();
.htaccess
RewriteEngine On
RewriteRule ^ index.php [QSA,L]
网址
http://localhost/project/api/authenticate
我有一个标量变量,$var其中包含10个字节.删除我使用的那10个字节
$var =~ s/^(.{$numberOfbytes})//;
如果少于10个字节,这可以正常工作.但是我希望一次删除超过4500个字节.我怎样才能做到这一点?