Click here to Skip to main content
15,884,083 members
Everything / Programming Languages / Perl

Perl

Perl

Great Reads

by Omar Al Zabir
Protect ASP.NET and WCF from various brute force and Denial of Service attacks and speed up response time using nginx.
by Oscar-Tark
If you are looking into white hat hacking, it's good to know old school tactics used for overflows.
by Oscar-Tark
In this article, we will be looking at a more advanced version of a buffer overflow attack.
by anshulskywalker
Understanding of Example Based Machine Translation (EBMT) system and how to create your own using exisiting tools

Latest Articles

by Paul Aurelian Gagniuc
This article shows how to mix two signals into a third, in variable proportions.
by Oscar-Tark
In this article, we will be looking at a more advanced version of a buffer overflow attack.
by Oscar-Tark
A basic formatted string exploit shows you how small errors in programming with the printf function can be a lethal weapon for hackers looking to compromise a system.
by Shameel
Part 2 of this multi-part article series compares SQL Server and PostgreSQL article, database structure, language differences, data type mappings, functions and operators and other important considerations for migration..

All Articles

Sort by Updated

Perl 

4 Jan 2024 by Richard MacCutchan
Yes, whether it will work or not is a different matter.
4 Jan 2024 by Milan Belobaba 2024
Can i run perl script in IIS Express 10 What I have tried: "PERL">Can i run perl script in IIS Express 10
24 Nov 2022 by H. Bala
My Input HTML File is: 1.1 Heading 1 1.1.1 Heading 2 1.1.2 Heading 2 1.1.2.1 Heading 3 1.1.2.1.1 Heading 4 I am expecting Output is: ...
23 Jul 2022 by k5054
To assign matched substrings you have to use the substitute regex operator my $s = "Regular expression"; $s =~ s/Regular(.*?)/$1/; # note leading s for regex operation # update: (oops!) changed assignment (=) to match-assign (=~) in above...
22 Jul 2022 by armanvaneld
hi i try to match expression but not match What I have tried: #!/usr/bin/perl use warnings; use strict; my $s = "Regular expression"; $s =~ /Regular(.*?)/; print $s;
22 Jul 2022 by Richard MacCutchan
That works fine for me, so I cannot see what you may be doing wrong. You also need to understand that the expression $s =~ /Regular(.*?)/ returns 1 for a match, and nothing for a non-match. Match: my $s = "Regular expression"; print $s =~...
22 Jul 2022 by Patrice T
Quote: hi i try to match expression but not match It works : ! Try $s =~ /Regular(.*)/; Pay attention to the '?' removed, it may give better results. Just a few interesting links to help building and debugging RegEx. Here is a link to RegEx...
16 May 2022 by Member 15251555
Hi, I trying substring line from file where is a keywords - open newest file in folder but now I using file as a source data: kontroly20220513_154743.txt I need find keywords: Konec_Kontroly, Konec, Volat, Stav, Info and print this data to...
20 Mar 2022 by Paul Aurelian Gagniuc
This article shows how to mix two signals into a third, in variable proportions.
18 Oct 2021 by Member 15251555
Hi, how can I remove word "headers" from code please? use LWP::UserAgent; my $ua = LWP::UserAgent->new; # set custom HTTP request header fields my $req = HTTP::Request->new(POST => $server_endpoint); $req->header('content-type' =>...
12 Oct 2021 by Richard MacCutchan
Sorry, this site does not provide code to order. You need to do some more research into how Perl handles JSON.
28 Sep 2021 by OriginalGriff
We do not condone, support, or assist in the production of malicious code in any way, form, or manner. This is a professional site for professional developers. If you want to know how to create such things, you need to visit a hacking site: but...
6 Jul 2021 by Member 15277469
The example shows a small application which should run multi-threaded to speed up the data processing. There is an input-thread, creating work and putting it into a queue created with Thread::Queue A bunch of worker threads is getting started,...
6 Jul 2021 by k5054
Perl threads, at least in perl 5, aren't really threads - they're perhaps more like fibers that are controlled by the perl runtime rather than POSIX or other threads. In general, you will get much better performance using a fork rather than...
27 May 2021 by Oscar-Tark
In this article, we will be looking at a more advanced version of a buffer overflow attack.
17 Mar 2021 by Santosh Kumar 2021
How to get expected output for an input file like below and output should be as below using any program awk/sed/perl/shell/python. please help input: abc APPLE 123 456 789 def APPLE 321 654 987 . . . expected Output: append sequence before...
17 Mar 2021 by CPallini
Try fin = open('input.txt', 'r') fout = open('output.txt', 'w') linesin = fin.read().splitlines() seqnum = 1 previous = None for lin in linesin: if previous != None: if lin == 'APPLE': previous += str(seqnum) seqnum = seqnum +...
25 Nov 2020 by Patrice T
Posting your homework is not a question. You show no attempt to solve the problem yourself, you have no question, your main effort is pasting the requirement, you just want us to do your HomeWork. HomeWork problems are simplified versions of the...
25 Nov 2020 by OriginalGriff
You're running late - the rest of your class was trying to get us to do this homework last week ... But I'll tell you what we told them: Quote: We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it...
26 Aug 2020 by JaanVvk
Hi Team, I am new to perl script and using regex to validate a user input for fixed format.I have t accept only two formats of string as input. Format 1# R99.999 {Upto any number but it should start with R and go upto some digits after decimal}...
26 Aug 2020 by k5054
Your logic is backwards. When A != B || A != C then this will evalutate to true unless B == C A = 2 B = 2 C = 3 A != B => false A != C => true false || true => true You want to use && instead. You also might want to check your regexes: 1)...
25 Aug 2020 by learners0930
i have two hashes say fruit and vegetable in a.pl file how can i access these in another file say b.pl? What I have tried: #a.pl file %fruit=('apple',1,'mango',2,'grapes',3); %vegetable=('carrot',4,'potato',5);...
25 Aug 2020 by Sandeep Mewara
I would suggest you to pick some book or tutorial to go through it first. See what all is already there and how they can be used. This would help you know basic stuff. For now, above query, look details here: Using variable from modules[^]...
24 Aug 2020 by Garth J Lancaster
For the first part, you could think about using the 'exists' Perl keyword, as in : if (exists($fruit($praticular_product)) { print "Found Apple in fruit\n"; } else { print "Apple not found in fruit\n" } you can use 'for' to iterate (loop...
24 Aug 2020 by learners0930
i have to create two hashes say vegetable and fruit with key names as the product and values can be any (for vegetable:keys are carrot ,potato and for fruits keys are apple and mango. i have a particular product say apple .i should check...
24 Aug 2020 by Sandeep Mewara
You can use exists() function. # Calling the exists() function if(exists($fruit{'apple'})) { print "Exists\n"; } else { print "Not Exists\n" } Refer: Perl - Hashes - Tutorialspoint[^]
31 May 2020 by Member 14849382
It looks like you are trying to determine the identity of an unauthenticated remote user, which does not work and even if it did would be meaningless. http by default is anonymous. To change this you need to either authenticate the user (http...
29 Feb 2020 by Oscar-Tark
A basic formatted string exploit shows you how small errors in programming with the printf function can be a lethal weapon for hackers looking to compromise a system.
9 Dec 2019 by bhrgv_7
Hi while running a perl snippet getting error as : "Can't modify subtraction (-) in scalar assignment at /usr/local/intranet.tsp line 329, at EOF" #please let me know what mistake i'm doing here.Thanks my %vhost_dev-redirector = ( name => 'dev-redirector.com', ...
9 Dec 2019 by Richard MacCutchan
Change the variable name dev-redirector to dev_redirector, using underscore instead of subtraction operator.
29 Oct 2019 by Member 14174174
I am getting parse error in my Perl file on VM (OS: Maipo Linux) due to DateTime module use strict; use warnings; use NodeExtensions; use Time::Local; use DateTime; What I have tried: By making comment out use DateTime; parse error get resolved what might be the issue, thanks in...
29 Sep 2019 by Rema Thomas
I need to create a program in Perl that will allow the user to play craps. Here are some of the specifics and the rules for craps: The program should allow the player to make a wager before each “turn”. Before each turn, allow the user to either place a bet or exit the game. After each turn...
29 Sep 2019 by Patrice T
Quote: I am unfamiliar with the Perl coding language. Bad idea ! It is like trying to win a Formula 1 GP while learning to drive, it don't work that way. Millions of people have learned programming: 1) Lean programming with courses or tutorials, do tiny exercises. 2) Solve more complicated...
29 Sep 2019 by Dave Kreskowiak
If you're not familiar with Perl, what do you want from anyone answering this? Step 1: You MUST learn the language before you start writing code in it.
21 Sep 2019 by Shameel
Part 2 of this multi-part article series compares SQL Server and PostgreSQL article, database structure, language differences, data type mappings, functions and operators and other important considerations for migration..
30 Aug 2019 by Oscar-Tark
If you are looking into white hat hacking, it's good to know old school tactics used for overflows.
22 Jul 2018 by Patrice T
Quote: How do I wite the code for stalls and coupens coding questions (tcs digital advanced coding questions)? First of all, in this kind of challenges, every word matters. So it is a good idea to give exact wording and/or a link to original webpage. Quote: Ive tried for the logic but no luck ...
22 Jul 2018 by Member 13921555
well when i wrote the test even i couldn't figure it out,but after coming home,when i tried,it worked here the solution: #include int main(void) { int n,k,arr[20],i,j,curr_val=0,max_val=0,l,c; scanf("%d,%d",&n,&k); for(i=0;i
22 Jul 2018 by Member 13921117
what is the coding logic for the question ? thier are n shops, each shop will give a coupen with some number on it. if you take a coupen from a shop then you cant take coupen from the next k shops. at the end you should posses the max total of coupens. Input:- n(no of shops) k(shops to skip) ...
21 Jul 2018 by OriginalGriff
Start by reading the input and storing it. Then process the input repeatedly, trying each combination. For example, if you take the first shops coupon, then you cannot take a coupon from the next two, but you can take the fourth shops coupon if you want - 7. If you do, then you will have 2...
9 Jun 2018 by Patrice T
$sql = "SELECT name,password FROM admin where name='$adminuser' and password='$adminpass';"; Not a solution to your question, but another problem you have. Never build an SQL query by concatenating strings. Sooner or later, you will do it with user inputs, and this opens door to a vulnerability...
9 Jun 2018 by Richard MacCutchan
PHP and Perl are two completely different beasts. And as it is a school project you should do your own homework, rather than expecting someone else to do it for you.
29 May 2018 by Jochen Arndt
The first step is to understand what the code is doing: The code seems to convert an array of bytes to a string of hex characters where the lowest byte is on the right side of the string (it depends on the definition of the HEX array but I guess it is just a mapping to the characters 0 to 9 and...
29 May 2018 by Rajesh Kumar Yuvaraj
I am in need of below Java code converted to PERL script. Can anyone help me in this context? public static String hex(byte[] bytes) { char[] c = new char[bytes.length * 2]; for (int i = 0; i
25 May 2018 by Surajit M
Example of my requirement: If a web page has a form and when you submit the form, that page will fetch some data from a database and then display the output. While fetching the data it needs 9-10 seconds of time. On that particular time I need a loader or a progress bar to let user know that...
3 Apr 2018 by Member 13751131
I'm using a Mac osx. I know that this code in the terminal will replace all txt files that include "hello" with "hiThere" in the folder named "world": perl -pi -w -e 's/hello/hiThere/g;' ~/Desktop/world/*.txt But inside that world folder there are other folders which have other txt files...
16 Feb 2018 by Patrice T
Here is a good tutorial site to learn the basics of web dev. W3Schools Online Web Tutorials[^]
16 Feb 2018 by garav kumar mishra
i want to develop html 5 base video chat how to start ??
5 Feb 2018 by KaisNeihoum
I want to ask about using multi-language in a project: I want to known what the benefit of it is, and why its common in the modern apps. and I'd also like to know about the marshalling mechanism. I'd also like to know what the best way to do that, and what programming-languages must I learn to...
5 Feb 2018 by CPallini
Using different programming languages makes the developer take adavantage of both (or more) language features. In a typical sceneario, you embed a scripting language (e.g. Lua or Python) into an application (written with a non-scripting one like C++, C# or Java) to make it easily customizable to...
21 Dec 2017 by Mohibur Rashid
If all your requirement is to remove the space then $string =~ s/\s//g; should be fine if you only want to filter the index-4 item leave other as it is then try the following example $line="A,01/01/1900,12/30/9999, 2AB9500,A9,8999,BNVV"; @arr=split /\//, $line; $arr[4] =~ s/\s//g; ...
21 Dec 2017 by Member 13588253
input string is: A,01/01/1900,12/30/9999, 2AB9500,A9,8999,BNVV I want to get the 4th element and remove the space for that field and join it back to the string. What I have tried: I tried : @capture = $string =~ /([^,]+)/g; # capture all the fields with spaces $capture[pos] =~...
14 Dec 2017 by ilostmyid2
I use this site to convert sequence of bytes like this: Рабыни into proper character sequences like this: Рабыни It seems that the site decodes the UTF8 sequences into their original characters. For some reason, some of my files names are corrupted and I need to convert them back to...
27 Nov 2017 by Arlert
Hi and Happy new year.Is there anywhere perl script converter to other languages like c++ or c#?If yes, can you please give me link to it, or can you write this code:foreach $pair (split('&', $form)) { if ($pair =~ /(.*)=(.*)/) { ($key,$value) = ($1,$2); ...
27 Oct 2017 by Nabil Droussi
Hi experts, There is a debate between some acadimic and non academic programmers especially in the Franco world of whether to break inside a loop. The bellow code illustrates what I mean. What do you think best to use and why: 1. for(int i=0; i
27 Oct 2017 by BillWoodruff
I don't think the two examples shown are comparable. When the loop on the second example exits, information persists in a variable 'tentatives that will tell you how many iterations occurred to find the match ... if it found the match. The first example does not persist the iteration count. The...
27 Oct 2017 by Patrice T
My like goes to first option. But I use both depending on situation, there is no absolute rule.
27 Oct 2017 by W Balboos, GHB
I would prefer the internal break - it's absolutely clear and makes it easier to follow if one has, for example, multiple handlers for a desired value and a break; Alternatively, the while() test could grow and grow, becoming more difficult to understand and easier to code with errors. Also,...
27 Oct 2017 by CPallini
I usually go with the first option (even with return, if appropriate) because of less code to type and see. However it is just personal taste.
25 Aug 2017 by Member 13376675
this txt file contains hex values i want to change this into dec and divided into li l2 t1 t2 v1 v2 p h these are hex values 4f337d5000000001 4f337d5000000001 0082004600010000 0082004600010000 334f464600010000 334f464600010000 4f33464601000100 4f33464601000100 334f464600010000 334f464600010000...
24 Aug 2017 by KarstenK
Sounds like you need to learn some basics for your job. At first you need to read the file. How it can be done is explained in Input/output with files tutorial. After that you must split the string in parts as discussed in this answer of stackoverflow. I like the last sample code most. Than...
24 Aug 2017 by Jochen Arndt
For example by Reading the text file line by line Converting each line to a 64-bit integer and store that in an array Writing 8 values from the array to a text file separating them with a comma Depending on the language this might require to determine the array size in advance by...
3 Aug 2017 by OriginalGriff
Start by learning the languages, and then work on specifying the project: what it is meant to do, and then how it is meant to do it. From that document, you generate a design for the project, which becomes detailed enough that you can begin to code to that design. Once that's done, you can start...
21 Jul 2017 by Patrice T
Take a sheet of paper and a pencil. Use your brain and solve the problem by hand. Since Harry Potter didn't gave you the solution, there is no magic, and the solution didn't jump to your face. You solved the problem by following a procedure, that procedure is your algorithm. You need to write...
21 Jul 2017 by OriginalGriff
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action. Try it yourself, you may find it is...
21 Jul 2017 by Dave Kreskowiak
No, no, no. We're not here to do your homework for you. This industry is already too full of people who don't have a clue what their doing and beg other people to do their work for them.
7 Jul 2017 by Member 13298024
use strict; use warnings; use feature qw( say ); my @aa = ("A", "C", "D", "E", "F", "G", "H", "I", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "V", "W", "Y"); my $pair; for my $n1 (@aa) { for my $n2 (@aa) { $pair = $n1 . $n2; } } my $k1=split("' '", $pair);...
7 Jul 2017 by KarstenK
I am not sure, that your split is correct. I would only split for a white space. my $k1=split(" ", $pair); See my other answer. Google for some Perl tutorial to learn the basics.
7 Jul 2017 by Member 13298024
use strict; use warnings; # syntax is use ??? use feature qw( say ); my @aa = ("A", "C", "D", "E", "F", "G", "H", "I", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "V", "W", "Y"); my $pair; for my $n1 (@aa) { for my $n2 (@aa) { $pair = $n1 . $n2; } } my $k1=split("'...
7 Jul 2017 by KarstenK
this assigment overwrites any older assigments: $pair = $n1 . $n2; possible solution could look like this: my $pair = ""; #init as empty string # in the loop: append result string on the previous reuslt and append white space $pair .= $n1 . $n2 . " ";
6 Jul 2017 by Simon Sparkes
A simple way of extracting all images from a RESX file using a simple perl script
21 May 2017 by Member 13209843
I am creating ".inf" file using following command using perl program. system("secedit /export /areas USER_RIGHTS /cfg ".$path); Next, I want to open this file and search for a string. But while opening this file it is not opening in standard format rather some other format,between each...
11 May 2017 by srv vani
perl a.pl > result.txt my generated output: name:asf192lin1 total slots used:0 total slots free:8 name:asf192lin10 total slots used:7 total slots free:9 name:asf192lin11 total slots used:6 total slots free:10 name:asf192lin12 total slots used:8 total slots free:8 name:asf192lin3 total...
18 Apr 2017 by gps sana
Am unable to read the files recursively inside the directories.Here $dir1 is the directory which has the file names with task recursively.I want to remove those files which starts with task recursively.How can i do it? Error: Use of uninitialized value in pattern match (m//) at...
18 Apr 2017 by Jochen Arndt
The regex must be applied to an existing variable but you are trying to create a new one using my and there is an unnecessary brace: my $dirs1=basename($f); { if (my $dirs1 =~ /^task/) So it should be: my $dirs1=basename($f); if ($dirs1 =~ /^task/) # ... # Remove closing brace too You...
4 Apr 2017 by find data
---------- In the below script i tried to pass the values in the submit button using perl cgi.But it fails in my case.Thanks in advance for any help. Things which i verified : In the browser i found the submit button fails to load the value which i had passed.Instead it shows the value as...
4 Apr 2017 by Jochen Arndt
Submitted values can not be read until the form is submitted and you are checking for the value 'submit' but pass 'place2' so that the if condition is never true and $action will be empty. Use param() instead to check the value of submit buttons: if (param('submit') eq 'place2') { ...
30 Mar 2017 by R!sh!
16.726--5.670--25.129**16.312-...
30 Mar 2017 by Patrice T
Just a few interesting links to help building and debugging RegEx.Here is a link to RegEx documentation:perlre - perldoc.perl.org[^]Here is links to tools to help build RegEx and debug them:.NET Regex Tester - Regex Storm[^]Expresso Regular Expression Tool[^]This one show you the...
29 Mar 2017 by Jochen Arndt
Just use an alternation:@pointss = split(/\*\*|--/, $points);
26 Mar 2017 by R!sh!
I have c language file with my algorithm in it and I have done command line arguments. I have compiled the file and got the assembler output file also. Now I need to pass values to my output of c file from perl script and get back the values from c file. Need help. thanks in advance.What I...