<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>生信菜鸟团 &#187; perl</title>
	<atom:link href="http://www.bio-info-trainee.com/tag/perl/feed" rel="self" type="application/rss+xml" />
	<link>http://www.bio-info-trainee.com</link>
	<description>欢迎去论坛biotrainee.com留言参与讨论，或者关注同名微信公众号biotrainee</description>
	<lastBuildDate>Sat, 28 Jun 2025 14:30:13 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.33</generator>
	<item>
		<title>用php脚本把Rstudio公司的所有cheatsheet合并</title>
		<link>http://www.bio-info-trainee.com/1673.html</link>
		<comments>http://www.bio-info-trainee.com/1673.html#comments</comments>
		<pubDate>Thu, 02 Jun 2016 23:51:19 +0000</pubDate>
		<dc:creator><![CDATA[ulwvfje]]></dc:creator>
				<category><![CDATA[R]]></category>
		<category><![CDATA[计算机基础]]></category>
		<category><![CDATA[cheatsheet]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Rstudio]]></category>

		<guid isPermaLink="false">http://www.bio-info-trainee.com/?p=1673</guid>
		<description><![CDATA[R studio公司毕竟是商业化公司，在R语言推广方面做得很棒。网站什么总共有9 &#8230; <a href="http://www.bio-info-trainee.com/1673.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>R studio公司毕竟是商业化公司，在R语言推广方面做得很棒。网站什么总共有9个cheatsheet，R语言入门完全可以把这个当做笔记，写代码随时查用！</p>
<p>我批量下载了所有，但是想打印的时候，发现挺麻烦的，因为我不知道批量打印的方法，索性我还是半个程序猿，所以搜索了一下批量合并pdf的方法，这样就可以批量打印了，也方便传输这个文件。</p>
<p>其实如果在linux系统里面，一般都会自带pdf toolkit工具，里面有命令可以合并PDF文档。<span id="more-1673"></span></p>
<p>正好我搜索到了一个比较好玩的实现方法，就是PHP脚本，我还是第一次听说PHP也可以来当做脚本运行，简单浏览了一下，发现跟perl其实差不多，它需要require一些其它public的php脚本，perl就是需要载入一些模块。</p>
<p>首先列出所有下载地址，用wget批量来下载：</p>
<blockquote><p><a href="http://www.rstudio.com/wp-content/uploads/2016/05/base-r.pdf">http://www.rstudio.com/wp-content/uploads/2016/05/base-r.pdf</a></p>
<p><a href="http://www.rstudio.com/wp-content/uploads/2016/02/advancedR.pdf">http://www.rstudio.com/wp-content/uploads/2016/02/advancedR.pdf</a></p>
<p><a href="http://www.rstudio.com/wp-content/uploads/2015/03/rmarkdown-reference.pdf">http://www.rstudio.com/wp-content/uploads/2015/03/rmarkdown-reference.pdf</a></p>
<p><a href="https://www.rstudio.com/wp-content/uploads/2016/01/rstudio-IDE-cheatsheet.pdf">https://www.rstudio.com/wp-content/uploads/2016/01/rstudio-IDE-cheatsheet.pdf</a></p>
<p><a href="https://www.rstudio.com/wp-content/uploads/2015/02/data-wrangling-cheatsheet.pdf">https://www.rstudio.com/wp-content/uploads/2015/02/data-wrangling-cheatsheet.pdf</a></p>
<p><a href="https://www.rstudio.com/wp-content/uploads/2015/02/rmarkdown-cheatsheet.pdf">https://www.rstudio.com/wp-content/uploads/2015/02/rmarkdown-cheatsheet.pdf</a></p>
<p><a href="https://www.rstudio.com/wp-content/uploads/2015/03/ggplot2-cheatsheet.pdf">https://www.rstudio.com/wp-content/uploads/2015/03/ggplot2-cheatsheet.pdf</a></p>
<p><a href="https://www.rstudio.com/wp-content/uploads/2015/06/devtools-cheatsheet.pdf">https://www.rstudio.com/wp-content/uploads/2015/06/devtools-cheatsheet.pdf</a></p>
<p><a href="https://www.rstudio.com/wp-content/uploads/2015/02/shiny-cheatsheet.pdf">https://www.rstudio.com/wp-content/uploads/2015/02/shiny-cheatsheet.pdf</a></p></blockquote>
<p>然后写一个PHP函数，get到待合并目录下面的所有pdf文件：</p>
<blockquote><p>&lt;?php</p>
<p>$dir="./Rstudio_cheatsheets/";</p>
<p><strong>$file=array_diff(scandir($dir),array('..','.'));</strong></p>
<p>print_r($file);</p>
<p>?&gt;</p></blockquote>
<p>上面的代码相当于简单的PHP语法入门，其实这个语言感觉跟perl挺像的，就是列出文件夹里面的文件。</p>
<p><a href="http://www.bio-info-trainee.com/wp-content/uploads/2016/06/1.png"><img class="alignnone size-full wp-image-1674" src="http://www.bio-info-trainee.com/wp-content/uploads/2016/06/1.png" alt="1" width="603" height="264" /></a></p>
<p>然后需要下载两个PHP压缩包，解压到当前文件夹</p>
<p>FPDF: <a href="http://www.fpdf.org/en/download.php">http://www.fpdf.org/en/download.php</a></p>
<p>FPDI: <a href="https://www.setasign.com/products/fpdi/downloads">https://www.setasign.com/products/fpdi/downloads</a></p>
<p>然后写一个脚本来实现合并的功能。</p>
<p><a href="http://www.bio-info-trainee.com/wp-content/uploads/2016/06/2.png"><img class="alignnone size-full wp-image-1675" src="http://www.bio-info-trainee.com/wp-content/uploads/2016/06/2.png" alt="2" width="462" height="324" /></a></p>
<p>这个语法对我来说很诡异，最后居然还报错！！！</p>
<blockquote><p>PHP Fatal error:  Uncaught exception 'Exception' with message 'This document (/home/jmzeng/tmp/test_php/Rstudio_cheatsheets/advancedR.pdf) <strong>probably uses a compression technique which is not supported by the free parser shipped with FPDI. </strong>(See <a href="https://www.setasign.com/fpdi-pdf-parser">https://www.setasign.com/fpdi-pdf-parser</a> for more details)' in /home/jmzeng/tmp/test_php/pdf_parser.php:322</p>
<p>Stack trace:</p>
<p>#0 /home/jmzeng/tmp/test_php/pdf_parser.php(195): pdf_parser-&gt;_readXref(Array, 116)</p>
<p>#1 /home/jmzeng/tmp/test_php/fpdi_pdf_parser.php(64): pdf_parser-&gt;__construct('/home/jmzeng/tm...')</p>
<p>#2 /home/jmzeng/tmp/test_php/fpdi.php(123): fpdi_pdf_parser-&gt;__construct('/home/jmzeng/tm...')</p>
<p>#3 /home/jmzeng/tmp/test_php/fpdi.php(101): FPDI-&gt;_getPdfParser('/home/jmzeng/tm...')</p>
<p>#4 /home/jmzeng/tmp/test_php/merge_pdf.php(11): FPDI-&gt;setSourceFile('advancedR.pdf')</p>
<p>#5 {main}</p>
<p>thrown in /home/jmzeng/tmp/test_php/pdf_parser.php on line 322</p></blockquote>
<p>简单看了下报错内容，估计是PDF这个技术更新的太快了，R studio公司的 cheatsheet 用的PDF标准不被PHP的那两个模块支持！</p>
<p>后来我直接用了<strong>pdfjoin Rstudio_cheatsheets/*pdf   这个命令，简单粗暴，一下子就搞定了！</strong></p>
<p>----</p>
<blockquote><p>  pdfjam: This is pdfjam version 2.08.</p>
<p>pdfjam: Reading any site-wide or user-specific defaults...</p>
<p>(none found)</p>
<p>pdfjam: Effective call for this run of pdfjam:</p>
<p>/usr/bin/pdfjam --fitpaper 'true' --rotateoversize 'true' --suffix joined -- Rstudio_cheatsheets/advancedR.pdf - Rstudio_cheatsheets/base-r.pdf - Rstudio_cheatsheets/data-wrangling-cheatsheet.pdf - Rstudio_cheatsheets/devtools-cheatsheet.pdf - Rstudio_cheatsheets/ggplot2-cheatsheet.pdf - Rstudio_cheatsheets/rmarkdown-cheatsheet.pdf - Rstudio_cheatsheets/rmarkdown-reference.pdf - Rstudio_cheatsheets/rstudio-IDE-cheatsheet.pdf - Rstudio_cheatsheets/shiny-cheatsheet.pdf -</p>
<p>pdfjam: Calling pdflatex...</p>
<p><strong>  pdfjam: Finished.  Output was to '/home/jmzeng/tmp/test_php/shiny-cheatsheet-joined.pdf'.</strong></p></blockquote>
<p>但是，格式不怎么正常， 我最后还是推荐用一个网页工具，你直接上传你的PDF，人家马上就给你合并好了，你直接下载即可。</p>
<p>这种技术，玩玩就好，不要深究。</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bio-info-trainee.com/1673.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>生信分析人员如何系统入门perl？</title>
		<link>http://www.bio-info-trainee.com/1667.html</link>
		<comments>http://www.bio-info-trainee.com/1667.html#comments</comments>
		<pubDate>Thu, 26 May 2016 15:06:05 +0000</pubDate>
		<dc:creator><![CDATA[ulwvfje]]></dc:creator>
				<category><![CDATA[perl]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[学习]]></category>

		<guid isPermaLink="false">http://www.bio-info-trainee.com/?p=1667</guid>
		<description><![CDATA[perl语言在老一辈的生物信息学分析人员中非常流行，所以因为历史遗留原因大家肯定 &#8230; <a href="http://www.bio-info-trainee.com/1667.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<div>perl语言在老一辈的生物信息学分析人员中非常流行，所以因为历史遗留原因大家肯定会或多或少的接触perl，即使你再怎么推崇python或者GO。</div>
<div>perl是典型的脚本语言，短小精悍，非常容易上手，尤其适合处理文本，数据，以及系统管理。</div>
<div></div>
<p><span id="more-1667"></span></p>
<div><span style="color: #ff0000; font-size: large;">简单给几个资料吧：</span></div>
<div>两个半小时入门指导：<a href="https://qntm.org/files/perl/perl.html">https://qntm.org/files/perl/perl.html</a></div>
<div>21天学完：<a href="http://ft-sipil.unila.ac.id/dbooks/%28ebook%20pdf%29%20Teach%20Yourself%20Perl%20in%2021%20Days.pdf">http://ft-sipil.unila.ac.id/dbooks/(ebook%20pdf)%20Teach%20Yourself%20Perl%20in%2021%20Days.pdf</a></div>
<div>还有大小骆驼书，建议都看完，以囫囵吞枣的方式阅读，只看基础知识来入门，难点全部跳过。</div>
<div>官网：<a href="https://www.perl.org/">https://www.perl.org/</a></div>
<div>函数如何用，都可以在<a href="http://perldoc.perl.org/perl.html">http://perldoc.perl.org/perl.html</a> 查到</div>
<div>论坛：<a href="http://www.perlmonks.org/">http://www.perlmonks.org/</a></div>
<div></div>
<div>在看书的同时，你必须记住和熟练使用的知识点是下面这些：</div>
<div><span style="color: #ff0000; font-size: large;"> </span></div>
<div><span style="color: #ff0000; font-size: large;">首先要理解perl里面的三种变量表示方式:</span></div>
<div>$ 表示单个变量  用单双引号区别，q(),qq()</div>
<div>@ 表示多个变量组成的数组，qw()</div>
<div>% 表示关系型变量-hash</div>
<div>变量不严格区分类型，没有int/float/double/char这样的概念</div>
<div></div>
<p><span style="color: #ff0000; font-size: large;">以及对这些简单变量的操作函数</span></p>
<div># Numerical operators:  &lt;,  &gt;, &lt;=, &gt;=, ==, !=, &lt;=&gt;, +, *</div>
<div># String operators:    lt, gt, le, ge, eq, ne, cmp, ., x</div>
<div>数组操作(pop/push/shift/unshift/splice/map/grep/join/split/sort/reverse)</div>
<div>hash操作方式(keys,values,each,delete,exists)</div>
<div></div>
<div>变量内容交换，字符型转为数值型，字符串转为字符数组，字符串变量，heredoc，字符串分割，字符串截取，</div>
<div>随机数生成，取整，各种概率分布数，多维矩阵如何操作，进制转换</div>
<div>hash翻转，数组转hash</div>
<div></div>
<div></div>
<p><span style="color: #ff0000; font-size: large;">上下文环境</span></p>
<div>这个比较复杂： <a href="http://www.perlmonks.org/?node_id=738558">http://www.perlmonks.org/?node_id=738558</a></div>
<div>就是需要理解你写的程序是如何判断你的变量的，你以为的不一定是你以为的</div>
<div><span style="color: #ff0000; font-size: large;"> </span></div>
<div><span style="color: #ff0000; font-size: large;">正则表达式</span></div>
<div>这也是一个非常重要的一块内容，基础用法就是m和s，一个匹配，一个替换，比较有趣的就是$1,$2等等捕获变量。</div>
<div></div>
<div>(=~ s{^https?://}{}   =~ m{///})</div>
<div></div>
<p><span style="color: #ff0000; font-size: large;">内建变量</span></p>
<div>就是perl语言设计的时候定义了一大堆的全局变量($_  $, $0 $&gt; $&lt; $! $. @ARGV @F @_ @INC %ENV %SIG</div>
<div>外表上看起来都是一个$/@/%符号后面加上一大堆的奇奇怪怪的字符，表示一些特殊变量，这也是perl语言饱受诟病的原因。</div>
<div>但是有些非常重要，懂了它之后写程序会方便</div>
<div>下载一个表格，里面有近100个预定义变量需要学习的</div>
<div><span style="color: #ff0000; font-size: large;"> </span></div>
<div><span style="color: #ff0000; font-size: large;">控制语句(循环/条件/判断)</span></div>
<div>if ... elsif ... else ...</div>
<div>unless/while/next/last/for/foreach</div>
<div></div>
<p><span style="color: #ff0000; font-size: large;">读写文件，脚本实战！</span></p>
<div>while(&lt;&gt;){</div>
<div>#do something !</div>
<div>}</div>
<div>这是我最喜欢的一个程序模板，读取文件，根据需要处理文件，然后输出。</div>
<div>需要实现非常多的功能，然后就可以自己总结脚本技巧，也能完全掌握perl的各种语法。</div>
<div>在生物信息学领域，需要实现的功能有！</div>
<div></div>
<p><span style="color: #ff0000; font-size: large;">perl 单行命令</span></p>
<div>我个人特别喜欢这个知识点，我也专门下载过一本书来学习，把这个教程看完就基本上能全明白：<a href="http://www.catonmat.net/blog/perl-one-liners-explained-part-one/">http://www.catonmat.net/blog/perl-one-liners-explained-part-one/</a></div>
<div>学习单行命令的前提是掌握非常多的奇奇怪怪的perl自定义变量，和perl的基础语法，用熟练了之后就非常方便，很多生物信息学数据处理过程我现在基本不写脚本，都是直接写一行命令，完全代替了shell脚本里面的awk、sed/grep系列命令。</div>
<div>(-p -a -n -a -l -i -F -M)</div>
<div></div>
<div></div>
<p><span style="color: #ff0000; font-size: large;">预定义函数</span></p>
<div>perl 是一个非常精简的语言，自定义的函数非常少，连min max这样常见的函数都没有，如果你需要使用这样的功能，要么自己写一个函数，要么使用加强版的包，perl的包非常多。</div>
<div>下面列出一些，我常用的包</div>
<div>程序必备 use/die/warn/print/open/close/&lt;&gt;/</div>
<div>数学函数sin/cos/log/abs/rand/srand/sqrt</div>
<div>字符串函数 uc/lc/scaler/index/rindex/length/pos/substr/sprintf/chop/chomp/hex/int/oct/ord/chr/unpack/unencode</div>
<div>defined/undef</div>
<div></div>
<p><span style="color: #ff0000; font-size: large;">系统操作相关</span></p>
<div>perl语言是跨平台的，因为它的执行靠的是perl解释器，而perl的解释器可以安装在任何机器上面。所以可以用perl来代替很多系统管理工作。</div>
<div>系统命令调用</div>
<div>文件句柄操作(STDIN,STDOUT,STDERR,ARGV,DATA,)</div>
<div>系统文件管理(mkdir/chdir/opendir/closedir/readdir/telldir/rmdir/)</div>
<div></div>
<p><span style="color: #ff0000; font-size: large;">一些高级技巧</span></p>
<div>自定义函数 sub , 参数传递，数组传递，返回值</div>
<div>模块操作(模块安装，加载，模块路径，模块函数引用)</div>
<div>引用（变量的变量）</div>
<div></div>
<div>选择一个好的编辑器-编译器,editplus,notepad++,jEdit，编程习惯的养成。</div>
<div>搞清楚perl版本的问题，还有程序编码的问题，中文显示的问题</div>
<div>程序调试</div>
<div><span style="color: #ff0000; font-size: large;"> </span></div>
<div><span style="color: #ff0000; font-size: large;">perl常见模块学习</span></div>
<div>perl和LWP/HTML做网络爬虫必备，重点是DOM如何解析</div>
<div>perl和CGI编程，做网站的神器，重点是html基础知识</div>
<div>DBI相关数据库，用perl来操作mysql等，当然，重点是mysql知识</div>
<div>GD and GD::Graph 可以用来画图，但是基本上没有人用了，除了CIRCOS画圈圈图火起来了。</div>
<div>TK模块，可以编写GUI界面程序，但是也几乎没有人用了。</div>
<div>XML/pdf/excel/Json 相关的模块可以用来读取非文本格式数据，或者输出格式化报告。</div>
<div>socket通信相关，高手甚至可以写出一个QQ的模仿版本</div>
<div>最后不得不提的就是Bioperl了，虽然我从来没有用过，但是它的确对初学者非常有用，大多数人不提倡重复造轮子，但我个人觉得，对初学者来说，重复造轮子是一个非常好的学习方式。大家可以仿造bioperl里面的各个功能，用自己的脚本来实现！</div>
<div></div>
<p><span style="color: #ff0000; font-size: large;">如果你感觉学的差不多了，就可以下载一些复习资料，查漏补缺:</span></p>
<div>
<div><a href="http://michaelgoerz.net/refcards/perl_refcard.pdf">http://michaelgoerz.net/refcards/perl_refcard.pdf</a></div>
<div><a href="https://rc.hms.harvard.edu/training/perl/Perl%20Cheat%20Sheet.pdf">https://rc.hms.harvard.edu/training/perl/Perl%20Cheat%20Sheet.pdf</a></div>
<div><a href="https://www.cheatography.com/mishin/cheat-sheets/perl-reference-card/">https://www.cheatography.com/mishin/cheat-sheets/perl-reference-card/</a></div>
<div><a href="http://www.catonmat.net/download/perl.predefined.variables.pdf">http://www.catonmat.net/download/perl.predefined.variables.pdf</a></div>
<div><a href="http://www.erudil.com/preqr.pdf">http://www.erudil.com/preqr.pdf</a></div>
<div><a href="https://www.cs.tut.fi/~jkorpela/perl/regexp.html">https://www.cs.tut.fi/~jkorpela/perl/regexp.html</a></div>
<div><a href="https://support.sas.com/rnd/base/datastep/perl_regexp/regexp-tip-sheet.pdf">https://support.sas.com/rnd/base/datastep/perl_regexp/regexp-tip-sheet.pdf</a></div>
</div>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bio-info-trainee.com/1667.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>perl程序技巧-检验系统环境或模块安装</title>
		<link>http://www.bio-info-trainee.com/1479.html</link>
		<comments>http://www.bio-info-trainee.com/1479.html#comments</comments>
		<pubDate>Tue, 15 Mar 2016 12:12:34 +0000</pubDate>
		<dc:creator><![CDATA[ulwvfje]]></dc:creator>
				<category><![CDATA[perl]]></category>
		<category><![CDATA[模块]]></category>
		<category><![CDATA[环境变量]]></category>

		<guid isPermaLink="false">http://www.bio-info-trainee.com/?p=1479</guid>
		<description><![CDATA[这个程序是我在VirusFinder里面发现的，大家可以自行搜索它！ 非常好用， &#8230; <a href="http://www.bio-info-trainee.com/1479.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>这个程序是我在VirusFinder里面发现的，大家可以自行搜索它！</p>
<p>非常好用，建议大家写程序都可以加上这个！</p>
<blockquote>
<div>print "\nChecking Java version...\n\n";</div>
<div></div>
<div>my $ret = `java -version 2&gt;&amp;1`;</div>
<div>print "$ret\n";</div>
<div></div>
<div>if (index($ret, '1.6') == -1) {</div>
<div>    printf "Warning: The tool Trinity of the Broad Institute may require Java 1.6.\n\n";</div>
<div>}</div>
<div></div>
<div></div>
<div>print "\nChecking SAMtools...\n\n";</div>
<div></div>
<div>$ret = `which samtools 2&gt;&amp;1`;</div>
<div>if (index($ret, 'no samtools') == -1) {</div>
<div>    printf "%-30s\tOK\n\n", 'SAMtools';</div>
<div>}else{</div>
<div>    printf "%-30s\tnot found\n\n", 'SAMtools';</div>
<div>}</div>
<div></div>
<div></div>
<div>my @required_modules = ("Bio::DB::Sam",</div>
<div>                        "Bio::DB::Sam::Constants",</div>
<div>                        "Bio::SeqIO",</div>
<div>                        "Bio::SearchIO",</div>
<div>                        "Carp",</div>
<div>                        "Config::General",</div>
<div>                        "Cwd",</div>
<div>                        "Data::Dumper",</div>
<div>                        "English",</div>
<div>                        "File::Basename",</div>
<div>                        "File::Copy",</div>
<div>                        "File::Path",</div>
<div>                        "File::Spec",</div>
<div>                        "File::Temp",</div>
<div>                        "FindBin",</div>
<div>                        "Getopt::Std",</div>
<div>                        "Getopt::Long",</div>
<div>                        "IO::Handle",</div>
<div>                        "List::MoreUtils",</div>
<div>                        "Pod::Usage",</div>
<div>                        "threads");</div>
<div></div>
<div>print "\nChecking CPAN modules required by VirusFinder...\n\n";</div>
<div>my $count = 0;</div>
<div>for my $module (@required_modules){</div>
<div></div>
<div>eval("use $module");</div>
<div>if ($@) {</div>
<div>printf "%-30s\tFailed\n", $module;</div>
<div>                $count++;</div>
<div>}</div>
<div>else {</div>
<div>printf "%-30s\tOK\n",     $module;</div>
<div>}</div>
<div>}</div>
<div></div>
<div>if ($count==1){</div>
<div>print "\n\nOne module may not be installed properly.\n\n";</div>
<div>}elsif ($count &gt; 1){</div>
<div>print "\n\n$count modules may not be installed properly.\n\n";</div>
<div>}else{</div>
<div>print "\n\nAll CPAN modules checked!\n\n";</div>
<div>}</div>
</blockquote>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bio-info-trainee.com/1479.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>perl模块终极解决方案-下</title>
		<link>http://www.bio-info-trainee.com/1476.html</link>
		<comments>http://www.bio-info-trainee.com/1476.html#comments</comments>
		<pubDate>Tue, 15 Mar 2016 12:08:44 +0000</pubDate>
		<dc:creator><![CDATA[ulwvfje]]></dc:creator>
				<category><![CDATA[perl]]></category>
		<category><![CDATA[模块]]></category>

		<guid isPermaLink="false">http://www.bio-info-trainee.com/?p=1476</guid>
		<description><![CDATA[其实可以手动下载local::lib, 这个perl模块，然后自己安装在指定目录 &#8230; <a href="http://www.bio-info-trainee.com/1476.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>其实可以手动下载<a href="http://search.cpan.org/perldoc?local::lib">local::lib</a>, 这个perl模块，然后自己安装在指定目录，也是能解决模块的问题！</p>
<p>下载之后解压，进入：</p>
<blockquote>
<pre><span style="color: #ff00ff;"> $ perl Makefile.PL --bootstrap=~/.perl  ##这里设置你想把模块放置的目录
 $ make test &amp;&amp; make install
 $ echo 'eval $(perl -I$HOME/.perl/lib/perl5 -Mlocal::lib=$HOME/.perl)' &gt;&gt; ~/.bashrc</span></pre>
</blockquote>
<p>等待几个小时即可！！！</p>
<p>添加好环境变量之后，就可以用</p>
<div>
<blockquote>
<pre class="">perl <span class="">-</span>MCPAN <span class="">-</span>Mlocal<span class="">::</span>lib <span class="">-</span>e <span class="">'CPAN::install(LWP)'</span></pre>
</blockquote>
<div class="gmail_quote">这样的模式下载模块了，所有的模块都会存储在<span style="color: #993366;">$HOME/.perl/lib/perl5</span> 里面！！！</div>
<div class="gmail_quote">如果是新写的perl程序，需要在开头加入<span style="color: #0000ff;"> <span class="">use</span> <span class="">local</span><span class="">::</span>lib<span class="">;   </span></span></div>
<div class="gmail_quote"><span class=""># sets up a local lib at ~/perl5才能使用该模块！  非常重要，非常重要，非常重要！！！<br />
</span></div>
</div>
<p>&nbsp;</p>
<p>其实你也可以直接打开<span style="color: #ff00ff;"> ~/.bashrc</span>，然后写入下面的内容</p>
<pre><span class="">PERL5LIB</span><span class="">=$</span><span class="">PERL5LIB</span><span class="">:/</span><span class="">PATH_WHERE_YOU_PUT_THE_PACKAGE</span><span class="">/</span><span class="">source</span><span class="">/</span><span class="">bin</span><span class="">/</span><span class="">perl_module</span><span class="">;</span> <span class="">export</span> <span class="">PERL5LIB</span></pre>
<pre><span class="">可以把perl模块安装在任何地方，然后通过这种方式去把模块加载到你的perl程序！</span></pre>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bio-info-trainee.com/1476.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>perl模块终极解决方案-上</title>
		<link>http://www.bio-info-trainee.com/1474.html</link>
		<comments>http://www.bio-info-trainee.com/1474.html#comments</comments>
		<pubDate>Tue, 15 Mar 2016 12:03:43 +0000</pubDate>
		<dc:creator><![CDATA[ulwvfje]]></dc:creator>
				<category><![CDATA[perl]]></category>
		<category><![CDATA[local]]></category>
		<category><![CDATA[模块]]></category>
		<category><![CDATA[非root]]></category>

		<guid isPermaLink="false">http://www.bio-info-trainee.com/?p=1474</guid>
		<description><![CDATA[不管别人怎么说，反正我是非常喜欢perl语言的！ 也会继续学习，以前写过不少pe &#8230; <a href="http://www.bio-info-trainee.com/1474.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>不管别人怎么说，反正我是非常喜欢perl语言的！</p>
<p>也会继续学习，以前写过不少perl模块的博客，发现有点乱，正好最近看到了关于local::lib这个模块。</p>
<p>居然是用来解决没有root权限的用户安装，perl模块问题的！</p>
<p>首先说一下，如果是root用户，模块其实没有问题，直接用cpan下载器，几乎能解决所有的模块下载安装问题！</p>
<p>但是如果是非root用户，那么就麻烦了，很难用自动的cpan下载器，这样只能下载模块源码，然后编译，但是编译有个问题，很多模块居然是依赖于其它模块的，你的不停地下载其它依赖模块，最后才能解决，特别麻烦</p>
<p>但是，只需要运行下面的代码：<code></code><br />
<code></code></p>
<blockquote>
<pre class=""><code><span class="">wget </span><span class="">-</span><span class="">O</span><span class="">-</span><span class=""> http</span><span class="">:/</span><span class="">/<a href="http://cpanmin.us">cpanmin.us</a> | perl - -l ~/</span><span class="">perl5 </span><span class="">App</span><span class="">::</span><span class="">cpanminus </span><span class="">local</span><span class="">::</span><span class="">lib
</span><span class="">eval</span> <span class="">`perl -I ~/perl5/lib/perl5 -Mlocal::lib`</span><span class="">
echo </span><span class="">'eval `perl -I ~/perl5/lib/perl5 -Mlocal::lib`'</span> <span class="">&gt;&gt;</span> <span class="">~</span><span class="">/.profile
echo 'export MANPATH=$HOME/</span><span class="">perl5</span><span class="">/</span><span class="">man</span><span class="">:</span><span class="">$MANPATH</span><span class="">' &gt;&gt; ~/.profile</span></code></pre>
</blockquote>
<p>就能拥有一个私人的cpan下载器，<code><span class="">~/.profile可能需要更改为<span style="color: #ff00ff;">.bash_profile, .bashrc, etc</span>等等，取决于你的linux系统！<br />
</span></code></p>
<p>然后你直接运行<code><span class="">cpanm </span><span class="">Module</span><span class="">::</span><span class="">Name，就跟root用户一样的可以下载模块啦！<br />
</span></code></p>
<p>或者用下面的方式在shell里面安装模块，其中ext是模块的安装目录，可以修改</p>
<blockquote><p> perl -MTime::HiRes -e 1 &gt; /dev/null 2&gt;&amp;1 || cpanm -v --notest -l ext Time::HiRes;<br />
perl -MFile::Path -e 1 &gt; /dev/null 2&gt;&amp;1 || cpanm -v --notest -l ext File::Path;<br />
perl -MFile::Basename -e 1 &gt; /dev/null 2&gt;&amp;1 || cpanm -v --notest -l ext File::Basename;<br />
perl -MFile::Copy -e 1 &gt; /dev/null 2&gt;&amp;1 || cpanm -v --notest -l ext File::Copy;<br />
perl -MIO::Handle -e 1 &gt; /dev/null 2&gt;&amp;1 || cpanm -v --notest -l ext IO::Handle;<br />
perl -MYAML::XS -e 1 &gt; /dev/null 2&gt;&amp;1 || cpanm -v --notest -l ext YAML::XS;<br />
perl -MYAML -e 1 &gt; /dev/null 2&gt;&amp;1 || cpanm -v --notest -l ext YAML;<br />
perl -MXML::Simple -e 1 &gt; /dev/null 2&gt;&amp;1 || cpanm -v --notest -l ext XML::Simple;<br />
perl -MStorable -e 1 &gt; /dev/null 2&gt;&amp;1 || cpanm -v --notest -l ext Storable;<br />
perl -MStatistics::Descriptive -e 1 &gt; /dev/null 2&gt;&amp;1 || cpanm -v --notest -l ext Statistics::Descriptive;<br />
perl -MTie::IxHash -e 1 &gt; /dev/null 2&gt;&amp;1 || cpanm -v --notest -l ext Tie::IxHash;<br />
perl -MAlgorithm::Combinatorics -e 1 &gt; /dev/null 2&gt;&amp;1 || cpanm -v --notest -l ext Algorithm::Combinatorics;<br />
perl -MDevel::Size -e 1 &gt; /dev/null 2&gt;&amp;1 || cpanm -v --notest -l ext Devel::Size;<br />
perl -MSort::Key::Radix -e 1 &gt; /dev/null 2&gt;&amp;1 || cpanm -v --notest -l ext Sort::Key::Radix;<br />
perl -MSort::Key -e 1 &gt; /dev/null 2&gt;&amp;1 || cpanm -v --notest -l ext Sort::Key;<br />
perl -MBit::Vector -e 1 &gt; /dev/null 2&gt;&amp;1 || cpanm -v --notest -l ext Bit::Vector;<br />
perl -M"feature 'switch'" -e 1 &gt; /dev/null 2&gt;&amp;1 || cpanm -v --notest -l ext feature;</p></blockquote>
<p>下面是解释为什么这样可以解决问题！！！</p>
<p>&nbsp;</p>
<div>
<p>What follows is a brief explanation of what the commands above do.</p>
<p><code>wget -O- <a href="http://cpanmin.us">http://cpanmin.us</a></code> fetches the latest version of <code>cpanm</code> and prints it to <code>STDOUT</code> which is then piped to <code>perl - -l ~/perl5 App::cpanminus local::lib</code>. The first <code>-</code> tells <code>perl</code> to expect the program to come in on <code>STDIN</code>, this makes <code>perl</code> run the version of <code>cpanm</code> we just downloaded.<code>perl</code> passes the rest of the arguments to <code>cpanm</code>. The <code>-l ~/perl5</code> argument tells <code>cpanm</code> where to install Perl modules, and the other two arguments are two modules to install. <code>[App::cpanmins</code>]<a href="http://search.cpan.org/dist/App-cpanminus/lib/App/cpanminus.pm">1</a> is the package that installs <code>cpanm</code>. <a href="http://search.cpan.org/dist/local-lib/lib/local/lib.pm"><code>local::lib</code></a> is a helper module that manages the environment variables needed to run modules in local directory.</p>
<p>After those modules are installed we run</p>
<pre class=""><code><span class="">eval</span> <span class="">`perl -I ~/perl5/lib/perl5 -Mlocal::lib`</span></code></pre>
<p>to set the environment variables needed to use the local modules and then</p>
<pre class=""><code><span class="">echo </span><span class="">'eval `perl -I ~/perl5/lib/perl5 -Mlocal::lib`'</span> <span class="">&gt;&gt;</span> <span class="">~/.</span><span class="">profile</span></code></pre>
<p>to ensure we will be able to use them the next time we log in.</p>
<pre class=""><code><span class="">echo </span><span class="">'export MANPATH=$HOME/perl5/man:$MANPATH'</span> <span class="">&gt;&gt;</span> <span class="">~/.</span><span class="">profile</span></code></pre>
<p>will hopefully cause man to find the man pages for your local modules.</p>
</div>
<div>
<p>这种类似的问题被问的特别多！</p>
<p>There's the way documented in <a href="http://faq.perl.org/perlfaq8.html#How_do_I_install_a_m">perlfaq8</a>, which is what <a href="http://search.cpan.org/perldoc/local%3a%3alib#The_bootstrapping_technique">local::lib</a> is doing for you.</p>
<p>It's also a frequently asked StackOverflow question:</p>
<ul>
<li><a href="http://stackoverflow.com/q/1366902/8817">Why does installing certain CPAN modules require root privilege?</a></li>
<li><a href="http://stackoverflow.com/q/102850/8817">How can I install CPAN modules locally without root access (DynaLoader.pm line 229 error)?</a></li>
<li><a href="http://stackoverflow.com/q/786544/8817">How do I tell CPAN.pm to install all modules in a specific directory?</a></li>
<li><a href="http://stackoverflow.com/q/540640/8817">How can I install a CPAN module into a local directory?</a></li>
<li><a href="http://stackoverflow.com/q/251705/8817">How can I use a new Perl module without install permissions?</a></li>
<li><a href="http://stackoverflow.com/q/2980297/8817">How can I use CPAN as a non-root user?</a></li>
<li><a href="http://stackoverflow.com/q/1541638/8817">How can I install local modules with the cpan tool?</a></li>
</ul>
</div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bio-info-trainee.com/1474.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>没必要学shell进阶语法</title>
		<link>http://www.bio-info-trainee.com/1410.html</link>
		<comments>http://www.bio-info-trainee.com/1410.html#comments</comments>
		<pubDate>Mon, 22 Feb 2016 12:29:07 +0000</pubDate>
		<dc:creator><![CDATA[ulwvfje]]></dc:creator>
				<category><![CDATA[杂谈-随笔]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[脚本]]></category>
		<category><![CDATA[自动化]]></category>

		<guid isPermaLink="false">http://www.bio-info-trainee.com/?p=1410</guid>
		<description><![CDATA[因为大部分生物信息学软件都是linux版本的，所以生物信息学数据分析工作者必备技 &#8230; <a href="http://www.bio-info-trainee.com/1410.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>因为大部分生物信息学软件都是linux版本的，所以生物信息学数据分析工作者必备技能就是linux，但是大部分人只是拿他当个中转站，我以前也是，直到接触了大批量的任务，自动化流程，才明白这里面的水太深了，不过无所谓，凭我个人的观点，其实shell的进阶语法真的不必要！</p>
<div>当然，只是我一家之言！</div>
<div>我实在是不想去背诵大括号，小括号，中括号以及双重括号到底区别是什么！</div>
<div>
<div><a href="http://www.bio-info-trainee.com/?p=1018">http://www.bio-info-trainee.com/?p=1018</a>  [],[[]],(),(()),{},{{}},以及在前面加上$的区别，以及它们互相杂交组合的区别！！！</div>
<p>我也不想去搞明白操作符两边是否加空格的区别是什么了。</p>
</div>
<div>if((i%5==0)) 来判断变量是否被一个数整除</div>
<div>i=$((i+1))来表示变量自增。</div>
<div>这些东西真的很诡异！</div>
<div>如果你有qsub，condor等任务提交系统，那么你只需要熟悉他们就可以了，但大部分散兵游勇的生物信息学家并没有集群，所以压根不会接触任务提交系统，就需要些自动化脚本了！</div>
<div>
<div><a href="http://www.bio-info-trainee.com/?p=382">http://www.bio-info-trainee.com/?p=382</a></div>
</div>
<div>受限制与机器的cpu以及内存数，需要判断提交了多少任务，等待多久再执行，所以会把一个简单的自动化脚本写的很复杂！</div>
<div>比如下面这个脚本：cat &gt;download_hg38_from_UCSC.sh</p>
<div><span style="color: #ff0000;">for i in $(seq 1 22) X Y M;</span></div>
<div><span style="color: #ff0000;">do echo $i;</span></div>
<div><span style="color: #ff0000;">wget<span class="Apple-converted-space"> </span><a href="ftp://hgdownload.cse.ucsc.edu/goldenPath/hg38/chromosomes/chr$%7Bi%7D.fa.gz">ftp://hgdownload.cse.ucsc.edu/goldenPath/hg38/chromosomes/chr${i}.fa.gz</a>;</span></div>
<div><span style="color: #ff0000;">done</span></div>
<div><span style="color: #ff0000;">gunzip *.gz</span></div>
<div><span style="color: #ff0000;">for i in $(seq 1 22) X Y M;</span></div>
<div><span style="color: #ff0000;">do cat chr${i}.fa &gt;&gt; hg38.fa;</span></div>
<div><span style="color: #ff0000;">done</span></div>
<div><span style="color: #ff0000;">rm -fr chr*.fa</span></div>
<div>可以下载hg38基因组的fasta文件，但是是分染色体一个个下载的！</div>
<div>再比如下面这个，批量做GSEA分析的脚本：</div>
<div>
<div>while read id</div>
<div>do</div>
<div>echo $id</div>
<div>gene=`echo $id |awk '{print $1}'`</div>
<div>probe=`echo $id |awk '{print $2}'`</div>
<div></div>
<div>echo $i</div>
<div>do_GSEA $probe $gene; ##这里是我自己定义的一个function，就不贴出来了</div>
<div>if((i%5==0))</div>
<div>then</div>
<div>sleep 10  ##重点就在这里，每次提交的任务有限制，所以需要休息，不然机器的cpu负载太高！</div>
<div>fi</div>
<div>i=$((i+1))</div>
<div>done &lt;$1</div>
<p>如果，还有其它功能需要实现，我们可以把脚本写的更负载，纯粹的用shell，需要搜索更多的shell技巧。</p>
</div>
<div>但是事实上并没有这个必要，我们现在有了更方便的脚本语言，比如我所擅长的perl</div>
<div>我写一个nohup提交任务的脚本！</div>
<div>
<div>## perl<span class="Apple-converted-space"> </span><a href="http://nohup.pl/">nohup.pl</a><span class="Apple-converted-space"> </span>  deep_count.sh  0</div>
<div>## perl<span class="Apple-converted-space"> </span><a href="http://nohup.pl/">nohup.pl</a><span class="Apple-converted-space"> </span>  deep_count.sh  1</div>
<div>## perl<span class="Apple-converted-space"> </span><a href="http://nohup.pl/">nohup.pl</a><span class="Apple-converted-space"> </span>  deep_count.sh  2</div>
<p>[perl]<br />
## perl nohup.pl   deep_count.sh  0<br />
## perl nohup.pl   deep_count.sh  1<br />
## perl nohup.pl   deep_count.sh  2<br />
$i=1;<br />
open FH,$ARGV[0];<br />
while(&lt;FH&gt;){<br />
    chomp;<br />
    next unless $.%3==$ARGV[1];<br />
    $cmd=&quot;nohup  $_  &amp;&quot;;<br />
    print &quot;$cmd\n&quot;;<br />
    system($cmd);<br />
    sleep(10800) if $i%5==4;<br />
    $i++;<br />
    #exit;<br />
}<br />
[/perl]</p>
</div>
<div>我尝试过用shell，写了很久，总是报错，但是用perl，一分钟我就写完了，所以，最好是用自己熟悉的一种语法最好！</div>
<div></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.bio-info-trainee.com/1410.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>perl的模块组织方式</title>
		<link>http://www.bio-info-trainee.com/1005.html</link>
		<comments>http://www.bio-info-trainee.com/1005.html#comments</comments>
		<pubDate>Thu, 24 Sep 2015 11:21:18 +0000</pubDate>
		<dc:creator><![CDATA[ulwvfje]]></dc:creator>
				<category><![CDATA[perl]]></category>
		<category><![CDATA[模块]]></category>

		<guid isPermaLink="false">http://www.bio-info-trainee.com/?p=1005</guid>
		<description><![CDATA[如何使用自己写的私人模块 模块通俗来讲，就是一堆函数的集合。 Personall &#8230; <a href="http://www.bio-info-trainee.com/1005.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>如何使用自己写的私人模块</p>
<div>模块通俗来讲，就是一堆函数的集合。</p>
<div>Personally I prefer to keep my modules (those that I write for myself or for systems I can control) in a certain directory, and also to place them in a subdirectory. As in:</p>
<pre><code>/www/modules/MyMods/Foo.pm
/www/modules/MyMods/Bar.pm</code></pre>
<p>And then where I use them:</p>
<pre><code>use lib qw(/www/modules);useMyMods::Foo; </code></pre>
<p>useMyMods::Bar;</p>
<div></div>
<div>
<p>As reported by "perldoc -f use":</p>
<blockquote><p>It is exactly equivalent to<br />
<code>BEGIN { require Module; import Module LIST; }</code><br />
except that Module must be a bareword.</p></blockquote>
<p>Putting that another way, "use" is equivalent to:</p>
<ul>
<li>running at compile time,</li>
<li>converting the package name to a file name,</li>
<li><code>require</code>-ing that file name, and</li>
<li><code>import</code>-ing that package.</li>
</ul>
<p>So, instead of calling use, you can call require and import inside a BEGIN block:</p>
<pre><code>BEGIN{require'../EPMS.pm';
  EPMS-&gt;import();}</code></pre>
<p>And of course, if your module don't actually do any symbol exporting or other initialization when you call import, you can leave that line out:</p>
<pre><code>BEGIN{require'../EPMS.pm';}</code></pre>
</div>
<div>比如我的一个模块如下，命名为<a href="http://my_stat.pm/">my_stat.pm</a>：</div>
</div>
</div>
<div>package my_stat;</div>
<div>sub mean{</div>
<div>my $sum=0;</div>
<div>$sum+=$_ foreach @_;</div>
<div>$sum/($#_+1);</div>
<div>}</div>
<div>#print &amp;mean(1..10),"\n";</div>
<div>sub stddev{</div>
<div>$avg=&amp;mean(@_);</div>
<div>#print "$avg\n";</div>
<div>my $sum=0;</div>
<div>$sum+=($_-$avg)**2 foreach @_;</div>
<div>sqrt($sum/($#_));</div>
<div>#It will be different if you use $#_+1;</div>
<div>#sqrt($sum/($#_+1));</div>
<div>}</div>
<div>#print &amp;stddev(1..10),"\n";</div>
<div>1;</div>
<div>里面有我定义好的两个函数 mean 和 stddev , 那么我就可以在我的其它perl程序里面直接引用这个模块，从而使用我的两个自定义函数。</div>
<div>use lib "./";  #取决于你把自定义模块<a href="http://my_stat.pm/">my_stat.pm</a>放在哪个目录</div>
<div>use my_stat;</div>
<div>print my_stat::stddev(1..10),"\n";</div>
]]></content:encoded>
			<wfw:commentRss>http://www.bio-info-trainee.com/1005.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>perl操作pdf文档</title>
		<link>http://www.bio-info-trainee.com/873.html</link>
		<comments>http://www.bio-info-trainee.com/873.html#comments</comments>
		<pubDate>Fri, 17 Jul 2015 03:47:22 +0000</pubDate>
		<dc:creator><![CDATA[ulwvfje]]></dc:creator>
				<category><![CDATA[perl]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[模块]]></category>

		<guid isPermaLink="false">http://www.bio-info-trainee.com/?p=873</guid>
		<description><![CDATA[大家看看就好，这个模块写的不怎么样，而且有高手已经写了一个pdftoolkit就 &#8230; <a href="http://www.bio-info-trainee.com/873.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>大家看看就好，这个模块写的不怎么样，而且有高手已经写了一个pdftoolkit就是完全用这个模块实现了大部分pdf文档的操作</p>
<p><strong>PDF::API2</strong><strong>模块使用笔记</strong></p>
<p>一：简单使用方法</p>
<p>use PDF::API2;</p>
<table>
<tbody>
<tr>
<td width="284"># Create a blank PDF file</td>
<td width="284">$pdf = PDF::API2-&gt;new();</td>
</tr>
<tr>
<td width="284"># Open an existing PDF file</td>
<td width="284">$pdf = PDF::API2-&gt;open('some.pdf');</td>
</tr>
<tr>
<td width="284"># Add a blank page</td>
<td width="284">$page = $pdf-&gt;page();</td>
</tr>
<tr>
<td width="284"># Retrieve an existing page</td>
<td width="284">$page = $pdf-&gt;openpage($page_number);</td>
</tr>
<tr>
<td width="284"># Set the page size</td>
<td width="284">$page-&gt;mediabox('Letter');</td>
</tr>
<tr>
<td width="284"># Add a built-in font to the PDF</td>
<td width="284">$font = $pdf-&gt;corefont('Helvetica-Bold');</td>
</tr>
<tr>
<td width="284"># Add an external TTF font to the PDF</td>
<td width="284">$font = $pdf-&gt;ttfont('/path/to/font.ttf');</td>
</tr>
<tr>
<td width="284">&nbsp;</p>
<p># Add some text to the page</td>
<td width="284">$text = $page-&gt;text();</p>
<p>$text-&gt;font($font, 20);</p>
<p>$text-&gt;translate(200, 700);</p>
<p>$text-&gt;text('Hello World!');</td>
</tr>
<tr>
<td width="284"># Save the PDF</td>
<td width="284">$pdf-&gt;saveas('/path/to/new.pdf');</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>实例：</p>
<p>use PDF::API2;</p>
<p>$pdf=PDF::API2-&gt;new;</p>
<p>$pdf-&gt;mediabox('A4');</p>
<p>$ft=$pdf-&gt;cjkfont('Song');</p>
<p>$page = $pdf-&gt;page;</p>
<p>$gfx=$page-&gt;gfx;</p>
<p>$gfx-&gt;textlabel(50,750,$ft,20,"\x{Cool44}\x{4EA7}"); # 资产二字</p>
<p>$pdf-&gt;saveas('Song_Test.pdf');</p>
<p>&nbsp;</p>
<p>二：主要对象及方法</p>
<p>1、pdf对象可以创造，可以打开，可以保存，可以更新，还有一堆参数可以设置</p>
<p>$pdf-&gt;preferences(%options)还可以设置一些浏览参数，不过本来pdf阅读器可以设置，没必要在这里花时间。</p>
<p>这个可以当做是个人创建pdf的保密信息，也许有一点用吧。</p>
<p>还可以可以设置页脚$pdf-&gt;pageLabel($index, $options</p>
<p>2、Page对象，可以新建，可以打开，可以保存（需要指定保存的位置）</p>
<p>$page = $pdf-&gt;page()</p>
<p>$page = $pdf-&gt;page($page_number)</p>
<p>$page = $pdf-&gt;openpage($page_number);</p>
<p>还可以更新旧的pdf，这样可以循环获取pdf页面不停的累积到一个新的pdf</p>
<p>$page = $pdf-&gt;import_page($source_pdf, $source_page_number, $target_page_number)</p>
<p>$pdf = PDF::API2-&gt;new();</p>
<p>$old = PDF::API2-&gt;open('our/old.pdf');   # Add page 2 from the old PDF as page 1 of the new PDF</p>
<p>$page = <strong>$pdf-&gt;import_page</strong>($old, 2);</p>
<p>$pdf-&gt;saveas('our/new.pdf');If $source_page_number is 0 or -1, it will return the last page in the document.</p>
<p>$count = $pdf-&gt;pages()Returns the number of pages in the document.</p>
<p>这样就可以写一个简单程序把我们的pdf文件合并</p>
<p>use PDF::API2;</p>
<p>my $new = PDF::API2-&gt;new;</p>
<p>foreach my $filename (@ARGV) {   my $pdf = PDF::API2-&gt;open($filename);   $new-&gt;importpage($pdf, $_) foreach 1 .. $pdf-&gt;pages;}$new-&gt;saveas('new.pdf'); $pdf-&gt;mediabox($name)</p>
<p>可以指定A4，A3，A5等等$pdf-&gt;mediabox($w, $h)可以指定宽度和高度$pdf-&gt;mediabox($llx, $lly, $urx, $ury)</p>
<p>3，还可以随意画点线面及表格，太复杂了就不看了</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bio-info-trainee.com/873.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>perl操作excel表格</title>
		<link>http://www.bio-info-trainee.com/851.html</link>
		<comments>http://www.bio-info-trainee.com/851.html#comments</comments>
		<pubDate>Wed, 15 Jul 2015 08:28:50 +0000</pubDate>
		<dc:creator><![CDATA[ulwvfje]]></dc:creator>
				<category><![CDATA[perl]]></category>
		<category><![CDATA[excel]]></category>

		<guid isPermaLink="false">http://www.bio-info-trainee.com/?p=851</guid>
		<description><![CDATA[perl这个语言已经过时很久了，所以它的模块支持性能不是很好，暂时我只看到了对e &#8230; <a href="http://www.bio-info-trainee.com/851.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>perl这个语言已经过时很久了，所以它的模块支持性能不是很好，暂时我只看到了对excel2003格式的表格的读取写入操作。</p>
<p>以下是我参考Spreadsheet::ParseExcel这个模块写的一个把excel表格转为csv的小程序，大家也可以自己搜索该模块的说明文档，这样学的更快一点！</p>
<p>[perl]</p>
<p>#!/usr/bin/perl -w<br />
# For each tab (worksheet) in a file (workbook),<br />
# spit out columns separated by &quot;,&quot;,<br />
# and rows separated by c/r.</p>
<p>use Spreadsheet::ParseExcel;<br />
use strict;<br />
use utf8;<br />
use Encode::Locale qw($ENCODING_LOCALE_FS);<br />
use Encode;</p>
<p>my $filename =&quot;test.xls&quot;;#输入需要解析的excel文件名，必须是03版本的<br />
my $e = new Spreadsheet::ParseExcel; #新建一个excel表格操作器<br />
my $eBook = $e-&gt;Parse($filename);    #用表格操作器来解析我们的文件<br />
my $sheets = $eBook-&gt;{SheetCount};   #得到该文件中sheet总数<br />
my ($eSheet, $sheetName);</p>
<p>foreach my $sheet (0 .. $sheets - 1) {<br />
$eSheet = $eBook-&gt;{Worksheet}[$sheet];<br />
$sheetName = $eSheet-&gt;{Name};<br />
my $f1 = encode(locale_fs =&gt; $sheetName); #每次操作中文我都很纠结，还得各种转码<br />
open FH_out ,&quot;&gt;$f1.csv&quot; or die &quot;error open &quot;;<br />
next unless (exists ($eSheet-&gt;{MaxRow}) and (exists ($eSheet-&gt;{MaxCol})));<br />
foreach my $row ($eSheet-&gt;{MinRow} .. $eSheet-&gt;{MaxRow}) {<br />
foreach my $column ($eSheet-&gt;{MinCol} .. $eSheet-&gt;{MaxCol}) {<br />
if (defined $eSheet-&gt;{Cells}[$row][$column])<br />
{<br />
print FH_out $eSheet-&gt;{Cells}[$row][$column]-&gt;Value . &quot;,&quot;;<br />
} else {<br />
print FH_out &quot;,&quot;;<br />
}<br />
}<br />
print FH_out &quot;\n&quot;;<br />
}<br />
close FH_out;</p>
<p>}<br />
exit;</p>
<p>[/perl]</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bio-info-trainee.com/851.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perl用cpan在linux上面安装模块</title>
		<link>http://www.bio-info-trainee.com/540.html</link>
		<comments>http://www.bio-info-trainee.com/540.html#comments</comments>
		<pubDate>Mon, 30 Mar 2015 08:17:38 +0000</pubDate>
		<dc:creator><![CDATA[ulwvfje]]></dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[cpan]]></category>
		<category><![CDATA[模块]]></category>

		<guid isPermaLink="false">http://www.bio-info-trainee.com/?p=540</guid>
		<description><![CDATA[之所以要讲一下这个，是因为trinity这个软件居然需要perl的模块才能使用， &#8230; <a href="http://www.bio-info-trainee.com/540.html">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>之所以要讲一下这个，是因为trinity这个软件居然需要perl的模块才能使用，所以我必须自己安装几个模块。<strong>此教程可能过期了，请直接看最新版</strong>(<a href="http://www.bio-info-trainee.com/2451.html" target="_blank">perl模块安装大全</a>)</p>
<p>前提是要有root权限，否则只能自己下载perl模块自己解压安装了。<span id="more-540"></span></p>
<p>首次使用需要perl -MCPAN -e shell</p>
<p>以后只需要cpan即可</p>
<p>安装只有两个步骤，查询或者安装</p>
<p>查询：cpan[1]&gt; d /模块名字或者部分名字/</p>
<p>查询结果中会给出所有含有模块名字或者部分名字的模块，选择您所需要的模块进行下载</p>
<p>&nbsp;</p>
<p>下载安装：cpan[1]&gt;  install  模块名字</p>
<p><a href="http://www.bio-info-trainee.com/wp-content/uploads/2015/03/Perl用cpan在linux上面安装模块313.png"><img class="alignnone size-full wp-image-541" src="http://www.bio-info-trainee.com/wp-content/uploads/2015/03/Perl用cpan在linux上面安装模块313.png" alt="Perl用cpan在linux上面安装模块313" width="554" height="333" /></a></p>
<p>install LWP  同时会自动安装很多依赖的模块，非常方便。</p>
<p>&nbsp;</p>
<p>或者查找bioperl模块</p>
<p><a href="http://www.bio-info-trainee.com/wp-content/uploads/2015/03/Perl用cpan在linux上面安装模块329.png"><img class="alignnone size-full wp-image-542" src="http://www.bio-info-trainee.com/wp-content/uploads/2015/03/Perl用cpan在linux上面安装模块329.png" alt="Perl用cpan在linux上面安装模块329" width="554" height="240" /></a></p>
<p>install   CJFIELDS/Bundle-BioPerl-2.1.9.tar.gz</p>
<p>再输入上面这个命令，就可以安装啦</p>
<p>Running make install</p>
<p>Installing /usr/local/share/perl/5.18.2/Bundle/BioPerl.pm</p>
<p>Installing /usr/local/man/man3/Bundle::BioPerl.3pm</p>
<p>Appending installation info to /usr/local/lib/perl/5.18.2/perllocal.pod</p>
<p>CJFIELDS/Bundle-BioPerl-2.1.9.tar.gz</p>
<p>/usr/bin/make install  -- OK</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>之前运行Trinity是会报错的，说缺少一个模块，现在就可以用了</p>
<p>但是如果把Trinity那个程序拷贝到其它目录，还是会报错</p>
<p>Can't locate COMMON.pm in @INC (you may need to install the COMMON module) (@INC contains: /usr/local/bin/PerlLib /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at /usr/local/bin/Trinity line 14.</p>
<p>BEGIN failed--compilation aborted at /usr/local/bin/Trinity line 14.</p>
<p>因为Trinity这个软件本身放了几个perl模块在它自己的目录下面，不能把它们分开！</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bio-info-trainee.com/540.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
