Perl scalar Function - Tutorialspoint

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

Perl scalar Function · Description. This function forces the evaluation of EXPR to be in scalar context, even if it would normally work in list context. · Syntax. Home CodingGround Jobs Whiteboard Tools Business Teachwithus PerlBasics Perl-Home Perl-Introduction Perl-Environment Perl-SyntaxOverview Perl-DataTypes Perl-Variables Perl-Scalars Perl-Arrays Perl-Hashes Perl-IF...ELSE Perl-Loops Perl-Operators Perl-Date&Time Perl-Subroutines Perl-References Perl-Formats Perl-FileI/O Perl-Directories Perl-ErrorHandling Perl-SpecialVariables Perl-CodingStandard Perl-RegularExpressions Perl-SendingEmail PerlAdvanced Perl-SocketProgramming Perl-ObjectOriented Perl-DatabaseAccess Perl-CGIProgramming Perl-Packages&Modules Perl-ProcessManagement Perl-EmbeddedDocumentation Perl-FunctionsReferences PerlUsefulResources Perl-QuestionsandAnswers Perl-QuickGuide Perl-UsefulResources Perl-Discussion SelectedReading UPSCIASExamsNotes Developer'sBestPractices QuestionsandAnswers EffectiveResumeWriting HRInterviewQuestions ComputerGlossary WhoisWho PerlscalarFunction Advertisements PreviousPage NextPage  PerlOnlineTraining 46Lectures 4.5hours DeviKillada MoreDetail COMPLETEPERLProgramming 11Lectures 1.5hours HarshitSrivastava MoreDetail PerlforBeginners:LearnAtoZofPerlScriptingHands-on 30Lectures 6hours TELCOMAGlobal MoreDetail Description ThisfunctionforcestheevaluationofEXPRtobeinscalarcontext,evenifitwouldnormallyworkinlistcontext. Syntax Followingisthesimplesyntaxforthisfunction− scalarEXPR ReturnValue ThisfunctionreturnsScalar. Example Followingistheexamplecodeshowingitsbasicusage− LiveDemo #!/usr/bin/perl-w @a=(1,2,3,4); @b=(10,20,30,40); @c=(@a,@b); print"1-FinalArrayis@c\n"; @c=(scalar(@a),scalar(@b)); print"2-FinalArrayis@c\n"; Whenabovecodeisexecuted,itproducesthefollowingresult− 1-FinalArrayis123410203040 2-FinalArrayis44 perl_function_references.htm PreviousPage PrintPage NextPage  Advertisements



請為這篇文章評分?