Thanks Miller!
#>perl scratch.pl -x="-number 1 -string abc"
#userprog = '-number 1 -string abc'
The '=' is fine!
Jerin
User Profile
Collapse
-
Use GetOpt option to read in string containing "-S -DWT"
Hi,
I'm not very familiar with Perl but got around to using the GetOpt module. One of my inputs strings contains a '-' character, but I don't want the GetOpt to parse it.
eg.
my_perl_file -x "-number 1 -string abc"
GetOptions("h"= >\$hflag,
"x:s", \$user_prop);
I want the GetOpt to get $user_prop as "-number 1 -string... -
overriding new operator with extra parameters
I'm trying to track memory leaks by keeping track of the new and delete operators are called.
I've declared new operator as:
void* operator new (size_t size, const char *file, int line)
{
//code to store info abt the new call.
}
I want to define macros that can replace new and delete calls in existing code with a new that is passed object type, current line number and file name.... -
use this:
time_t seconds = time(NULL); //make sure this is declared at the beginning of the block
srand(seconds);
int a = rand();
If you want to generate the same set of random numbers again and again then seed srand with the same number instead of seconds - ideally pass this as a command line argument or a define at the top of your code.Leave a comment:
No activity results to display
Show More
Leave a comment: