You might try looking at the Getopt::Std module, or the Getopt::Long module - read the perldocs on these modules that come included with Perl by doing
perldoc Getopt::Std
or
perldoc Getopt::Long
at a command prompt.
HTH. Hardy Merrill
I'll add a few cents of my own ;-)
I've used both - Perl is a more mature, very stable language - I like Perl a lot - for everything. Perl as DBI for database integration, which is excellent and rock solid - as of 1 1/2 years ago(I haven't used PHP in the last year and a half), PHP didn't have...
Backticks is the easiest solution, but just for the sake of completeness, I'll offer this:
$ls_command = "ls -rltd $file |";
open(LS_COMMAND,"ls -l message |) || die "Can't open the ls command!";
while (<LS_COMMAND>) {
print "Here is a line of ls output...
Are you using the DBI and DBD::mysql modules in Perl?
Assuming you have DBI and DBD::mysql installed, you could create a script do this:
1. connect to mysql database
2. select all rows in table B
3. for each row in table B
save value of column x in variable $x
SELECT x...
jamisar, sorting was something that I chose to do - it is *NOT* necessary. I copied and pasted that from something I use to display the enviroment variables in a cgi script, and the sort just happened to be in there.
HTH.
Hardy Merrill Hardy Merrill
I'm a python newbie, and I'm trying to use "getopt" to process command line arguments. I'd like to be able to specify a command line option that *could* have an associated argument, but getopt is forcing me to declare each option to be
*either*
1. with an associated argument
*or*...
You really need to read up on Perl - start by doing
perldoc perl
at a command prompt.
The way data validation is done in Perl is normally by using regular expressions - read about Perl regular expressions by doing
perldoc requick
and/or
perldoc perlretut
HTH. Hardy Merrill
/([^(asdf)]*)/
The square brackets means character class - each character in between the square brackets is a member of a character class that you are defining.
When you say [^(asdf)] you are really saying match any character which is not(^) one of the characters "(", "a"...
How did you figure that out? I just looked through the 'perldoc perlwin32' and I didn't see anything like that - I couldn't really find anything on windows paths needing the directories separated by *forward* slashes. I'm confused ;-) Hardy Merrill
Does your open look like
open(LOG, ">C:\Program Files\Abria Merlin\Apache\htdocs\site\test1.txt") || &ErrorMessage;
???
What error message(s) are you getting?
Not sure about Windows, but on *nix, you need to ensure that the user("apache" or "nobody" or ???)...
The "sleep" function usually works - not sure on Win NT thought. Do 'perldoc -f sleep' at a command prompt to see the perldocs on "sleep".
HTH. Hardy Merrill
If you don't get an answer here or in MS SQL, ask your question on the DBI mailing list - there are many excellent people on that list, including many who are very knowledgable about Sybase and DBD::Sybase.
HTH. Hardy Merrill
my $abs_file = "/path/to/file";
open(IN, "<$abs_file") || die "Can't open $abs_file!"
while(<IN>) {
if (/^\d\d\d/) {
### This is a good line - it starts with 3 digits
}
}
HTH. Hardy Merrill
I can't be much help on the Windows platform - I'm on Red Hat Linux 7.3. Assuming you'll use ODBC, you'll need DBI and DBD::ODBC (I think - I've never used ODBC, but I'm pretty sure that's what the DBD driver is called) - you can find them at www.cpan.org, or search.cpan.org.
Once you've...
If Perl can do it, my guess is that the "stat" function would be *the* function. But according to 'perldoc -f stat'
stat FILEHANDLE
stat EXPR
stat Returns a 13-element list giving the status info
for a file, either the file opened via...
I guess I don't understand. Won't
my $stdout = \*STDOUT;
give you what you want in $stdout? Then, if you do
print $stdout "Some text or something\n";
won't that go to the file that STDOUT is pointing to?
What am I missing? Hardy Merrill
At a command prompt, do
perldoc -f die
to read what the "die" does.
You could say
open(MCF,"member_colour_file.txt") || print "error message";
but after printing "error message", your program would continue on, which is not what you want.
I'd...
One thing I forgot to mention - if your system already has Perl on it, Perl *comes with* excellent documentation called "perldocs". To get started, you can do
perldoc perl
at a command prompt - that will list all the different topics covered by the perldocs. Then, to look at one...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.