# perldoc > access

---
type: CommandReference
command: substr
mode: perldoc
section: ""
source: perldoc
---

## Quick Reference

- `substr( $string, 0, 1 )` — get first character
- `substr( $string, 13, 4, "replacement" )` — replace substring
- `substr( $string, 13, 4 ) = "replacement"` — lvalue assignment

## Name

`substr` — access or change a substring of a string

## Synopsis

`substr EXPR, OFFSET, LENGTH, REPLACEMENT`

## Options

- `EXPR` — the string to operate on
- `OFFSET` — zero‑based start position
- `LENGTH` — number of characters to extract or replace
- `REPLACEMENT` — optional string to replace the substring (fourth argument)

## Examples

perl
my $string = "Just another Perl Hacker";
my $first_char = substr( $string, 0, 1 );  # 'J'

substr( $string, 13, 4, "Perl 5.8.0" );

substr( $string, 13, 4 ) = "Perl 5.8.0";
## See Also

[perlfunc/substr](https://perldoc.perl.org/functions/substr)

---
type: CommandReference
command: our
mode: perldoc
section: ""
source: perldoc
---

## Quick Reference

- `$Some_Pack::var` — access dynamic variable by explicit package
- `our $var` — bring dynamic variable into lexical scope
- `use warnings FATAL => qw(uninitialized)` — promote undefined variable warnings to errors

## Name

`our` — compiler directive that brings a dynamic (package) variable into the current lexical scope

## Synopsis

`our VAR`

## Options

None.

## Examples

### Access dynamic variable when lexical with same name exists

perl
use vars '$var';
local $var = "global";
my    $var = "lexical";

print "lexical is $var\n";
print "global  is $main::var\n";
### Use `our` to bring dynamic variable into scope

perl
require 5.006;
use vars '$var';

local $var = "global";
my $var    = "lexical";

print "lexical is $var\n";

{
    our $var;
    print "global  is $var\n";
}
### Catch accesses to undefined variables

perl
use warnings FATAL => qw(uninitialized);
## Notes

Undefined function and method calls can be captured via `AUTOLOAD` (see perlsub).

## See Also

[perlfunc/our](https://perldoc.perl.org/functions/our), [perlsub/Autoloading](https://perldoc.perl.org/perlsub#Autoloading), [perllexwarn](https://perldoc.perl.org/perllexwarn)