📄 ch19.008_prob_ex19.6
字号:
################################################################################ Example 19.6 (NOT RECOMMENDED) from Chapter 19 of "Perl Best Practices" #### Copyright (c) O'Reilly & Associates, 2005. All Rights Reserved. #### See: http://www.oreilly.com/pub/a/oreilly/ask_tim/2001/codepolicy.html ################################################################################# Example 19-6. Building a report with format# Standard modules...use strict;use warnings;use IO::Prompt;use Carp;use English qw( -no_match_vars );use Data::Alias;use Readonly;# Predeclare report format with the necessary package variables...our ($name, $ID, $age, $comments); format CONTACT = ==================================| NAME | AGE | ID NUMBER ||----------------+-----+-----------|| ^<<<<<<<<<<<<< | ^|| | ^>>>>>>>> |~~ $name, $age, $ID,|==================================|| COMMENTS ||----------------------------------|| ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< |~~ $comments, ==================================. # and later...my $search_string; # Grab contact information...($ID, $name, $age, my $comments_ref) = get_contact($search_string); # Massage comments into a single string...$comments = join "\n", @{$comments_ref}; # Open output stream to STDOUT and write formatted data...open *CONTACT, q{>-} or croak $!;write *CONTACT;sub get_contact { return ( 869942, 'Damian M. Conway', 40, [ 'Do not feed after midnight.', 'Do not mix with quantum physics.', 'Do not allow subject to talk for "as long as he likes".', ], );}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -