- 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
460 Posted Topics
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. | |
Given the date in mm-dd-yyyy (or M-D-YYYY) format (or any combination of that format) you can find out what day of the week that was on or is on or will be on, within the limitations of the system the script resides on. This snippet uses only core functions and … | |
Re: Looks like an error/typo in this line: unless (flag1 == 0) {die("Cannot open visitor_stat.txt");} missing the '$' before flag1, should be: unless ([B]$[/B]flag1 == 0) {die("Cannot open visitor_stat.txt");} | |
Convert 1000000 into 1,000,000 using a perl regexp. | |
Use the List::Util module. I believe List::Util is a core module starting with perl 5.8. For older versions of perl you may need to install the module. See the module documentation for more details: [URL="http://perldoc.perl.org/List/Util.html"]List::Util[/URL] | |
I've seen this question (or similar) asked many times on forums: I have a variable in a file (text) and want to expand it. For example, I have this line in a text file: Mary had a little $lamb and I want to be able to expand $lamb but text … | |
"How can I find all the permutations of a list (or a word)"? I have seen this question asked a number of times on forums. There is a module that makes this task very easy: List::Permutor. It is not a core module so you may need to install it. See … | |
You will need to install the Email::Valid module if it's not already installed. See the module documentation for further details. [URL="http://search.cpan.org/~rjbs/Email-Valid-0.176/lib/Email/Valid.pm"]Email::Valid[/URL] | |
The [URL="http://perldoc.perl.org/File/Basename.html"]File::Basename[/URL] module is used to parse file paths into directory, filename and suffix (or file extension). My simple example shows how to get just the file extensions. | |
Re: Mike, You have several very good replies on perlguru but here is your code rewritten to work: [code] [COLOR="Green"][I]# first open file for reading only[/I][/COLOR] open (INFILE, $ARGV[0]) or die "Error $ARGV[0]: $!\n"; @slurp = <INFILE>; close(INFILE); [COLOR="Green"][I]#now open file for overwriting[/I][/COLOR] open (OUTFILE, [COLOR="Red"]">"[/COLOR], $ARGV[0]) or die "Error $ARGV[0]: … | |
Re: You should just append a date to the end of the log file then you don't need to rename all the other files every time the script runs. | |
Re: Check the Windows server 2003 error logs. Hopefully there is something in the log that can help. Before you ask how, search google: [url]http://www.google.com/search?q=Windows+server+2003+error+logs[/url] | |
Re: Calling another perl script in a loop should not be difficult but the last part of your question makes no sense to me. [QUOTE]I want the second calling of the script shouldn't depend on the first calling.... all should run independently............[/QUOTE] ![]() | |
Re: Do the groups of lines with numbers break at the lines with text? In other words, do you only sort the numbers up to "test" as a group, and then sort the next set of lines with numbers until the next line with "test" or does the sorting of the … | |
Re: [QUOTE=bildja;939180]i'm sure 'file' is absolutely valid)[/QUOTE] cool, for the last 2 and a half years I've been wondering about that..... :-/ | |
Re: use sprintf to round off your numbers. [CODE=perl]my $t = 92.38495; $t = sprintf ("%.0f", $t); print $t;[/CODE] | |
Re: It aborts because you can't have nested quantifiers. Your expectation of what the "g" modifier does is also wrong. Here is an excerpt from perlretut: Global matching The final two modifiers //g and //c concern multiple matches. The modifier //g stands for global matching and allows the matching operator to … | |
Re: Normally in perl you don't worry about memory management. But instead of undef you can assign the variable an empty list/string and see if that helps free up memory. $var = ''; @var = (); %var = (); | |
Re: hashes are not randomly ordered lists, they are lists that don't have any guaranteed ordered, but they should always be the same order on the same computer. So that bug report appears to be erroneous because the reporter did not seem to understand that hashes are not randomly ordered. If … |
The End.