{
  "id": "09",
  "content": [
    {
      "type": "heading",
      "text": "File I/O & Database Access with DBI"
    },
    {
      "type": "text",
      "html": "Read/write files carefully with proper permissions. For databases, use DBI with placeholders to avoid SQL injection."
    },
    {
      "type": "text",
      "html": "<pre><code>use DBI;\nmy $dbh = DBI->connect('DBI:mysql:database=app;host=localhost','user','pass',{ RaiseError=>1, AutoCommit=>1 });\nmy $sth = $dbh->prepare('SELECT * FROM users WHERE email = ?');\n$sth->execute($email);\nmy @rows = @{$sth->fetchall_arrayref({})};\n</code></pre>"
    }
  ],
  "quiz": {
    "questions": [
      {
        "id": "q1",
        "type": "single",
        "text": "Which Perl module provides a database-independent interface?",
        "options": [
          {
            "id": "a",
            "text": "DBI"
          },
          {
            "id": "b",
            "text": "PDO"
          },
          {
            "id": "c",
            "text": "Sequelize"
          }
        ],
        "correct": [
          "a"
        ]
      },
      {
        "id": "q2",
        "type": "single",
        "text": "Which DBI technique helps prevent SQL injection?",
        "options": [
          {
            "id": "a",
            "text": "Placeholders (prepared statements)"
          },
          {
            "id": "b",
            "text": "String concatenation"
          },
          {
            "id": "c",
            "text": "Building SQL with user input directly"
          }
        ],
        "correct": [
          "a"
        ]
      }
    ]
  }
}