⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 perlhack.1

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 1
📖 第 1 页 / 共 5 页
字号:
thrown away by someone in the future?.IP "Is there enough documentation?" 4.IX Item "Is there enough documentation?"Patches without documentation are probably ill-thought out orincomplete.  Nothing can be added without documentation, so submittinga patch for the appropriate manpages as well as the source code isalways a good idea..IP "Is there another way to do it?" 4.IX Item "Is there another way to do it?"Larry said "Although the Perl Slogan is \fIThere's More Than One Wayto Do It\fR, I hesitate to make 10 ways to do something".  This is atricky heuristic to navigate, though\*(--one man's essential addition isanother man's pointless cruft..IP "Does it create too much work?" 4.IX Item "Does it create too much work?"Work for the pumpking, work for Perl programmers, work for moduleauthors, ...  Perl is supposed to be easy..IP "Patches speak louder than words" 4.IX Item "Patches speak louder than words"Working code is always preferred to pie-in-the-sky ideas.  A patch toadd a feature stands a much higher chance of making it to the languagethan does a random feature request, no matter how fervently argued therequest might be.  This ties into \*(L"Will it be useful?\*(R", as the factthat someone took the time to make the patch demonstrates a strongdesire for the feature..PPIf you're on the list, you might hear the word \*(L"core\*(R" bandiedaround.  It refers to the standard distribution.  \*(L"Hacking on thecore\*(R" means you're changing the C source code to the Perlinterpreter.  \*(L"A core module\*(R" is one that ships with Perl..Sh "Keeping in sync".IX Subsection "Keeping in sync"The source code to the Perl interpreter, in its different versions, iskept in a repository managed by a revision control system ( which iscurrently the Perforce program, see http://perforce.com/ ).  Thepumpkings and a few others have access to the repository to check inchanges.  Periodically the pumpking for the development version of Perlwill release a new version, so the rest of the porters can see what'schanged.  The current state of the main trunk of repository, and patchesthat describe the individual changes that have happened since the lastpublic release are available at this location:.PP.Vb 2\&    http://public.activestate.com/pub/apc/\&    ftp://public.activestate.com/pub/apc/.Ve.PPIf you're looking for a particular change, or a change that affecteda particular set of files, you may find the \fBPerl Repository Browser\fRuseful:.PP.Vb 1\&    http://public.activestate.com/cgi\-bin/perlbrowse.Ve.PPYou may also want to subscribe to the perl5\-changes mailing list toreceive a copy of each patch that gets submitted to the maintenanceand development \*(L"branches\*(R" of the perl repository.  Seehttp://lists.perl.org/ for subscription information..PPIf you are a member of the perl5\-porters mailing list, it is a goodthing to keep in touch with the most recent changes. If not only toverify if what you would have posted as a bug report isn't alreadysolved in the most recent available perl development branch, alsoknown as perl-current, bleading edge perl, bleedperl or bleadperl..PPNeedless to say, the source code in perl-current is usually in a perpetualstate of evolution.  You should expect it to be very buggy.  Do \fBnot\fR useit for any purpose other than testing and development..PPKeeping in sync with the most recent branch can be done in several ways,but the most convenient and reliable way is using \fBrsync\fR, available atftp://rsync.samba.org/pub/rsync/ .  (You can also get the most recentbranch by \s-1FTP\s0.).PPIf you choose to keep in sync using rsync, there are two approachesto doing so:.IP "rsync'ing the source tree" 4.IX Item "rsync'ing the source tree"Presuming you are in the directory where your perl source residesand you have rsync installed and available, you can \*(L"upgrade\*(R" tothe bleadperl using:.Sp.Vb 1\& # rsync \-avz rsync://public.activestate.com/perl\-current/ ..Ve.SpThis takes care of updating every single item in the source tree tothe latest applied patch level, creating files that are new (to yourdistribution) and setting date/time stamps of existing files toreflect the bleadperl status..SpNote that this will not delete any files that were in '.' beforethe rsync. Once you are sure that the rsync is running correctly,run it with the \-\-delete and the \-\-dry\-run options like this:.Sp.Vb 1\& # rsync \-avz \-\-delete \-\-dry\-run rsync://public.activestate.com/perl\-current/ ..Ve.SpThis will \fIsimulate\fR an rsync run that also deletes files notpresent in the bleadperl master copy. Observe the results fromthis run closely. If you are sure that the actual run would deleteno files precious to you, you could remove the '\-\-dry\-run' option..SpYou can than check what patch was the latest that was applied bylooking in the file \fB.patch\fR, which will show the number of thelatest patch..SpIf you have more than one machine to keep in sync, and not all ofthem have access to the \s-1WAN\s0 (so you are not able to rsync all thesource trees to the real source), there are some ways to get aroundthis problem..RS 4.IP "Using rsync over the \s-1LAN\s0" 4.IX Item "Using rsync over the LAN"Set up a local rsync server which makes the rsynced source treeavailable to the \s-1LAN\s0 and sync the other machines against thisdirectory..SpFrom http://rsync.samba.org/README.html :.Sp.Vb 5\&   "Rsync uses rsh or ssh for communication. It does not need to be\&    setuid and requires no special privileges for installation.  It\&    does not require an inetd entry or a daemon.  You must, however,\&    have a working rsh or ssh system.  Using ssh is recommended for\&    its security features.".Ve.IP "Using pushing over the \s-1NFS\s0" 4.IX Item "Using pushing over the NFS"Having the other systems mounted over the \s-1NFS\s0, you can take anactive pushing approach by checking the just updated tree againstthe other not-yet synced trees. An example would be.Sp.Vb 1\&  #!/usr/bin/perl \-w\&\&  use strict;\&  use File::Copy;\&\&  my %MF = map {\&      m/(\eS+)/;\&      $1 => [ (stat $1)[2, 7, 9] ];     # mode, size, mtime\&      } \`cat MANIFEST\`;\&\&  my %remote = map { $_ => "/$_/pro/3gl/CPAN/perl\-5.7.1" } qw(host1 host2);\&\&  foreach my $host (keys %remote) {\&      unless (\-d $remote{$host}) {\&          print STDERR "Cannot Xsync for host $host\en";\&          next;\&          }\&      foreach my $file (keys %MF) {\&          my $rfile = "$remote{$host}/$file";\&          my ($mode, $size, $mtime) = (stat $rfile)[2, 7, 9];\&          defined $size or ($mode, $size, $mtime) = (0, 0, 0);\&          $size == $MF{$file}[1] && $mtime == $MF{$file}[2] and next;\&          printf "%4s %\-34s %8d %9d  %8d %9d\en",\&              $host, $file, $MF{$file}[1], $MF{$file}[2], $size, $mtime;\&          unlink $rfile;\&          copy ($file, $rfile);\&          utime time, $MF{$file}[2], $rfile;\&          chmod $MF{$file}[0], $rfile;\&          }\&      }.Ve.Spthough this is not perfect. It could be improved with checkingfile checksums before updating. Not all \s-1NFS\s0 systems supportreliable utime support (when used over the \s-1NFS\s0)..RE.RS 4.RE.IP "rsync'ing the patches" 4.IX Item "rsync'ing the patches"The source tree is maintained by the pumpking who applies patches tothe files in the tree. These patches are either created by thepumpking himself using \f(CW\*(C`diff \-c\*(C'\fR after updating the file manually orby applying patches sent in by posters on the perl5\-porters list.These patches are also saved and rsync'able, so you can apply themyourself to the source files..SpPresuming you are in a directory where your patches reside, you canget them in sync with.Sp.Vb 1\& # rsync \-avz rsync://public.activestate.com/perl\-current\-diffs/ ..Ve.SpThis makes sure the latest available patch is downloaded to yourpatch directory..SpIt's then up to you to apply these patches, using something like.Sp.Vb 5\& # last="\`cat ../perl\-current/.patch\`.gz"\& # rsync \-avz rsync://public.activestate.com/perl\-current\-diffs/ .\& # find . \-name \*(Aq*.gz\*(Aq \-newer $last \-exec gzcat {} \e; >blead.patch\& # cd ../perl\-current\& # patch \-p1 \-N <../perl\-current\-diffs/blead.patch.Ve.Spor, since this is only a hint towards how it works, use CPAN-patchaperlfrom Andreas Ko\*:nig to have better control over the patching process..Sh "Why rsync the source tree".IX Subsection "Why rsync the source tree".IP "It's easier to rsync the source tree" 4.IX Item "It's easier to rsync the source tree"Since you don't have to apply the patches yourself, you are sure allfiles in the source tree are in the right state..IP "It's more reliable" 4.IX Item "It's more reliable"While both the rsync-able source and patch areas are automaticallyupdated every few minutes, keep in mind that applying patches maysometimes mean careful hand-holding, especially if your version ofthe \f(CW\*(C`patch\*(C'\fR program does not understand how to deal with new files,files with 8\-bit characters, or files without trailing newlines..Sh "Why rsync the patches".IX Subsection "Why rsync the patches".IP "It's easier to rsync the patches" 4.IX Item "It's easier to rsync the patches"If you have more than one machine that you want to keep in track withbleadperl, it's easier to rsync the patches only once and then applythem to all the source trees on the different machines..SpIn case you try to keep in pace on 5 different machines, for whichonly one of them has access to the \s-1WAN\s0, rsync'ing all the sourcetrees should than be done 5 times over the \s-1NFS\s0. Havingrsync'ed the patches only once, I can apply them to all the sourcetrees automatically. Need you say more ;\-).IP "It's a good reference" 4.IX Item "It's a good reference"If you do not only like to have the most recent development branch,but also like to \fBfix\fR bugs, or extend features, you want to diveinto the sources. If you are a seasoned perl core diver, you don'tneed no manuals, tips, roadmaps, perlguts.pod or other aids to findyour way around. But if you are a starter, the patches may help youin finding where you should start and how to change the bits thatbug you..SpThe file \fBChanges\fR is updated on occasions the pumpking sees as hisown little sync points. On those occasions, he releases a tar-ball ofthe current source tree (i.e. perl@7582.tar.gz), which will be anexcellent point to start with when choosing to use the 'rsync thepatches' scheme. Starting with perl@7582, which means a set of sourcefiles on which the latest applied patch is number 7582, you apply allsucceeding patches available from then on (7583, 7584, ...)..SpYou can use the patches later as a kind of search archive..RS 4.IP "Finding a start point" 4.IX Item "Finding a start point"If you want to fix/change the behaviour of function/feature Foo, justscan the patches for patches that mention Foo either in the subject,the comments, or the body of the fix. A good chance the patch showsyou the files that are affected by that patch which are very likelyto be the starting point of your journey into the guts of perl..IP "Finding how to fix a bug" 4.IX Item "Finding how to fix a bug"If you've found \fIwhere\fR the function/feature Foo misbehaves, but youdon't know how to fix it (but you do know the change you want tomake), you can, again, peruse the patches for similar changes andlook how others apply the fix..IP "Finding the source of misbehaviour" 4.IX Item "Finding the source of misbehaviour"When you keep in sync with bleadperl, the pumpking would love to\&\fIsee\fR that the community efforts really work. So after each of hissync points, you are to 'make test' to check if everything is stillin working order. If it is, you do 'make ok', which will send an \s-1OK\s0report to \fIperlbug@perl.org\fR. (If you do not have access to a mailerfrom the system you just finished successfully 'make test', you cando 'make okfile', which creates the file \f(CW\*(C`perl.ok\*(C'\fR, which you canthan take to your favourite mailer and mail yourself)..SpBut of course, as always, things will not always lead to a successpath, and one or more test do not pass the 'make test'. Beforesending in a bug report (using 'make nok' or 'make nokfile'), checkthe mailing list if someone else has reported the bug already and ifso, confirm it by replying to that message. If not, you might want totrace the source of that misbehaviour \fBbefore\fR sending in the bug,which will help all the other porters in finding the solution..SpHere the saved patches come in very handy. You can check the list ofpatches to see which patch changed what file and what change causedthe misbehaviour. If you note that in the bug report, it saves theone trying to solve it, looking for that point..RE.RS 4.SpIf searching the patches is too bothersome, you might consider usingperl's bugtron to find more information about discussions and

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -