Perl | scalar keyword - GeeksforGeeks

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

scalar keyword in Perl is used to convert the expression to scalar context. This is a forceful evaluation of expression to scalar context even ... Skiptocontent CoursesForWorkingProfessionalsDSAClasses(Live)SystemDesign(Live)JavaBackendDeveloper(Live)FullStack(Live)ExploreMoreLiveCoursesDSA(Self-Paced)SDETheory(Self-Paced)AllDevelopmentCourses(Self-Paced)ExploreMoreSelf-PacedCoursesForStudentsCompetitiveProgramming(Live)GATECourse2023(Live)DataScience(Live)ExploreMoreLiveCoursesDSA(Self-Paced)CIP(Self-Paced)JAVA/Python/C++(Self-Paced)ExploreMoreSelf-PacedCoursesSchoolCoursesSchoolGuidePythonProgrammingLearnToMakeAppsExploremoreAllCoursesTutorialsAlgorithmsAnalysisofAlgorithmsAsymptoticAnalysisWorst,AverageandBestCasesAsymptoticNotationsLittleoandlittleomeganotationsLowerandUpperBoundTheoryAnalysisofLoopsSolvingRecurrencesAmortizedAnalysisWhatdoes'SpaceComplexity'mean?Pseudo-polynomialAlgorithmsPolynomialTimeApproximationSchemeATimeComplexityQuestionSearchingAlgorithmsSortingAlgorithmsGraphAlgorithmsPatternSearchingGeometricAlgorithmsMathematicalBitwiseAlgorithmsRandomizedAlgorithmsGreedyAlgorithmsDynamicProgrammingDivideandConquerBacktrackingBranchandBoundAllAlgorithmsDataStructuresArraysLinkedListStackQueueBinaryTreeBinarySearchTreeHeapHashingGraphAdvancedDataStructureMatrixStringsAllDataStructuresInterviewCornerCompanyPreparationTopTopicsPracticeCompanyQuestionsInterviewExperiencesExperiencedInterviewsInternshipInterviewsCompetititveProgrammingDesignPatternsSystemDesignTutorialMultipleChoiceQuizzesLanguagesCC++JavaPythonC#SQLScalaPerlGoLanguageKotlinWebDevelopmentHTMLCSSJavaScriptPHPCSSFrameworksBootstrapTailwindCSSFoundationCSSMaterializeCSSBulmaPureCSSPrimerCSSBlazeUISemanticUIJavaScriptFrameworksAngularJSNodeJSJavaScriptLibrariesjQueryReactJSML&DataScienceMachineLearningDataScienceCSSubjectsMathematicsOperatingSystemDBMSComputerNetworksComputerOrganizationandArchitectureTheoryofComputationCompilerDesignDigitalLogicSoftwareEngineeringGATEGATEComputerScienceNotesLastMinuteNotesGATECSSolvedPapersGATECSOriginalPapersandOfficialKeysGATE2021DatesGATECS2021SyllabusImportantTopicsforGATECSSoftwareDesignsSoftwareDesignPatternsSystemDesignTutorialGFGSheetsWebDevCheatSheetsHTMLCheatSheetCSSCheatSheetJSCheatSheetjQueryCheatSheetCompany-WiseSDESheetsFacebookSDESheetAmazonSDESheetAppleSDESheetNetflixSDESheetGoogleSDESheetWiproCodingSheetInfosysCodingSheetTCSCodingSheetCognizantCodingSheetHCLCodingSheetDSASheetsSDESheetFAANGCodingSheetLoveBabbarSheetMassRecruiterSheetProduct-BasedCodingSheetCompany-WisePreparationSheetArraySheetStringSheetTreeSheetGraphSheetDPSheetSchoolLearningSchoolProgrammingMathematicsNumberSystemAlgebraTrigonometryStatisticsProbabilityGeometryMensurationCalculusMathsNotes(Class8-12)Class8NotesClass9NotesClass10NotesClass11NotesClass12NotesNCERTSolutionsClass8MathsSolutionClass9MathsSolutionClass10MathsSolutionClass11MathsSolutionClass12MathsSolutionRDSharmaSolutionsClass8MathsSolutionClass9MathsSolutionClass10MathsSolutionClass11MathsSolutionClass12MathsSolutionPhysicsNotes(Class8-11)Class8NotesClass9NotesClass10NotesClass11NotesChemistryNotesClass8NotesClass9NotesClass10NotesBusinessStudies(Class11th)BusinessStudies(Class12th)CSExams/PSUsISROISROCSOriginalPapersandOfficialKeysISROCSSolvedPapersISROCSSyllabusforScientist/EngineerExamUGCNETUGCNETCSNotesPaperIIUGCNETCSNotesPaperIIIUGCNETCSSolvedPapersStudentCampusAmbassadorProgramSchoolAmbassadorProgramProjectGeekoftheMonthCampusGeekoftheMonthPlacementCourseCompetititveProgrammingTestimonialsStudentChapterGeekontheTopInternshipCareersUPSCGeographyNotesHistoryNotesScience&Tech.NotesEthicsNotesPolityNotesEconomicsNotesUPSCPreviousYearPapersSSCCGLSSCCGLSyllabusGeneralStudiesEnglishReasoningSubjectwisePracticePapersPreviousYearPapersBankingExamsSBIClerkSBIClerkSyllabusGeneralAwarenessEnglishQuantitativeAptitudeReasoningAbilitySBIClerkPracticePapersSBIPOSBIPOSyllabusGeneralAwarenessEnglishQuantitativeAptitudeReasoningAbilityPreviousYearPapersSBIPOPracticePapersIBPSPOIBPSPO2022SyllabusEnglishNotesReasoningNotesPreviousYearPapersMockQuestionPapersIBPSClerkIBPSClerkSyllabusEnglishNotesPreviousYearPapersJobsApplyforJobsPostaJobHirewithUsKnowaboutJobathonJobathonPracticeAllDSAProblemsProblemoftheDayInterviewSeries:WeeklyContestsBi-WizardCoding:SchoolContestsEventsPracticeSDESheetCuratedDSAListsTop50ArrayProblemsTop50StringProblemsTop50TreeProblemsTop50GraphProblemsTop50DPProblemsContests HomeSavedVideosCoursesGBlogPuzzlesWhat'sNew? ChangeLanguage DataStructuresAlgorithmsInterviewPreparationTopic-wisePracticeC++JavaPythonCompetitiveProgrammingMachineLearningWrite&EarnJavaScriptSDESheetPuzzlesGFGSchoolProjects RelatedArticles ▲RelatedArticlesWriteanArticleWriteArticlesPickTopicstowriteGuidelinestoWriteGetTechnicalWritingInternshipWriteanInterviewExperienceBasicsPerlProgrammingLanguageIntroductiontoPerlPerlInstallationandEnvironmentSetupinWindows,Linux,andMacOSPerl|BasicSyntaxofaPerlProgramHelloWorldPrograminPerlFundamentalsPerl|DataTypesPerl|BooleanValuesPerl|Operators|Set–1Perl|Operators|Set–2Perl|VariablesPerl|ModulesPackagesinPerlControlFlowPerl|DecisionMaking(if,if-else,Nested–if,if-elsifladder,unless,unless-else,unless-elsif)Perl|Loops(for,foreach,while,do…while,until,Nestedloops)Perl|given-whenStatementPerl|gotostatementArrays&ListsPerl|ArraysPerl|ArraySlicesPerl|Arrays(push,pop,shift,unshift)PerlListanditsTypesHashPerlHashPerl|HashOperationsPerl|MultidimensionalHashesScalarsPerl|ScalarsPerl|ComparingScalarsPerl|scalarkeywordStringsPerl|Quoted,InterpolatedandEscapedStringsPerl|StringOperatorsPerl|Stringfunctions(length,lc,uc,index,rindex)OOPConceptsObjectOrientedProgramming(OOPs)inPerlPerl|ClassesinOOPPerl|ObjectsinOOPsPerl|MethodsinOOPsPerl|ConstructorsandDestructorsPerl|MethodOverridinginOOPsPerl|InheritanceinOOPsPerl|PolymorphisminOOPsPerl|EncapsulationinOOPsRegularExpressionsPerl|RegularExpressionsPerl|OperatorsinRegularExpressionPerl|RegexCharacterClassesPerl|QuantifiersinRegularExpressionFileHandlingPerl|FileHandlingIntroductionPerl|OpeningandReadingaFilePerl|WritingtoaFilePerl|UsefulFile-handlingfunctionsCGIProgrammingPerl|CGIProgrammingPerl|FileUploadinCGIPerl|GETvsPOSTinCGIWriteanArticleWriteArticlesPickTopicstowriteGuidelinestoWriteGetTechnicalWritingInternshipWriteanInterviewExperienceBasicsPerlProgrammingLanguageIntroductiontoPerlPerlInstallationandEnvironmentSetupinWindows,Linux,andMacOSPerl|BasicSyntaxofaPerlProgramHelloWorldPrograminPerlFundamentalsPerl|DataTypesPerl|BooleanValuesPerl|Operators|Set–1Perl|Operators|Set–2Perl|VariablesPerl|ModulesPackagesinPerlControlFlowPerl|DecisionMaking(if,if-else,Nested–if,if-elsifladder,unless,unless-else,unless-elsif)Perl|Loops(for,foreach,while,do…while,until,Nestedloops)Perl|given-whenStatementPerl|gotostatementArrays&ListsPerl|ArraysPerl|ArraySlicesPerl|Arrays(push,pop,shift,unshift)PerlListanditsTypesHashPerlHashPerl|HashOperationsPerl|MultidimensionalHashesScalarsPerl|ScalarsPerl|ComparingScalarsPerl|scalarkeywordStringsPerl|Quoted,InterpolatedandEscapedStringsPerl|StringOperatorsPerl|Stringfunctions(length,lc,uc,index,rindex)OOPConceptsObjectOrientedProgramming(OOPs)inPerlPerl|ClassesinOOPPerl|ObjectsinOOPsPerl|MethodsinOOPsPerl|ConstructorsandDestructorsPerl|MethodOverridinginOOPsPerl|InheritanceinOOPsPerl|PolymorphisminOOPsPerl|EncapsulationinOOPsRegularExpressionsPerl|RegularExpressionsPerl|OperatorsinRegularExpressionPerl|RegexCharacterClassesPerl|QuantifiersinRegularExpressionFileHandlingPerl|FileHandlingIntroductionPerl|OpeningandReadingaFilePerl|WritingtoaFilePerl|UsefulFile-handlingfunctionsCGIProgrammingPerl|CGIProgrammingPerl|FileUploadinCGIPerl|GETvsPOSTinCGIPerl|scalarkeywordViewDiscussion ImproveArticle SaveArticle LikeArticle DifficultyLevel: ExpertLastUpdated: 11Aug,2021ReadDiscussViewDiscussion ImproveArticle SaveArticle LikeArticle scalarkeywordinPerlisusedtoconverttheexpressiontoscalarcontext.Thisisaforcefulevaluationofexpressiontoscalarcontextevenifitworkswellinlistcontext. Syntax:scalarexprReturns:ascalarvalueExample1:  Perl#!/usr/bin/perl-w #DefiningArrays@array1=("Geeks","For","Geeks");@array2=(1,1,0,0,9,6); #Concatenationofbotharrays@array3=(@array1,@array2); #PrintingtheConcatenatedArray#inListformprint"ArrayinListform:@array3\n"; #ConversionofArraystoscalarcontext@array3=(scalar(@array1),scalar(@array2)); #Conversiontoscalarreturns#thenumberofelementsinthearrayprint"Arrayinscalarform:@array3\n";Output: ArrayinListform:GeeksForGeeks110096 Arrayinscalarform:36 Example2:  Perl#!/usr/bin/perl-w #DefiningArrays@array1=("Welcome","To","Geeks");@array2=(1,1,0,0,9,6); #concatenationofbotharrays@array3=(@array1,@array2); #PrintingtheConcatenatedArrayprint"ConcatenationofArrays:@array3\n"; #ConversionofArraystoscalarcontextto#EvaluateDifferencebetweensizeofarrays@array3=(scalar(@array2)-scalar(@array1)); #PrintingthesizeDifferenceprint"Differenceinnumberofelements:@array3\n";Output: ConcatenationofArrays:WelcomeToGeeks110096 Differenceinnumberofelements:3 MyPersonalNotes arrow_drop_upSave LikePreviousPerl|ComparingScalarsNext Perl|Quoted,InterpolatedandEscapedStringsRecommendedArticlesPage:06,Mar1927,Mar1917,Jun1926,Mar1913,Jun1913,Nov1902,Aug1802,May1903,Jul1930,May1929,Apr1926,Apr1928,Feb1913,Jul1820,Jun1820,Jun1820,Jun1825,Jun1818,Jul1826,Jun1828,Jun1803,Jul1803,Jul1803,Jul18ArticleContributedBy:Code_Mech@Code_MechVotefordifficultyCurrentdifficulty: ExpertEasy Normal Medium Hard ExpertImprovedBy:clintraArticleTags:Perl-KeywordsPerl-ScalarsPerlPracticeTags:PerlReportIssueWritingcodeincomment? Pleaseuseide.geeksforgeeks.org, generatelinkandsharethelinkhere. LoadCommentsPleaseLogintocomment...What'sNew  ViewDetailsViewDetailsViewDetailsImproveyourCodingSkillswithPracticeTryIt! Weusecookiestoensureyouhavethebestbrowsingexperienceonourwebsite.Byusingoursite,you acknowledgethatyouhavereadandunderstoodour CookiePolicy& PrivacyPolicy GotIt! StartYourCodingJourneyNow!Login Register



請為這篇文章評分?