Perl - ArchWiki

文章推薦指數: 80 %
投票人數:10人

The Comprehensive Perl Archive Network (CPAN) is a repository of over 250,000 software modules and accompanying documentation written in the ... HomePackagesForumsWikiBugsSecurityAURDownload Jumptocontent Namespaces PageDiscussion English expanded collapsed Views ReadViewsourceViewhistory More expanded collapsed Navigation MainpageTableofcontentsGettinginvolvedWikinewsRandompage Interaction HelpContributingRecentchangesRecenttalksNewpagesStatisticsRequests Tools WhatlinkshereRelatedchangesSpecialpagesPrintableversionPermanentlinkPageinformation Relatedarticles PerlPolicy Perlpackageguidelines mod_perl FromWikipedia: Perlisafamilyofhigh-level,general-purpose,interpreted,dynamicprogramminglanguages.ThelanguagesinthisfamilyincludePerl5andRaku(formerlyPerl6). ThePerllanguagesborrowfeaturesfromotherprogramminglanguagesincludingC,shellscript(sh),AWK,andsed.Theyprovidepowerfultextprocessingfacilitieswithoutthearbitrarydata-lengthlimitsofmanycontemporaryUnixcommandlinetools,facilitatingeasymanipulationoftextfiles.Perl5gainedwidespreadpopularityinthelate1990sasaCGIscriptinglanguage,inpartduetoitsthenunsurpassedregularexpressionandstringparsingabilities. Contents 1Installation 2Commands 3Packagemanagement 3.1pacmanandAUR 3.2CPAN.pm 3.2.1Configuringcpan 3.2.2Usageexamples 4Widgetbindings 5Tipsandtricks 5.1Improvedmodulemanagement 5.1.1cpanminus 5.1.2ucpan 5.1.3Bundle::CPAN 5.2Re-runcpanconfiguration 5.3Createnewmodule 5.3.1module-starter 6Seealso 6.1Perl5 6.2Raku 6.3CPAN 6.4Tutorials 6.5Miscellaneous Installation Installtheperlpackage. Commands ThePerllanguageinterpreter: $perl Perlbugreporting: $perlbug LookupthePerldocumentationinPODformat: $perldoc SendthePerlauthorsandmaintainersathankyoumessage: $perlthanks Packagemanagement TheComprehensivePerlArchiveNetwork(CPAN)isarepositoryofover250,000softwaremodulesandaccompanyingdocumentationwritteninthePerlprogramminglanguagebyover12,000contributors. CPANisalsothenameofaPerlmodule,CPAN.pm,whichisusedtodownloadandinstallPerlsoftwarefromtheCPANarchive. pacmanandAUR AnumberofpopularCPANmodulesareavailableaspackagesintheArchrepositories.TherearefurthermodulesavailableintheAUR. CPAN.pm TheCPAN.pmmoduleisincludedwithPerl.ItcanbeusedinteractivelyfromtheshellorinPerlscripts. Configuringcpan Beforefirstuse,themoduleneedstobeconfigured.Thisisdoneinteractivelyfromtheshellwith(someoutputomitted): $cpan CPAN.pmrequiresconfiguration,butmostofitcanbedoneautomatically. Ifyouanswer'no'below,youwillenteraninteractivedialogforeach configurationoptioninstead. Wouldyouliketoconfigureasmuchaspossibleautomatically?[yes] Automatedconfigurationwillsuitmostusers.Answeringyes,theconfigurationwillcontinuewith: Toinstallmodules,youneedtoconfigurealocalPerllibrarydirectoryor escalateyourprivileges.CPANcanhelpyoubybootstrappingthelocal::lib moduleorbyconfiguringitselftouse'sudo'(ifavailable).Youmayalso resolvethisproblemmanuallyifyouneedtocustomizeyoursetup. Whatapproachdoyouwant?(Choose'local::lib','sudo'or'manual') [local::lib] Ifyouwantcpantoinstallmodulesinyourhomedirectorychooselocal::lib.Toinstallthemsystem-widechoosesudo.Choosingsudotheconfigurationends: Autoconfigurationcomplete. commit:wrote'/home/username/.cpan/CPAN/MyConfig.pm' Choosingthelocal::liboptionwillresultinadditionmodulesbeinginstalled. Choosingnottouseautomatedconfigurationallowstheusertosetcpanoptionsinteractivelyintheshell.Thetablebelowshowssomeoptionnameswithabriefdescriptionanddefaultvalue.Moredetailedinformationisdisplayedforeachoptionduringconfiguration. Name Description Default cpan_home CPANbuildandcachedirectory $HOME/.cpan keep_source_where Downloadtargetdirectory $HOME/.cpan/sources build_dir Buildprocessdirectory $HOME/.cpan/build prefs_dir Customizablemodulesoptionsdirectory $HOME/.cpan/prefs build_cache Cachesizeforbuilddirectory 100MB cleanup_after_install Removebuilddirectoryaftersuccessfulinstall No shell Preferredshell /bin/bash halt_on_failure Haltonfailure No colorize_output Turnoncoloredoutput No histfile Historyfilelocation $HOME/.cpan/histfile histsize Historyfilesize 100lines Theconfigurationfile$HOME/.cpan/CPAN/MyConfig.pmcanbeeditedwithyourtexteditorofchoice. Usageexamples Tosimplyinstallamodulespassthemasparameterstocpan(multiplemodulenamesareseparatedbyspaces): $cpanAcme::MetaSyntactic Thefollowingexamplesareallinthecpaninteractiveshell,startedwith: $cpan Displayinformationonamodule: cpan[1]>mAcme::MetaSyntactic Reading'/home/username/.cpan/Metadata' DatabasewasgeneratedonFri,08Dec201702:17:03GMT Moduleid=Acme::MetaSyntactic CPAN_USERIDBOOK(PhilippeBruhat(BooK)) CPAN_VERSION1.014 CPAN_FILEB/BO/BOOK/Acme-MetaSyntactic-1.014.tar.gz INST_FILE(notinstalled) ViewmoduleREADME: cpan[2]>readmeAcme::MetaSyntactic Acme::MetaSyntactic-Themedmetasyntacticvariables DESCRIPTION Whenwritingcodeexamples,it'salwayseasyatthebeginning: my$foo="bar"; $foo.="baz";#barbaz ... Installamodule: cpan[3]>installAcme::MetaSyntactic Widgetbindings Thefollowingwidgettoolkitbindingsareavailable: gtk2-perl—GTK2bindings http://gtk2-perl.sourceforge.net/||gtk2-perl perl-gtk3—GTK3bindings https://metacpan.org/release/Gtk3||perl-gtk3 Perl/TK—Tkbindings https://search.cpan.org/dist/Tk/||perl-tk perlqt—Qtbindings https://github.com/KDE/perlqt||notpackaged?searchinAUR wxPerl—wxWidgetsbindings http://www.wxperl.it/||perl-wxAUR Prima—aperlmultiplatformgraphictoolkit https://metacpan.org/release/Prima||perl-primaAUR TousethesewithPerl,youmayneedtoinstalltheassociatedwidgetkits. Tipsandtricks Improvedmodulemanagement cpanminus cpanminusextendsmodulemanagementandaimstobezeroconfigurationandintegrateswithlocal::db. Installthecpanminuspackage. Thecpanminusdocumentationgivesexamples. ucpan ucpanisanice,fullyautomaticupdaterforCPANmodules(especiallyinstalledinlocal-lib).Toinstalluse: cpanApp::ucpan Bundle::CPAN InstallingtheBundle::CPANdistributionwilladdalotofnicefunctionalitytoCPAN.pm. $cpanBundle::CPAN Re-runcpanconfiguration $cpan cpan[1]>oconfinit Createnewmodule module-starter Module::Starterhelpsyoucreateyournewmodule...Install: cpanmModule::Starter Usage: module-starter--module=App::foobar--author="Mynamehere"[email protected] Thisgoingtocreateyourmoduletree... Note:Option--mbcreatemodulewhichwilluseModule::Build.Thenextpartassumesthatyouareusingthismodule. Toadddependiences,putmodule_name=>version_or_0inside$builder->requiresinfileBuild.PL Toinstallrequireddependiencesforyourproject,runinsideApp-foobarfolder: cpanm--installdeps. Toskipgitfolder,addunder$builder add_to_manifest_skip=>['.git'], Addingscriptscanbydonelikethis: mkdirbin touchbin/foobar Torunthisscript: perl-Ilibbin/foobar Youcanchangeyourprojectversionhere:lib/App/foobar.pm Toinstallyourmodulerunthiscommandinmodulerootfolder: cpanm. Seemoreon:cpanpage,cookbook Seealso Perl5 ThePerlProgrammingLanguage(Perlhomepage) Wikipedia:Perl PerlTutorials perl(1perl) perldoc(1perl) Raku TheRakuProgrammingLanguage Wikipedia:Raku_(programming_language) GettingstartedwithPerl6 Rakudo wikipedia:Rakudo perl6(1) CPAN ComprehensivePerlArchiveNetwork wikipedia:CPAN CPAN/CPANShell/CPANPLUSQuickReferenceGuide Tutorials Tutorialsatperldoc cpanconfiguration PerlMonksTutorials Miscellaneous Perl5vs6 Retrievedfrom"https://wiki.archlinux.org/index.php?title=Perl&oldid=743514" Category:ProgramminglanguagesHiddencategory:Pageswithmissingpackagelinks



請為這篇文章評分?