- Strength to Increase Rep
- +10
- Strength to Decrease Rep
- -2
- Upvotes Received
- 41
- Posts with Upvotes
- 37
- Upvoting Members
- 29
- Downvotes Received
- 4
- Posts with Downvotes
- 3
- Downvoting Members
- 3
Re: I suggest you look into existing programs on script archives such as [url]www.hotscripts.com[/url] and see if you can find something that does what you want or comes close to doing it. | |
Re: as far as I know there should be no quotes on the shebang line: #!c:\xampp\perl\bin\perl.exe but you're better off using forward slashes, which Windows fully supports: #!c:/xampp/perl/bin/perl.exe backslashes in perl code create escape sequences, not on the shebang line which is a special line in a perl program, but its … | |
This is a routine task best done with two regexp's when using perl. | |
Re: Using "strict" is important , especially for new perl coders, but it is not necessary to use it. But you will see that 99% of all perl scripts use "strict" and most use "warnings". The -T switch (not -t) is also important for a CGI script. It is there to … | |
Re: sounds possible but I have no clue how to go about it. | |
Re: Use a hash to compare the lines. [CODE]use strict; use warnings; my $f1 = 'E:\upload\new\2.txt'; my $f2 = 'E:\upload\new\a.txt'; my $outfile = 'E:\upload\new\1.txt'; my %results = (); open FILE1, "$f1" or die "Could not open file: $! \n"; while(my $line = <FILE1>){ $results{$line}=1; } close(FILE1); open FILE2, "$f2" or die … | |
Re: The character class you have will match all of the characters in the list of characters you posted. Is there a problem? | |
Re: save the data to a file with an html extension and then up it up in a browser. Or access the url from the internet using a browers. | |
Re: brax4444, what perl code have you tried so far? Is this class/school work? | |
Re: alternatives that do the same thing: print directly from file: [CODE]print "Content-type: text/html\n\n"; open (HTML, "<../path/to/your/file.htm"); print <HTML>; close (HTML);[/CODE] use a scalar instead of an array (slurp mode) [CODE]print "Content-type: text/html\n\n"; open (HTML, "<../path/to/your/file.htm"); my $html = do {local $/; <HTML>}; close (HTML); print $html;[/CODE] | |
Re: Your code is quite close to getting it right, here is a way to do this type of looping guessing game: [code] use strict; use warnings; my $thinkingof = int(rand 10)+1; while (1) { print "Pick a number 1 to 10\n"; my $guess = <STDIN>; chomp $guess; if ($guess > … | |
Re: It would be simpler to use perls inplace editor for this type of task; [CODE]sub edit { my $file = 'path/to/file.txt'; print "Enter the person's name and surname which you'll update the record: "; chomp($dest = <STDIN>); my ($name, $surname) = split(/\s+/,$dest); print "Enter new phone number: "; chomp($newNum = … | |
A bare-bones code snippet to remove duplicate lines from a file. There are a number of ways to accomplish this task but this is a fast and dependable method using perls inplace editor and a simple hash to get the job done. This probably should not be used for really … | |
Re: [QUOTE=Comatose]Look up the substitution operator. s//. You can replace the data like so: [CODE] $myvar = "hello|world|yes!"; $myvar =~ s/|/\t/gi; print "$myvar"; [/CODE][/QUOTE] I'm wondering if you or the OP ran the code you suggested, I think you will find the results not what is expected if the code is … | |
Re: You are running a CGI script. It is expecting data from a CGI form: $name = param ('Salesperson'); $sales = param ('Sales'); $rate = param ('Rate'); the above scalars will have no values (they are uninitialized). Why are you running a CGI script from the command line? That is OK … | |
Re: Akase... You insult everyone helping on this forum by posting your plagarized code and making it appear as if you wrote it. [url]http://www.programmersheaven.com/mb/perl/372885/392147/re-analysing-text-files-to-obtain-statistics-on-their-content/?S=B20000#392147[/url] | |
Re: two ways to go about it: [CODE] chdir("path/to/dir") or die "$!"; opendir (DIR, ".") or die "$!"; my @files = grep {/students_.*?\.html/} readdir DIR; close DIR; { local @ARGV = @files; while(<>){ #each file will be read line by line here } }[/CODE] [CODE]opendir (DIR, "path/to/dir") or die "$!"; my … | |
Re: I didn't get the impression it was homework/schoolwork but I have no idea how to answer such a question: [QUOTE]what are all the scenarios under which perl is used for software testing[/QUOTE] I don't even know what "testing software" means? Testing it for what? | |
Re: [QUOTE=lordspace;334645]It seems __END__ is a "synonym" of __DATA__[/QUOTE] [url]http://perldoc.perl.org/perldata.html[/url] [QUOTE]For compatibility with older scripts written before __DATA__ was introduced, __END__ behaves like __DATA__ in the toplevel script (but not in files loaded with require or do) and leaves the remaining contents of the file accessible via main::DATA .[/QUOTE] | |
Re: /^\D\w{3,7}\d+/; the above means: ^\D starts with one non-digit character \w{3,7} followed by 3 to 7 word characters, same as a-zA-Z0-9_ \d+ followed by one or more digits what you probably want is is two regexps: /\d/ has at least one digit /^[a-zA-Z][a-zA-Z0-9]{3,7}/; | |
Re: Sorry, I have read your question three times and I can't understand what you want to do. | |
Re: You have to use the -e switch to execute code from the command line: perl -e "print \"Hello World\";" | |
Re: he has been getting help on another forum, so he may not respond here. | |
This is a bare-bones search and replace script that uses perls in-place editor and the File::Find module to get the job done quickly. It will search in all sub directories of the start directory and find and replace the text you specify in the type of file you specify. Keep … | |
Re: I think hes really checking to see how many people will respond to a very old thread. So far 3, counting me. ;) Do you need to be a programmer to be a mathmatician? Or does the inverse logic not apply? | |
Code snippet to generate random passwords. Avoids using confusing characters such as lower case L (l) and the number one (1), the letter 'O' and the number zero. Upper-case alpha characters could be added to the character set if mixed-case passwords are desired. | |
Re: [QUOTE=Prakash_8111;987870]Hi Guys, Can any one suggest to generate a random number of eight digit. All suggestions are welcomed :)[/QUOTE] [url]http://www.daniweb.com/code/snippet216771.html[/url] A search engine would also find many examples of code to do what you are asking. | |
This code snippet will produce strings of numbers (1 thru 49) with no repeated numbers in the same string and no duplicated string of numbers in the list of strings. To change the range of numbers the script generates change 49 in the code to your requirements. Please feel free … | |
Re: You should put all the code in the same post. In your function you should use if/elsif/else instead of if/if/elsif. | |
Re: Image-Size has dependencies, so adding it via the lib pragma may not work unless the depenedencies are also added. It is a good way though to get image dimensions. |