Movatterモバイル変換


[0]ホーム

URL:


 / 
String-Scanf-2.1
River stage zero No dependents
/String::Scanf

NAME

String::Scanf - emulate sscanf() of the C library

SYNOPSIS

use String::Scanf; # imports sscanf()($a, $b, $c, $d) = sscanf("%d+%d %f-%s", $input);($e, $f, $g, $h) = sscanf("%x %o %s:%3c"); # input defaults to $_$r = String::Scanf::format_to_re($f);

or

# works only for Perl 5.005 or lateruse String::Scanf qw(); # import nothingmy $s1 = String::Scanf->new("%d+%d %f-%s");my $s2 = String::Scanf->new("%x %o %s:%3c");($a, $b, $c, $d) = $s1->sscanf($input);($e, $f, $g, $h) = $s2->sscanf(); # input defaults to $_

DESCRIPTION

String::Scanf supports scanning strings for data using formats similar to the libc/stdio sscanf().

The supported sscanf() formats are as follows:

%d

Decimal integer, with optional plus or minus sign.

%u

Decimal unsigned integer, with optional plus sign.

%x

Hexadecimal unsigned integer, with optional "0x" or "0x" in front.

%o

Octal unsigned integer.

%e %f %g

(The [efg] work identically.)

Decimal floating point number, with optional plus or minus sign, in any of these formats:

11.1.23.231e451.e451.23e45.23e45

The exponent has an optional plus or minus sign, and thee may also beE.

The various borderline cases likeInf andNan are not recognized.

%s

A non-whitespace string.

%c

A string of characters. An array reference is returned containing the numerical values of the characters.

%%

A literal%.

The sscanf() formats [pnSC] are not supported.

The%s and%c have an optional maximum width, e.g.%4s, in which case at most so many characters are consumed (but fewer characters are also accecpted).

The numeric formats may also have such a width but it is ignored.

The numeric formats may have[hl] before the main option, e.g.%hd, but since such widths have no meaning in Perl, they are ignored.

Non-format parts of the parameter string are matched literally (e.g.: matches as:), expect that any whitespace is matched as any whitespace (e.g. matches as\s+).

WARNING

The numeric formats match only something that looks like a number, they do not care whether it fits into the numbers of Perl. In other words,123e456789 is valid forsscanf(), but quite probably it won't fit into your Perl's numbers. Consider using the various Math::* modules instead.

AUTHOR, COPYRIGHT AND LICENSE

Jarkko Hietaniemi <jhi@iki.fi>

Copyright (c) 2002,2004 Jarkko Hietaniemi. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Module Install Instructions

To install String::Scanf, copy and paste the appropriate command in to your terminal.

cpanm

cpanm String::Scanf

CPAN shell

perl -MCPAN -e shellinstall String::Scanf

For more information on module installation, please visitthe detailed CPAN module installation guide.

Keyboard Shortcuts

Global
sFocus search bar
?Bring up this help dialog
GitHub
gpGo to pull requests
gigo to github issues (only if github is preferred repository)
POD
gaGo to author
gcGo to changes
giGo to issues
gdGo to dist
grGo to repository/SCM
gsGo to source
gbGo to file browse
Search terms
module: (e.g.module:Plugin)
distribution: (e.g.distribution:Dancer auth)
author: (e.g.author:SONGMU Redis)
version: (e.g.version:1.00)

[8]ページ先頭

©2009-2025 Movatter.jp