I. Definition
Functions can be divided into system functions and user functions. A subroutine is a separate piece of code that performs a special task, which makes it easy to reduce duplicate code and make the program readable. In Perl, subroutines
Method one (not using modules, by Agonyr)
Copy Code code as follows:
#!/usr/bin/perl-w
Use strict;
My @seq = ("A", "T", "C", "G");
my $length = 10000;
undef my%hash;
$hash {"A"} = Int ($length * 0.3);
$hash {"
This allows some characters (especially wide characters) to be displayed incorrectly, which is no longer utf-8 format.
Solution:When you open the output file, you specify the encoding format, and there is no garbled situation after the output file
Perl Debug
[From] http://goldenink.com/perl/perldebug.html
The concepts of the Perl debug is familiar to most programmers. Trace, breakpoint, and conditional breakpoint (watchpoint) is effective means with which to find problems in your Perl SC Ript.
The existing file Test.txt, the content is: "123\n456"1, Open Text test.txt#!/usr/bin/perlOpen D, "test.txt";D is the file handle, pointing to the open file2, read text line by row Test.txt#!/usr/bin/perlOpen D, "while () {Print $_;}Close D;Results:
Steps Summary:1. Download the installation file2. Click on the file to install3. Setting Environment variables4. Test whether the installation was successfulExample of installing active Perl 5.22 on a Win8Details:1. Download the installation file1)
In the Perl language, there are only two forms of strings:(1) Byte stream string: resolves to a single byte string, regardless of the content or encoding of the string.(2) Character stream string: According to UTF8 encoding scheme, the byte stream
The question is, how does the program run with the standard input using the "However, in the process of running the program to get input from the keyboard.Because/dev/tty is the console for the current process, it STDIN is entered for the current
1.hash mode access. %env key is the environment variable name, value is the environment variable2. Call the ENV module. Use Env QW (PATH);Print "path is $ENV {path}\n";This code creates (or overwrites) the Perlvar variable in the environment.$ENV
It is quite disgusting to use Perl for web development and debug debugging information output. Unlike PHP, it can directly echo to the page, or eclipse directly breakpoint debugging. Perl can only output the information you want to display in a
Usage: Select filehandle
Returns the selected file handle. You can set the current file handle to the default output. the default output of "write" and "print" without the specified handle is set to filehandle 2. variables related to the output
. Represents any single character and does not match the linefeed.* Is A quantizer, indicating that the previous content appears 0 to multiple times.+ It is also a quantizer, indicating that the previous content appears one to multiple times.
Perl read files
Open (file, "filename.txt ");
My $ record;
While ($ record = )
{
Print ("file record is: $ record/N ");
}
Close (File );
Perl file writing
Overwrite
Open (file, "> filename.txt ");
Syswrite (file, "This is My Write File
(1) set external tools
Select advanced> tool Configuration
Perform the following settings:
① Command line: C:/perl/bin/perl.exe "% F"
②. Working directory: % P (some people say there is a relationship between the size and I can run this
In item 116 of the book "valid Perl", author demonstrates how to use unpack to process fix-width columnar data.I tried to write a toy code for practice, and found two things need to note.
First thing, must use single quote 'before and after the
Note: This is an article on the Internet ~ (Post http://www.weskers.com/tag/debug)
Next let's go to the topic. to configure a graphical debug environment in win, you must first have a Perl (Khan, required) with environment variables.
Run the
I haven't posted it for a long time. Today I am posting about the common functions of the lwp module.
(1) The most important function is to view the webpage source file. We can view the webpage source file through the existing methods of Perl, and
Requirement: colleagues report that the server is difficult to log on to the terminal every afternoon and does not respond for a long time.After investigation, the shengteng terminal binding program and each terminal have a large number of invalid
Http://hi.baidu.com/jackywdx/blog/item/35bb33daedb414dfb7fd4867.html
LWP: Simple Function
1. How to use this module in Perl?
Use LWP: Simple;
2. How to get a page content?
My $ content = get ('HTTP: // www.yahoo.com.cn ');
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.