NAME
App::Greple::PwBlock - Password and ID information block parser for greple
SYNOPSIS
use App::Greple::PwBlock;
# Create a new PwBlock object
my $pb = App::Greple::PwBlock->new($text);
# Access parsed information
my $id = $pb->id('0'); # Get ID by label
my $pw = $pb->pw('a'); # Get password by label
my $cell = $pb->cell('A', 0); # Get matrix cell value
# Configuration
use App::Greple::PwBlock qw(config);
config('id_keys', 'LOGIN EMAIL USER ACCOUNT');
config('pw_blackout', 0);
DESCRIPTION
App::Greple::PwBlock is a specialized parser for extracting and managing password and ID information from text blocks. It provides intelligent pattern recognition for common credential formats and includes support for random number matrices used by banking systems.
The module uses Getopt::EX::Config for centralized parameter management, allowing configuration of parsing behavior, display colors, and keyword patterns.
METHODS
- new([text])
-
Creates a new PwBlock object. If text is provided, it will be parsed immediately.
my $pb = App::Greple::PwBlock->new($credential_text);
- parse(text)
-
Parses the given text to extract ID, password, and matrix information. This method is called automatically by new if text is provided.
$pb->parse($text);
- id(label)
-
Returns the ID value associated with the given label. Labels are assigned automatically during parsing (e.g., '0', '1', '2', ...).
my $username = $pb->id('0');
- pw(label)
-
Returns the password value associated with the given label. Labels are assigned automatically during parsing (e.g., 'a', 'b', 'c', ...).
my $password = $pb->pw('a');
- cell(column, row)
-
Returns the value from a matrix cell at the specified column and row. Useful for banking security matrices.
my $value = $pb->cell('E', 3); # Column E, Row 3
- any(label)
-
Returns any value (ID, password, or matrix cell) associated with the label. This is a convenient method that checks all types.
my $value = $pb->any('a');
- orig()
-
Returns the original unparsed text.
- masked()
-
Returns the text with passwords masked according to the pw_blackout setting.
- matrix()
-
Returns a hash reference containing the parsed matrix data.
CONFIGURATION
This module uses Getopt::EX::Config for parameter management. Configuration can be accessed using the config function:
use App::Greple::PwBlock qw(config);
Available Parameters
- parse_matrix (boolean, default: 1)
-
Enable or disable matrix parsing.
- parse_id (boolean, default: 1)
-
Enable or disable ID field parsing.
- parse_pw (boolean, default: 1)
-
Enable or disable password field parsing.
- id_keys (string, default: "ID ACCOUNT USER CODE NUMBER URL ユーザ アカウント コード 番号")
-
Space-separated list of keywords that identify ID fields.
- id_chars (string, default: "[\w\.\-\@]")
-
Regular expression character class for valid ID characters.
- id_color (string, default: "K/455")
-
Color specification for ID values in output.
- id_label_color (string, default: "S;C/555")
-
Color specification for ID labels in output.
- pw_keys (string, default: "PASS PIN パス 暗証")
-
Space-separated list of keywords that identify password fields.
- pw_chars (string, default: "\S")
-
Regular expression character class for valid password characters.
- pw_color (string, default: "K/545")
-
Color specification for password values in output.
- pw_label_color (string, default: "S;M/555")
-
Color specification for password labels in output.
- pw_blackout (boolean, default: 1)
-
When enabled, passwords are masked in the output for security.
Configuration Examples
# Customize ID keywords
config('id_keys', 'LOGIN EMAIL USERNAME ACCOUNT');
# Disable password masking
config('pw_blackout', 0);
# Add custom password keywords
config('pw_keys', 'PASS PASSWORD PIN SECRET TOKEN');
MATRIX SUPPORT
The module can automatically detect and parse random number matrices commonly used by banking systems for security:
| A B C D E F G H I J
--+--------------------
0 | Y W 0 B 8 P 4 C Z H
1 | M 0 6 I K U C 8 6 Z
2 | 7 N R E Y 1 9 3 G 5
Access matrix values using:
my $value = $pb->cell('E', 3); # Gets the value at column E, row 3
SEE ALSO
App::Greple::pw, Getopt::EX::Config
AUTHOR
Kazumasa Utashiro
LICENSE
Copyright (C) 2017-2025 Kazumasa Utashiro.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.