Ecosyste.ms: Repos
An open API service providing repository metadata for many open source software ecosystems.
GitHub / szabgab / perlmaven.com
The source files of the Perl Maven articles
JSON API: https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/szabgab%2Fperlmaven.com
Stars: 66
Forks: 110
Open Issues: 8
License: None
Language: Perl
Repo Size: 21.5 MB
Dependencies:
538
Created: about 11 years ago
Updated: 9 months ago
Last pushed: about 2 months ago
Last synced: 25 days ago
Funding links: https://github.com/sponsors/szabgab, https://patreon.com/szabgab, https://paypal.me/szabgab
Files
Loading...
Readme
Loading...
Dependencies
- Aexplica *
- Afinaldecontas ,avari
- Aideiatodado <b>escopo<
- Aoutra *
- Asolu *
- Dequalquerforma ,normalmentevoc
- Enquantoqueamensagemdeerroest *
- Eoerro *
- Esteerro *
- Eun *
- Globalsymbol *
- Issogeraumerroemtempodecompila *
- Muitoprovavelmenteeleaindan *
- NoPerl ,umblococercadoporchavesgeraumescoponovo.
- Obviamente ,sen
- Oerroqueobtemos *
- Oproblema *
- Oqueest *
- Ouent *
- Ouseja ,voc
- Outrasitua *
- Paraeliminaroerroacimavoc *
- Primeiro ,h
- Qualforma *
- Sefosseindentadoalgunsespa *
- Umar *
- if *
- issofuncionariatamb *
- my *
- oquegerasurpresaemmuitaspessoas ,especialmentequandoelasest
- ouent *
- print *
- usestrict *
- usewarnings *
- Globalsymbol *
- Theother *
- if *
- my *
- print *
- usestrict *
- usewarnings *
- DasGrundprinzipdes <b>Scopes<
- DasProblemist ,dassdieVariable<hl>
- Dasbedeutet *
- Dasistf *
- DasistnichtderInhaltdiesesArtikels.DerSinnbestehtdarin ,Anf
- Dasw *
- Desweiteren ,wennwirvergessen<hl>my<
- DieErkl *
- DieFehlermeldung ,diewirbekommen,istdiegleichewieoben
- DieL *
- Dieandere *
- Dieschnelle *
- DieseFehlermeldungwirdvon <b>usestrict<
- Diesl *
- EinAnf *
- EinandererFall ,denichoftvonAnf
- Globalsymbol *
- Ichwei *
- InPerlwirdeinScopedurcheinenBlockinnerhalbgeschweifterKlammerngebildet. *
- MitanderenWorten *
- ObwohldieFehlermledungrichtigist ,istsief
- Perl-Anf *
- Spracheverstehenzulassen ,wasdieseFehlermeldungbedeutet.
- UmdieobigeFehlermeldungzuunterdr *
- Unabh *
- Unddas ,obwohlsie<hl>
- UnddieFehlermeldungist *
- Wasmit <hl>my<
- WelchenWegDueinschlagenwirst ,istvondertats
- WenndieZeilemiteinpaarLeerzeichenodereinemTabulatorzeichen-wieimn *
- ZuersteinmalgibteshiereinvisuellesProblem.DieEinr *
- ausgeben. *
- diezuvornichtmit *
- eineVaraiblevollst *
- geschwungenerKlammern *
- if *
- my *
- nichtgelernt ,was
- oderdieVariableau *
- odervollst *
- print *
- sie ,wasexpliziterseinsollte,alsein
- syntaktischrichtigenL *
- undm.E.n.sehrirref *
- usestrict *
- usewarnings *
- Abeginnerwillhopefullystarteveryscriptwith <b>usestrict<
- Afteralltheydeclared <hl>
- Andtheerroris *
- AnothercaseIoftenseewithbeginnerslookslikethis *
- Explainingwhat <hl>our<
- First ,thereisalittlevisualproblem.Theindentationof<hl>my
- Globalsymbol *
- Idon *
- Ifitwasindentedafewspacesoratabtotheright ,asinthenextexample,
- InPerl ,ablockenclosedincurlybracescreatesascope.
- Inanycase ,normallyyouwouldnotdriveacarwithoutthesafetybelt,wouldyou
- Inotherwords ,the<hl>if
- Nordotheyknowwhatcanbemoreexplicitthan *
- Ofcourse ,ifweforgettoremovethe<hl>my<
- Thatis ,oneneedsto<b>declarethevariableusingmybeforeitsfirstuse.<
- Theerrorwegetisthesameasabove *
- Theexplanationinthedocumentationis *
- Theother *
- Theproblemis ,thatthevariable<hl>
- Thequicktranslationwouldbe *
- Thesolutioniseithertocallthe <hl>print<
- Thewholeideaof <b>scope<
- Theyhaveprobablynotlearnedwhatpackagesare. *
- Thiserrorisgeneratedby <b>usestrict<
- Thisgeneratesacompile-timeerrorifyouaccessavariablethatwasn *
- Thisiscalled <ahref=
- Toeliminatetheaboveerrormessageoneneedstowrite *
- Whatisdeclaredinsideusing <hl>my<
- Whichwayyoudowilldependontheactualtask.Thesearejustthesyntacticallypossiblecorrectsolutions. *
- Whiletheactualerrormessageiscorrect ,
- andIMHOverymisleadingerrormessageofPerl.Atleastforbeginners. *
- andwillprobablylearnabout <b>my<
- declaredvia *
- fullyqualifyavariablenameislefttoanotherpost. *
- if *
- my *
- ofthispost.Thepointistohelpbeginnersunderstandintheirownlanguagewhatdoes *
- ortodeclarethevariableoutsidetheblock *
- print *
- thatwouldworkbutthiscodewillgeneratea *
- thenwegeta <ahref=
- thesourceoftheproblemmightbemoreobvious *
- thiserrormessagemean. *
- thisislittleuseforthebeginnerPerlprogrammer. *
- usestrict *
- usewarnings *
- warning. *
- whichissurprisingformanypeople.Especiallywhentheystarttheircoding. *
- AwhileagoI *
- Inanycase ,letmepublishhereafewnotesImadeasminimalrequirements.
- IncaseI ,orsomeoneelsewillliketopickuptheidealateron.
- SincethentherewasalsoasmallmovementagainshavingasharedbloggingplatformforPerl ,somaybeIshouldnotgetinthisproject.
- andIwouldnotbeabletogetenoughtpeoplesupportingit.Theymightberight. *
- teachingtooltoshowvarioustechnologies.Iaskedanumberofpeopleaboutit.Manysaidtheythinkitwouldbetoobigaproject *
- AddtheBUILD_REQUIRESentrytotheMakefile.PL *
- AlsochangetheVERSIONnumberinCalc.pmtobe0.02andpackagethemoduleagain *
- AsDavidGolden *
- BUILD_REQUIRES =>
- IfyouchangetheMath *
- Inordertocreatethedistributionopenaterminalandcdto *
- IstartedtowriteanarticleexplaininghowtopackageaPerlmodule *
- Let *
- Likethis *
- MANIFEST *
- META.json *
- META.yml *
- Makefile.PL *
- Math-Calc *
- Math-Calc-0.01.tar.gz *
- NAME =>
- PREREQ_PM =>
- Socreateasubdirectorycalled *
- Sofornow ,I
- ThatwillensurethattheTest *
- The <b>MANIFEST<
- TheMakefile.PLfileshouldlooklikethis *
- Thefirst3entriesarethefileswereallyhave.ThetwoMETAfilesare *
- Therearealotofotherimprovementsonecanandshouldmakebutletmeshowyoujustonething. *
- Thereareanumberofotherthingsyoushouldtakecareof ,suchasaddingaREADMEfile,keepinganddistributing
- ThevalueoftheNAMEfieldwillbeusedasthefilenameforthedistribution. *
- TheversionnumberistakenfromtheCalc.pmfileandforthistoworkwe *
- ThisisthecodeyouhaveintheCalc.pmfile *
- Thistimerunningthetestsbeforecreatingthedistribution. *
- Thiswillgenerateanumberofhelperfilesandtheendresult *
- UpdatetheMANIFESTfiletoincludethet *
- VERSION_FROM =>
- Whileitisnotastrictrequirementtoaddanddistributeunit-testswith *
- WriteMakefile *
- Youcanreadmoreon <ahref=
- YoucanuploadittoPAUSEordistributeittoyourclients. *
- Youneedtocreateadirectory ,let
- aChangesfile.MaybehavingaMANIFEST.SKIPtohandletheMANIFESTfile.Youshouldalsoaddcopyrightandlicensing *
- aboutthemodule. *
- afilecalledt *
- allthepartsofthedistributions.InthatdirectoryputtheCalc.pm *
- andaMANIFESTfileintheMath-Calcdirectory *
- buildthesmallestpossiblebutstillsanepackage.Laterwecango *
- butitgottoolonganddetailed.Let *
- fileinthelib *
- generatedwhenthedistributioniscreated.TheycontainMETAinformationabout *
- goingtobeautomatically *
- informationtoyourmodule.Therearealsootherpackagingtoolsbutallthiswillbepartofanotherpost. *
- inmoredetailsandseealternativeways. *
- isMath *
- isonlyavailableinrelativelyrecentversionsofExtUtils *
- lib *
- likethis *
- make *
- makedist *
- maketest *
- needtoadda <hl>
- our *
- packageMath *
- perlMakefile.PL *
- prerequisitesintheMakefile.PL.Let *
- prerequisitesinthePREREQ_PMhash. *
- return *
- shouldbethecontent *
- subadd *
- theMath-Calcdirectoryandtype *
- thePREREQ_PMkeywithkey-valuepairs.Thekeysarethemodulenames ,thevaluesaretheminimum
- use5.008 *
- useExtUtils *
- useTest *
- use_ok *
- usestrict *
- usewarnings *
- versionnumbers. *
- willbeinstalledbeforethetestsarerunbytheinstaller. *
- yourcode ,peoplearereallyexpectingtoseethosetests.
- yourpackage.OnCPANtheyareusedbyvarioustoolstodisplayinformation *
- Add <hl>useCarp
- Bydefaultitisfalse ,butyoucansetittoanytruevalue.
- Callingtheconstructorwithavaluefor *
- DONE *
- Earlierwesawhowto <ahref=
- Foo *
- Howcanwemakesuretheattributeisalwaysset *
- IcheckeditagainwithMooversion2.000000andnowIgotthefollowingerror *
- Ifnow ,someonepassed<b>undef<
- Ifwenowrun <hl>perlprogramming.pl<
- Ifwethentrytoprintitwegeta <ahref=
- Ifyouincluded <b>useCarp
- Inanycasethereisatoolthatwecanuseforsometemporaryimprovement *
- Ineithercaseswegetthesame <ahref=
- Inthescriptwhereweusetheclass ,wecreateanobjectwithoutpassinganyvaluetothe
- Inthesecondlineoftheexceptionwecanseethepointinourcode *
- Inthisarticleyou *
- Let *
- Missingrequiredarguments *
- Ofcourse ,onemightpass<ahref=
- OfcourseifthecodeusingthePersonclassisabitmorecomplex ,likeinthenextexamples
- Person *
- Sub *
- The <hl>required<
- ThePersonclasshasasingleread-writeattributecalled *
- Thisisthe <hl>programming.pl<
- Thisisthe <hl>Person.pm<
- ThisistheerroryougetfromMoo1.002000 *
- Thistimetheexceptionwilllooklikethis *
- Useofuninitializedvalueinsayatprogramming.plline7. *
- Wecanavoidthisbyadding <ahref=
- Wecansetittobea <b>required<
- Wewillhaveahardertimenoticingthesourceoftheproblem ,whichisin
- andwhilemyfixwasnotaccepted ,itseemstherewillbesomeimprovementinalaterversionofMoo.
- bar *
- beginningofthescript *
- butthecodekeepsrunning *
- eitherbymistake *
- followingexception *
- foo *
- generatingtheexpectedoutput *
- hasname =>
- inwhichthe4thlinefromthetopistheonerevealingtherealsourceoftheerror *
- is =>
- isa =>sub
- isacheckfor *
- main *
- my *
- new *
- orevenonpurpose *
- packagePerson *
- required =>1,
- run <hl>perl
- say *
- subbar *
- subfoo *
- subget_name *
- thentheerrormessagewillbebiggeraswegetthefullstacktracefromthe *
- thesecondlineoftheoutput. *
- thevalueisalways ,atleast<b>defined<
- tosetup <ahref=
- use5.010 *
- useMoo *
- usePerson *
- usestrict *
- usewarnings *
- wherewemadetheproblematiccall. *
- Beforegoingfurtherthoughtwothings *
- Ifperlcannotfindtherightfileinanyofthedirectoriesitwillthrowanexception *
- Ifyou <hl>requireMath
- Ifyou *
- Ifyourequireamodulethathasadouble-coloninitsname ,forexample<hl>Math
- Note ,inbothcasesthe<hl>.<
- Nowyouknow <ahref=
- Thecontentof <hl>
- Thefirstoneitfindswillbeloadedintomemory.Sotheremightbeseveralsuchfilesinthedirectorieslistedin <hl>
- Whenyouwrite <hl>requireCalc
- Youhaveprobablyalsoseenmoduleswithoneormoredouble-colonpairsbetweennames.Sonotonly <hl>Calc<
- YouprobablyhavealreadyusedmodulesinPerlandyouhaveprobablyusedthe <hl>use<
- afilecalled <hl>Clever.pm<
- butperlwillfindthefirstoneanddisregardtherest. *
- called <hl>Math<
- calls <hl>require<
- fileinthepreviousexample *
- forafilecalled <hl>Calc.pm<
- ifthemoduleisinthecurrentdirectory ,perlwillfindit.Ontheotherhand,ifthemoduleisinthe<hl>lib
- in <hl>
- modules.Don *
- orina <ahref=
- seethelistofdirectories.ForexampleonOSXIgotthis *
- thenperlwon *
- wechangeitto <ahref=
- Asitturnsoutthereisa <ahref=
- Beingexplicitaboutwhatyouimportcangreatlyreducethisrisk ,andthemaintenanceprogrammer
- HelloWorld *
- Hereyoucanseeitinactionwhileusingthe <hl>single
- Ifyourunthisscript ,youwillseeitworks
- Ifyouusethedefaultimportofseveralproceduralmodulesthatallexportmanyfunction ,youmightendupimportingtwodifferentfunction,
- InthosecasesitisahugehelptohaveaPerl *
- Inwhichcaseyouusesomeoftheirfunctionsasfunction. *
- ModulesinPerlareeither *
- Ofcourse ,Iknowwhenyouhavetomakesomequickchangestoapieceofcode,andforsomereasonweare
- Sohowtomakesureyoudon *
- Subroutine *
- Theeasiestwaytothatistomakethereallylittleeffortofexplicitlyimportingthefunction. *
- Themoduleweareusingisarathersimplemodulethatusesthe <hl>import<
- Thescriptthatusesthemodule ,cleverlynamed
- Thisisonewayto <ahref=
- Whilethereisacertainlevelofdangerofimportingthesamefunctionnametwice ,Ithinkthemuchbiggerissue
- alwaysaskedtodoiturgently ,youwillforgettodothis.Icertainlywould.
- arrayusebythat <ahref=
- butafteryouinstallit ,youcanuseiteitheronthecommandlineorbyenablingitinthe<hl>.perlcriticrc<
- differentmodules ,itwillbeagreathelptobeabletoeasilylocatethesourceofthe
- doingdifferentthings ,buthavingthesamename.Inwhichcaseyouwillseeaseeminglyunpredictablebehaviorinwhichcasetheorder
- isthedocumentativevalueofimportingfunctionsexplicitly.When2yearsafteryouwrotethissomeoneneedsto *
- metodothis2-secondlongtask. *
- ofimportwilldecidewhichfunctionisinuse. *
- ortheyare <ahref=
- readandunderstandthecodeofthe *
- thatrequiresexplicitimportingoffunctions. *
- thatthefunctionisexported *
- whereyoulive *
- 1.Wecanfirstcreatealistoffilesinthegivendirectorystructureandthencomparethatlist *
- 2.Foreachexpectedfilewecansearchinthedirectorytree. *
- AfewdaysagooneofthereaderssentmearequestthatI *
- Butidon *
- Couldyoupleaseexplainhowwecandothis. *
- Eachfolderhassome.Pdffile. *
- FirstIincludethee-mailIreceived ,thenI
- Firstofall ,IthinkFooBarcommendableforbothcreatingtheasciiartofthedirectorystructure
- Firstweasktheuserforthenameoffilewiththeexpectedlist. *
- FolderStructureislikethis. *
- FooBar *
- Herewehaveaninputfilelistinganumberoffiles *
- HiGabor ,
- IamnewtoPerl.Iwanttotestfilesinadirectoryalsosubdirectoryinwindowsplatform. *
- Iamwaitingforyourmail.Thanksinadvance. *
- Ifitwasnotinthehashweaddittothereportfile. *
- Ihavelistofpdffile *
- IreplacedthenamewithFooBar ,tokeeptheinformationprivate.
- Let *
- NowIamcopyingallpdffileintoseparatefolderbymanually *
- Regards *
- Scriptwhichiused *
- Thatwilldisregardcaseforall3letters. *
- The <hl>File
- Thelaststepinpreparingtheexistinglistoffilesforfurtherinspectioniscreatingahashcalled <hl>
- Thelower-casingisimportantonWindowsastherethefilenamesarecaseinsensitive *
- Then ,evenbeforecollectingthefilenamesweopenedthefilewiththelistofexpected
- TheonlyissuemightbethatonWindowsthefilenamesarecaseinsensitiveandIthinkthewild-card *
- Thisapproachrequiresonlyonefile-nameatatimeinthememory ,butwillrequireustotraversethe
- Thishashwillhelpuseasilycheckifafilewasfoundinthedirectorystructure. *
- Wealsocalled <hl>lc
- Wecangointwomaindirections. *
- Wegoovertheentriesintheinputfile ,<hl>chomp<
- Weneedtogeneratethesubsetoffilesfromthelistingthatcannotbefoundinthedirectorystructure. *
- a.pdf *
- afterwecalled <hl>basename
- andadirectorystructure. *
- andthefilewherewecreatethereport.Thatway ,ifeitherofthisoperationsfail,wehavenot
- andwritingascriptthatalreadyworks.Evenifithasissues.Iseetoomanypeopleaskingquestions *
- b.pdf *
- butnotwith <hl>.Pdf<
- c.pdf *
- casewouldneedfurtherdiscussion. *
- chomp *
- close *
- directorystructureforeveryfile.Itcantakealotoftime ,especiallyiftherearealotofexpected
- else *
- files. *
- fullpathtoeachfile ,whileweonlyneedthefilename.Forthatwecreateanewarraycalled<hl>
- if *
- inwhichthekeysarethenamesofthefilesandallthevaluesarejustthenumber <hl>1<
- matchthewild-card <hl>
- my *
- ofFile *
- ofcodeandthenprovideasolution. *
- ofthefileisinthe <hl>
- open *
- print *
- printMYOP *
- thefilesystemandcollectthefilenames. *
- theproblem. *
- useFile *
- usestrict *
- usewarnings *
- wastedtimetraversingthewholedirectorytree. *
- whichcanbeanissueifthelistsarebiggerthanthememoryofourcomputer. *
- while *
- whilethestringsinperlarecasesensitive.IfthisscriptneedstorunonLinux *
- withouttryingtosolvetheproblemthemselves.Inmanycasesprobablywithoutevenunderstanding *
- withthelistofexpectedfile.Thisrequiresustoholdthelistoftheexistingfileinthememory ,
- BEGIN *
- Because <hl>requires<
- Iftheuserwhotypedin <hl>useMath
- Ifyouhaveeitheroftheseexpressionsinthecode *
- Ifyouwanttoloadmodulesoncondition ,inordertosaveonstart
- Inotherwords ,the<hl>import<
- Math *
- Soduringthecompilationforphase ,whenperlfinishedcompilingthecodeintheBEGIN
- Sosomepeoplemightthinktheywanttoloadamoduleconditionallysotheywrite *
- Sothat *
- That *
- The <hl>BEGIN<
- Thenyoucancallthe <hl>import<
- Thesecondstatementinthe <hl>BEGIN<
- Thiswillletyouusethefunctionsofthemodulewiththeir <ahref=
- Vacation *
- Wehavelearnedabout <ahref=
- Wesaw *
- Whatthe <hl>import<
- andonlyifthe <hl>
- andthe <hl>use<
- butIhavenotexplainedthedifferencebetween <hl>use<
- butthis <b>doesNOTwork<
- casesitwillarrangeforthe <hl>add<
- examplewiththe <hl>qw
- hopingthatyouwon *
- if *
- inthecompilation ,itwillloadthe<hl>Vacation
- inthefile *
- ofwhatvaluethevariable <hl>
- partofthescripthasfinishedcompiling. *
- pausethecompilationandexecutethecodeinsidetheblock.Thefirststatementthereisthe <hl>require<
- providingthefullyqualifiedname <hl>Math
- requireMath *
- requireVacation *
- statementthatmeans ,findthe<hl>Math
- the <hl>
- the <hl>use<
- thenperlwillloadandcompilethemoduleduringthecompilationtimeofthescript. *
- thereisafilecalled <hl>Calc.pm<
- thereissuchamethod. *
- useMath *
- useVacation *
- whenthescriptisrunninganditreachestheaboveexpression ,itwillgooverthedirectorieslistedin
- willbeexecutedduringcompiletime.Sowhenperlcompilesthisscriptandreachestheif-statement *
- Ancheseilmessaggiod *
- Anzitutto ,c
- Dopotutto ,lavariabile<hl>
- El *
- Globalsymbol *
- Ilconcettodi <b>scope<
- Ilmessaggiochericeviamo *
- Ilmessaggiod *
- Ilproblema *
- InPerl ,unbloccoracchiusotraparentesigraffegeneraunoscope.
- Inaltreparole ,lacondizione<hl>if
- Inognicaso ,normalmentenonguiderestel
- Lasoluzioneconsistenelchiamare <hl>print<
- Laspiegazionecontenutanelladocumentazione *
- Laspiegazionedici *
- Levariabilidichiaratenelbloccocon <hl>my<
- Lui *
- Naturalmente ,sedimenticatedirimuovereil<hl>my<
- Nonsonosicuroselacosapi *
- Ovvero ,occorre<b>dichiararelavariabileconmyprimadiusarla.<
- Persbarazzarsidalmessaggiod *
- Qualedelleduesoluzionisiagiustoapplicarevariadacasoacaso.Quellecheabbiamoillustratosonosemplicementelesoluzionicorrettedaunpuntodivistasintattico. *
- Secifosseun *
- Unainterpretazioneapprossimativadelsignificatodelmessaggio *
- Unaltroerrorecomunetraiprincipianti *
- Unprincipiantedovrebbegi *
- Vienegeneratounerroredicompilazioneseaccedeteaunavariabilechenonsiastata *
- checosaposaesserepi *
- chefunziona ,anchesegeneraunwarning
- chepermoltepersonepu *
- dichiaratacon *
- eavr *
- if *
- interminialorocomprensibili. *
- lacausadelproblemapotrebbeesserepi *
- my *
- oppureneldichiararelavariabilealdifuoridelblocco *
- print *
- qualificareilnomediunavariabile *
- risultapocoutileperilprogrammatorePerlprincipiante. *
- scopodelpresentearticolo.Ilsuoscopo *
- usestrict *
- usewarnings *
- Globalsymbol *
- Perl- *
- Thatis ,oneneedsto<b>declarethevariableusingmybeforeitsfirstuse.<
- if *
- my *
- print *
- usestrict *
- usewarnings *
.github/workflows/ci.yml
actions
- actions/checkout v2 composite
- perl 5.32 build
- ubuntu 18.04 build
- perl 5.32 build
- redis 6.2.1