415 Posted Topics
Re: I'm no expert but I don't see why push can't be done based on the result of a condition such as an if statement. Here's an example: [CODE]<html> <body> <script type="text/javascript"> var arr = new Array(0); var s = ""; while (s != "quit") { s = prompt("Enter a word", … | |
Re: Try the following character class: [ICODE]var illegalChars = /[\u0021-\u002f\u003a-\u0040\u005b-\u005e\u0060\u007b-\u007e]/g; // Don't allow any of these[/ICODE] Javascript supports specifying unicode characters by hexadecimal expressions like [ICODE]\u0060[/ICODE] and ranges like [ICODE]\u007b-\u007e[/ICODE]. There is a fun website at [URL="http://hamstersoup.com/javascript/regexp_character_class_tester.html"]http://hamstersoup.com/javascript/regexp_character_class_tester.html[/URL] that gives you the unicode expressions for any character class you specify. | |
Re: In case it makes a difference, is your platform *nix, Windows or Mac? I don't know much about http or curl but before using the system command make sure the $cmd variable has been built successfully. You may want to use Perl's quote operator qq(). [CODE]#!/usr/bin/perl -w use strict; my … | |
Re: I'm on Windows and don't have the scp utility so can't test your code but I notice you use the variable $currentTranStats without having assigned a value to it. Also note that while a dot between two text variables acts as the concatenation operator, a dot within double quotes is … | |
Re: [QUOTE]final = reorder(a, b)[/QUOTE] Look at line 18 of your first example, where you test your first function. Variables a and b have meaning [I]only[/I] in your function. You need to pass the variables first_str and second_str when you call your function, not a and b, which are out of … | |
Re: [QUOTE]I have a quesion for my problem with using mysql and perl programming.[/QUOTE] I think that is a good question but to avoid confusion please start a new thread for it, instead of posting it as a reply to this thread's question. | |
Re: [QUOTE=notuserfriendly;1027477]So basically what you are saying onaclov2000 is that the only way to delete a line is to write the whole thing in a different file omitting the line you do not want that begins with the specified string?[/QUOTE] Pardon my jumping in. I'm new to Perl but I have … | |
Re: The following program parses the string and stores the substrings in an array or list. So far I haven't figured out how to put the contents of this array into a hash that would be useful. [CODE]#!/usr/bin/perl -w use strict; $_ = "OWN - NLM " . "STAT- Publisher " … | |
Re: Unless you have to use an array you could also do the following. [CODE]#!/usr/bin/perl -w #CountLetters.pl use strict; print "Enter string of letters: "; chomp (my $input = <STDIN>); my ($char, $count, $verb, $s); print "\n"; while ($input =~ m/(.)/g) { $char = $1; #Count and remove all instances of … | |
Re: Sometimes it's simpler to read the entire document into one string variable and then apply a series of global substitute commands. The nice thing about this way is you can add a substitute command to your program, run it, visually inspect the output, then add another substitute command, test again … | |
Re: This may work for you. From looking at the files as they appear in your post (without code tags) it's hard to know if there are supposed to be spaces, carriage returns, or line-feed characters separating the records, or whether they are fixed or variable length. I attached the input … | |
Re: You can create a regular expression like the one in the variable called myRegExPattern to match any character listed between the square brackets. The square brackets define a "character class" aka "character set". Then replace each character that is matched. [CODE]<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"> <!-- Hide from browsers that do not … | |
Re: I can't see where the columns are in your example because this website reduces multiple spaces to single spaces. If you wrap your example in code tags (click the "Help with Code Tags" link for instructions) we can see how your example data really is appearing to you. For example, … | |
Re: jice's solution looks good to me, unless you want only a slice of the second data line and want to convert the FCITC string into an integer. Here it is with a couple of minor changes to do that. [CODE=PYTHON]noline=0 for line in open("fcitc.txt"): if noline==1: fcitc=line[:9].strip() intFCITC = int(float(fcitc)) … | |
Re: [CODE=PYTHON]if coursenum in courselistA: #courselistA is the set of course numbers #Convert courselistA into a list and use list comprehension print [x for x in list(courselistA) if x > coursenum][/CODE] |
The End.