diff --git a/sites/en/pages/shift.txt b/sites/en/pages/shift.txt index 62108da9..7332f9a7 100644 --- a/sites/en/pages/shift.txt +++ b/sites/en/pages/shift.txt @@ -4,7 +4,7 @@ =status show =books beginner =author szabgab -=comments_disqus_enable 1 +=comments_disqus_enable 0 =abstract start @@ -56,3 +56,63 @@ Regardless if the array was explicitely given to it or implicely selected based See video explaining shift and unshift or the example using shift to get first parameter of a script. +

Comments

+ +use strict; + +use warnings; + +sub something { + +my $first = shift; + +print "$first\n"; + +} + +something($ARGV[0], $ARGV[1]); +What about this? + +
+ +Hi Gabor, +As a beginner of Perl scripting, I have been reading your tutorials for sometime now. I am always amazed by your simple and to the point explanation of complex concepts. I am not even a real coder- just a grad student making some boring tasks interesting by learning new and appropriate languages. Thanks for being supper clear and your dedication to help others. - Ze + +I am glad I can help! + +
+ +What about shift with a hash reference? + +if ( !checkusage(\%opts) ) { +usage(); +} +sub checkusage { +my $opts_ref = shift; +...do something with $opts_ref +} + +
+ +Please I need your help: +I han been create the next variable: +my @dias=('2023-01-01','2023-01-02','2023-01-03'); +my $cadena_promedio= "obtener_promedios(\\%HoH,"; +foreach my $d (@dias){ +$cadena_promedio.="\'$d\', "; +} +$cadena_promedio.=");"; + +&obtener_promedios(\\%HoH, '2023-01-01','2su023-01-02','2023-01-03',); + +sub obtener_promedio{ +my $HoH= shift; +my @dates= @_; +} + +Please, what will be the value for the variables $HoH and @dates: + +THANKS A LOT. +REGARDS + + diff --git a/sites/en/pages/use-require-import.txt b/sites/en/pages/use-require-import.txt index e85d5ce6..3a33f5d4 100644 --- a/sites/en/pages/use-require-import.txt +++ b/sites/en/pages/use-require-import.txt @@ -5,7 +5,7 @@ =books advanced =status show =author szabgab -=comments_disqus_enable 1 +=comments_disqus_enable 0 =abstract start @@ -107,4 +107,21 @@ and only if the $holiday variable holds something that is considered Tr Then you can call the import method of the module. If you want to. +

Comments

+ +Maybe also discuss Module::Load which is pretty cool when you want to dynamic include modules or files. Good article! + +
+ +include() function it adds the content of the page or +file into the file where this function is used.If there is any problem +in loading a file then the include() function generates a warning but the script will continue execution. require() function takes all the text in a specified +file and copies it into the file that uses the include function. If +there is any problem in loading a file then the require() function generates a fatal error and halt the execution of the script.Vistit Here for example +https://techlifediary.com/whats-difference-include-require-functions/ + +
+ +I have encountered a "problem" with require in that the loaded script cannot see the of the calling script. (The "require" / second script cannot be amended in any way, ie moving the data in STD IN to @ARGV etc!) + diff --git a/sites/en/pages/using-like-to-test-without-exact-values.txt b/sites/en/pages/using-like-to-test-without-exact-values.txt index b88fbfb1..c0a34c35 100644 --- a/sites/en/pages/using-like-to-test-without-exact-values.txt +++ b/sites/en/pages/using-like-to-test-without-exact-values.txt @@ -5,7 +5,7 @@ =status show =books testing =author szabgab -=comments_disqus_enable 1 +=comments_disqus_enable 0 =abstract start