`
weihe6666
  • 浏览: 444813 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

Perl-Input and Output

阅读更多
Perl-Input and Output


1.printf 格式化输出:
print "Please input the value of width:\n";
chmop( $width = <STDIN> );

print "Please input the content of string:\n";
chmop ( @string = <STDIN> );

print "1234567890" x (($width+9)/10,"12345";

foreach my $lines (@string){
 printf "%${width}s\n", $lines;#标量内插,这里要用{}和s分开
}

输入:
Please input the wide:
30
Please input the string:
hewei
good-bye
d
D
12345678901234567890123456789012345
                         hewei
                      good-bye
                             d
                             D

分享到:
评论

相关推荐

    perl-pocket-ref-5.004.1.pdf

    Input/Output Perl提供了丰富的I/O操作函数,支持文件和网络通信。 - **print`、`say**:输出到标准输出。 - **&lt;FILEHANDLE&gt;`、`getline**:从文件读取一行。 - **socket`、`listen`、`accept`、`connect**:网络...

    Hadoop - Hadoop Streaming

    $ hadoop jar hadoop-streaming.jar -partitioner org.apache.hadoop.mapred.lib.KeyFieldBasedPartitioner -mapper mymapper -reducer myreducer -input input -output output ``` 这里 `org.apache.hadoop.mapred...

    Teach Yourself Perl In 21 Days

    listings and the Input-Output examples, as well as in code snippets. In the explanations of Perl features, commands, filenames, statements, variables, and any text you see on the screen also are type...

    perl编程实例 代码注释详细

    在这个“perl编程实例 代码注释详细”的压缩包中,我们很显然会探讨如何使用Perl来读取一个名为"Input.TXT"的文本文件,并将其中的内容写入到"Output"文件中。下面将详细解释这个过程以及涉及的Perl编程知识点。 ...

    Apress.Beginning.Perl.3rd.Edition.Apr.2010

    This material sets the stage for a discussion of more complex topics, such as writing custom functions, using regular expressions, and file input and output. Next, the book moves on to the advanced ...

    IO-Compress:IO-Compress-Perl5模块以多种格式读写压缩数据

    open my $in, ', 'input.txt' or die "Can't open input.txt: $!"; open my $out, '&gt;', 'output.gz' or die "Can't open output.gz: $!"; gzip $in =&gt; $out or die "Can't compress data: $!"; # 解压缩 open my $z...

    Perl函数小结

    pipe (INPUT, OUTPUT); $retval = fork(); if ($retval != 0) { # 父进程 close (INPUT); print ("Enter a line of input:\n"); $line = ; print OUTPUT ($line); } else { # 子进程 close (OUTPUT); $...

    Awk入门教程 《Awk A Tutorial and Introduction - by Bruce Barnett》

    Awk入门教程。作者 Bruce Barnett 注:英文版。以下是目录 Why learn AWK? Basic Structure Executing an AWK script Which shell to use with AWK? Dynamic Variables ...AWK, NAWK, GAWK, or PERL

    shellcode帮助工具,直接把exe转shellcode

    -stack put shellcode into stack and execute it (ESP is the shellcode start) -noinfo display no normal messages except error messages Available formats: 0 - C 1 - C(HexArray) 2 - Perl 3 - ...

    ERL脚本打包教程(PERL源代码封装EXE过程).rar

    基本命令格式可能是`perlapp -o output.exe input.pl`,其中`input.pl`是你的Perl脚本,`output.exe`是你想要生成的可执行文件名。 4. **参数和选项**:perlapp支持多种选项,如添加图标、设置版权信息、控制可执行...

    perl函数集(经典)

    pipe my $INPUT, my $OUTPUT; my $retval = fork(); if ($retval != 0) { # 这是父进程 close $INPUT; print "Enter a line of input: \n"; my $line = ; print $OUTPUT $line; } else { # 这是子进程 ...

    使用实体信息丰富用于关系分类的预训练语言模型.zip

    使用实体信息丰富用于关系分类的预训练语言模型 概述 R-BERT (非官方)R-BERT的Pytorch实现:Enriching Pre-trained ...$ python3 predict.py --input_file {INPUT_FILE_PATH} --output_file {OUTPUT_FILE_PATH} --

    ancestral-alleles:基因组变异的祖先等位基因推断

    用法perl run_aa.pl --emf EMF_DIR --input INPUT.txt --output OUTPUT.txt 这将遍历 INPUT.txt 文件中的所有变体并计算每个变体的 AA。 目前只支持特定的 TSV 文件格式,但新的文件格式(尤其是 VCF 将在不久的将来...

    The Perl Programming Language

    open my $fh, ', 'input.txt' or die "Cannot open file: $!"; my @lines = &lt;$fh&gt;; close $fh; foreach (@lines) { s/foo/bar/g; # 替换所有出现的foo为bar } open $fh, '&gt;', 'output.txt' or die "Cannot open ...

    Learning_Perl_Student_Workbook(2nd,2012.01)

    **Input and Output** - **章节概述**: 介绍Perl中的输入输出操作方法。 - **学习目标**: 理解文件句柄的概念;掌握文件的打开、读写、关闭等基本操作。 - **关键知识点**: - 文件句柄:文件句柄的声明与使用。...

    基于Java的在Java中运行Perl脚本 JERL.zip

    在上面的代码中,我们设置了Perl变量`input`,然后执行了一个Perl脚本片段,将`input`转换为大写并保存到`output`中,最后将结果打印出来。 在实际应用中,JERL可以用于各种场景,如自动化测试、数据预处理、复杂...

    verilog转网表perl脚本

    iscas2spice 2.0 : Rewrote the GSRC files generation part in Perl. iscas2spice 2.1 : Included the support for ISCAS89 sequential benchmark circuit. June 19, 2008 iscas2spice 2.2 : This is the first ...

    perl常用命令_函数集.pdf

    pipe (INPUT, OUTPUT); $retval = fork(); if ($retval != 0) { # this is the parent process close (INPUT); print ("Enter a line of input:\n"); $line = ; print OUTPUT ($line); } else { # this is the...

    perl函数应用.doc

    pipe(INPUT, OUTPUT); $retval = fork(); if ($retval != 0) { # This is the parent process close(INPUT); print "Enter a line of input:\n"; $line = ; print OUTPUT $line; } else { # This is the ...

Global site tag (gtag.js) - Google Analytics