How do you use warnings and diagnostics with a short example?

In Perl, using the `warnings` and `diagnostics` pragmas can help developers identify potential issues in their code. The `warnings` pragma issues warnings at runtime for problematic constructs, while `diagnostics` provides detailed explanations for those warnings, enabling easier debugging.

Here’s a short example:

#!/usr/bin/perl use strict; use warnings; use diagnostics; my $number = "123abc"; # This will generate a warning print $number + 1; # Attempting to add a string

keywords: Perl warnings diagnostics debugging code quality