What do you want to save?
Add Code snippet
New code examples
-
Perl 2021-10-30 07:38:12
perl validate int
# For Perl (language) only # Headers to use use Scalar::Util 'looks_like_number'; # syntax looks_like_number(<your-possible-integer>) # example (copy-paste, and then run the following to see what happens) use Scalar::Util 'looks_like_number'; my... Add solution -
Perl 2021-10-29 12:14:10
perl datetime formatting
# For Perl only # syntax use POSIX; use Time::Piece; my $CurTime = localtime(); # <-- Format: Day Month Date HH:MM:SS (ei: Thu May 7 08:45:52 2020) my $FormattedVal = $CurTime->strftime('<FormatOfDateTime>'); # example - Copy paste everyth... Add solution -
Perl 2021-10-01 16:37:02
perl replace substring
# For Perl (language) only # syntax (NOTE: this overwrites your original string) <variable> =~ s/<substring-to-replace>/<replacing-substring>/g; # example: replacing all the 'r' characters with 'l' $YourVar =~ s/r/l/g; # usable exampl... Add solution -
Perl 2021-09-23 20:20:02
perl get first characters
# For Perl (language) only # syntax substr(<your-string>,0,<characters-to-extract>) # example substr("Cool, isn't it!",0,4) # application my $sRandom = "Cool, isn't it!"; my $s1stFewChars = substr($sRandom,0,4); print &... Add solution -
Perl 2021-09-03 18:27:03
perl last characters
# For Perl (language) only # syntax substr(<your-string>,-<characters-to-extract>) # example substr("Glass half empty, glass half full",-15) # application my $sRandom = "Glass half empty, glass half full"; my $sLastFewC... Add solution -
Shell/Bash 2021-08-28 04:13:02
grep print only capture group
## Short answer: $ grep -oP 'stuff before your match\Kyour match(?=stuff after your match)' ## Explanation: # GNU grep has the -P option for perl-style regexes, and the -o option to print # only what matches the pattern. # These can be combined by usin... Add solution
Best helpers
Orlp
+5
Brenten1
+5
Kunder
+5
NullPointer
+5
Roshan
+5
Advocatus
+5
Sg qy
+5
Bryce Wagner
+5
Rn tmssn
+5
Lara
+5
TheBeege
+5
Lim
+5
Startripper
+5
Affable Geek
+5
JCM
+5
Dasedes
+5
Mark Walsh
+5
Adb
+5
Chd
+5
Carys Kim
+5
RMalke
+5
Sam C.
+5
James Gentes
+5
Skout
+5