What are special variables in Perl? - Educative.io

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

These special variables are usually represented by using punctuation symbols right after a variable indicator. Variable indicators in Perl include $ , @ ... SolutionsEducativeEnterpriseEnablementplatformDevelopersLearnnewtechnologiesProductsCoursesforEnterpriseSuperchargeyourengineeringteamCoursesforIndividualsWorldclasscoursesOnboardingOnboardnewhiresfasterAssessmentsMeasureyourSkillScorePersonalizedLearningPlansPersonalizedPlansforyourgoalsProjectsBuildrealworldapplicationsAnswersTrustedAnswerstoDeveloperQuestionsPricingForEnterpriseTailoredforyourteamForIndividualsStayaheadofthecurveCoursesLogInJoin forfreeTrustedanswerstodeveloperquestionsTrustedAnswerstoDeveloperQuestionsRelatedTagsperlWhatarespecialvariablesinPerl?ShezaMunirGrokkingModernSystemDesignInterviewforEngineers&ManagersAceyourSystemDesignInterviewandtakeyourcareertothenextlevel.LearntohandlethedesignofapplicationslikeNetflix,Quora,Facebook,Uber,andmanymoreina45-mininterview.LearntheRESHADEDframeworkforarchitectingweb-scaleapplicationsbydeterminingrequirements,constraints,andassumptionsbeforedivingintoastep-by-stepdesignprocess. StartLearningThereareparticularlyreservedkeywordsforspecialvariablesinPerl.Thesekeywordshavepredefinedmeanings. Representation Thesespecialvariablesareusuallyrepresentedbyusingpunctuationsymbolsrightafteravariableindicator.VariableindicatorsinPerlinclude$,@,and%.Anexampleofadeclarationofaspecialvariablewouldbe$_. Examples FollowingaresomeexamplesofspecialvariablesinPerl: $_Thisvariablesearchesforapattern.$/Thisvariableputsanewlineintheinput.Itiscalledthe'inputrecordseparator'$\Thisvariableputsanewlineintheoutputprinted.Itiscalledthe'outputrecordseparator'$"Thisvariableseparatesthevaluesinalist.$0ThisvaluestoresthenameofthefilecontainingtherunningPerlcode.%SIGThisvariablerepresentsthehashusedtosetsignalhandlersformanysignals@ARGVThisvariablestoresanarraycontainingCLIargumentsrequiredinthecode.Code ThefollowingcodeoutlinestheuseofspecialvariablesinPerl: #thiscodeexampleshowsthespecialvariables$_and$/foreach('This','is','an','Edpresso','shot.'){#the'$_'specialvariablecanbeusedtoiterateoveralist(pattern)print$_;#the'$/'specialvariablecanbeusedtoputanewlineprint$/;}RunRELATEDTAGSperlCONTRIBUTORShezaMunirCopyright©2022Educative,Inc.AllrightsreservedGrokkingModernSystemDesignInterviewforEngineers&ManagersAceyourSystemDesignInterviewandtakeyourcareertothenextlevel.LearntohandlethedesignofapplicationslikeNetflix,Quora,Facebook,Uber,andmanymoreina45-mininterview.LearntheRESHADEDframeworkforarchitectingweb-scaleapplicationsbydeterminingrequirements,constraints,andassumptionsbeforedivingintoastep-by-stepdesignprocess. StartLearningKeepExploringRelatedCoursesLearnin-demandtechskillsinhalfthetimeSOLUTIONSForEnterpriseForIndividualsForHR&ducativeSessionsEducativeAnswersABOUTUSOurTeamCareersHiringFrequentlyAskedQuestionsContactUsPressMOREGitHubStudentsScholarshipCourseCatalogEarlyAccessCoursesEarnReferralCreditsCodingInterview.comCopyright©2022Educative,Inc.Allrightsreserved.



請為這篇文章評分?