Ecosyste.ms: Repos
An open API service providing repository metadata for many open source software ecosystems.
GitHub / kbeyazli / perlmaven.com
The source files of the Perl Maven articles
JSON API: https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kbeyazli%2Fperlmaven.com
Fork of szabgab/perlmaven.com
Stars: 0
Forks: 0
Open Issues: 0
License: None
Language: Perl
Repo Size: 12.3 MB
Dependencies:
425
Created: about 9 years ago
Updated: about 9 years ago
Last pushed: almost 9 years ago
Last synced: over 1 year ago
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
- Prl-Anf *
- Spracheverstehenzulassen ,wasdieseFehlermeldungbedeutet.
- UmdieobigeFehlermeldungzuunterdr *
- Unabh *
- Unddas ,obwohlsie<hl>
- UnddieFehlermeldungist *
- Wasmit <hl>my<
- WelchenWegDueinschlagenwirst ,istvondertats
- WenndieZeilemiteinpaarLeerzeichenodereinemTabulatorzeichen-wieimn *
- ZuersteinmalgibteshiereinvisuellesProblem.DieEinr *
- ausgeben. *
- diezuvornichtmit *
- eineVaraiblevollst *
- geschwungenerKlammern *
- if *
- my *
- nichtexistiert.Daswirdalsder <ahref=
- 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. *
- 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
- 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 *
- 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. *
- 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 ,
- 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 *