RE: directory again
> -Original Message- > Behalf Of Dirk Bremer > > > $#ARGV contains the number of arguments minus one in @ARGV, i.e. > the first argument is $ARGV[0]. Sample code: > > # Check that the required number of arguments have been passed. > if ($#ARGV < 0) > { > Help(); > $InputFile = GetUserInput('Enter the input filename',0); > } > else {$InputFile = $ARGV[0];} > > # Check for optional second argument. > if ($#ARGV > 0) {$NbrPages = $ARGV[1];} > > # Check for optional third argument. > if ($#ARGV > 1) {$Width = $ARGV[2];} > else {$Width = 80} > Alternatively... my($InputFile, $NbrPages, $Width) = @ARGV; # Check that the required number of arguments have been passed. if (!defined $InputFile or $InputFile eq "") { Help(); $InputFile = GetUserInput('Enter the input filename',0); } # Check for optional second argument (make sure it is undef.) ($NbrPages = undef) if (defined $NbrPages and $NbrPages eq ""); # Check for optional third argument. ($Width = 80) if (!defined $Width or $Width eq ""); ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
Re: directory again
$#ARGV contains the number of arguments minus one in @ARGV, i.e. the first argument is $ARGV[0]. Sample code: # Check that the required number of arguments have been passed. if ($#ARGV < 0) { Help(); $InputFile = GetUserInput('Enter the input filename',0); } else {$InputFile = $ARGV[0];} # Check for optional second argument. if ($#ARGV > 0) {$NbrPages = $ARGV[1];} # Check for optional third argument. if ($#ARGV > 1) {$Width = $ARGV[2];} else {$Width = 80} In the above code, if no arguments were entered on the command line, the Help() function will be called, else the $InputFile will be assigned the first argument. If there is more than one argument, $NbrPages will be assigned the second argument. If there is more than two arguments, $Width will be assigned the third argument, etc. For options (flags) such as -d, check out the Getopt module. For example: use Getopt::Std; # Check if the -h option was entered. our $opt_h; getopts('h'); # If the -h option was entered, print the help and exit the program. if (defined $opt_h) { Help(); exit(1); } In the above code, it is checking for a -h option to be entered. Note that you must declare a variable for each option. So if we use -d and -h as options, we would need to change the our statement above to be something like: our ($opt_d,$opt_h) You can then simply test if they are defined to determine whether or not they have been entered. All of this information is in the Camel book, if you don't have it, get it, if you have it, please read it. Dirk Bremer - Systems Programmer II - AMS Department - NISC 636-922-9158 ext. 652 fax 636-447-4471 <mailto:[EMAIL PROTECTED]> - Original Message - From: "Tanya Graham" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, May 31, 2001 4:02 PM Subject: RE: directory again > Does anyone know where I can find information on passing parameters (flags) > on the command line? > thank you > tanya > > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: Thursday, May 31, 2001 9:13 AM > To: '[EMAIL PROTECTED]' > Subject: Re: directory again > > > > >Hi, > >I need to be able to recursively go through a directory and if i encounter > a > >file folder, perform the same actions on the files in that file folder. > is > >there a simple way to do this, like with an if-statement? > >thanks > >tanya graham > > Tanya, > > Please try to avoid replying with someone else's post, and just changing > the subject, it's confusing. > > Everyone here seems to have gone far out of their way to respond to your > earlier directory dilemma, including me, so allow me to now voice a few > suggestions. > > From your previous post, and this one I think it's fair to assume you are > very new to perl. The reason I like this mailing list so much is that they > are very kind to newbies, and I've never seen a flame war on this list. > Being new, it's often easy to not even know where the documentation is. > First, check the FAQ's, they are installed in HTML format when you install > ActiveState perl, many "easy" problems can be resolved right there. Many > people in response to your previous post pointed towards perldoc (perldoc > -f opendir ) as a tool to find information about function and module usage. > Another tool is PPM, which you can use to search for modules and install > them from ActiveState's (or any other ) ppm repository. Often it's good to > run a search for what you're looking for through there (such as "dir" or > "file" in your case), install a few "likely" sounding packages and then run > perldoc on them to see if they offer the features you are really looking > for. You can type "help" in ppm for usage help, and perldoc perldoc will > give you more than you ever wanted to know about how to use perldoc. Also > look at the O'Reilly series of perl books, as they are invaluable > resources. You can find info on them at www.perl.com. I apoligize to all > for this long post, but while I think none of us has a problem helping, I > personally have a problem when someone doesn't help themself first. > > To answer your current question, you may want to take a look at the > File::Find module as this will recurse through a directory tree and can > perform a specified callback (subroutine) on each file it finds. > > Sorry for the long post, > > Chuck > > > > ___ > Perl-Win32-Users mailing list > [EMAIL PROTECTED] > http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users > ___ > Perl-Win32-Users mailing list > [EMAIL PROTECTED] > http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users > > ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
RE: directory again
i found it...for some reason since i couldn't find "parameters" in the index i freaked out, and after a few minutes i realized i could look up "arguments"...been a long day... tanya -Original Message- From: Trever Furnish [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 31, 2001 2:33 PM To: Tanya Graham; [EMAIL PROTECTED] Subject: RE: directory again Unix: man perlrun Windows: Open the perl documentation and read the section titled "perlrun". Both: Take two aspirin. > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED]]On Behalf Of > Tanya Graham > Sent: Thursday, May 31, 2001 4:02 PM > To: '[EMAIL PROTECTED]' > Subject: RE: directory again > > > Does anyone know where I can find information on passing > parameters (flags) > on the command line? > thank you > tanya > > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: Thursday, May 31, 2001 9:13 AM > To: '[EMAIL PROTECTED]' > Subject: Re: directory again > > > > >Hi, > >I need to be able to recursively go through a directory and if i > encounter > a > >file folder, perform the same actions on the files in that file folder. > is > >there a simple way to do this, like with an if-statement? > >thanks > >tanya graham > > Tanya, > > Please try to avoid replying with someone else's post, and just changing > the subject, it's confusing. > > Everyone here seems to have gone far out of their way to respond to your > earlier directory dilemma, including me, so allow me to now voice a few > suggestions. > > >From your previous post, and this one I think it's fair to assume you are > very new to perl. The reason I like this mailing list so much is > that they > are very kind to newbies, and I've never seen a flame war on this list. > Being new, it's often easy to not even know where the documentation is. > First, check the FAQ's, they are installed in HTML format when you install > ActiveState perl, many "easy" problems can be resolved right there. Many > people in response to your previous post pointed towards perldoc (perldoc > -f opendir ) as a tool to find information about function and > module usage. > Another tool is PPM, which you can use to search for modules and install > them from ActiveState's (or any other ) ppm repository. Often > it's good to > run a search for what you're looking for through there (such as "dir" or > "file" in your case), install a few "likely" sounding packages > and then run > perldoc on them to see if they offer the features you are really looking > for. You can type "help" in ppm for usage help, and perldoc perldoc will > give you more than you ever wanted to know about how to use perldoc. Also > look at the O'Reilly series of perl books, as they are invaluable > resources. You can find info on them at www.perl.com. I apoligize to all > for this long post, but while I think none of us has a problem helping, I > personally have a problem when someone doesn't help themself first. > > To answer your current question, you may want to take a look at the > File::Find module as this will recurse through a directory tree and can > perform a specified callback (subroutine) on each file it finds. > > Sorry for the long post, > > Chuck > > > > ___ > Perl-Win32-Users mailing list > [EMAIL PROTECTED] > http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users > ___ > Perl-Win32-Users mailing list > [EMAIL PROTECTED] > http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users > ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
RE: directory again
Unix: man perlrun Windows: Open the perl documentation and read the section titled "perlrun". Both: Take two aspirin. > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED]]On Behalf Of > Tanya Graham > Sent: Thursday, May 31, 2001 4:02 PM > To: '[EMAIL PROTECTED]' > Subject: RE: directory again > > > Does anyone know where I can find information on passing > parameters (flags) > on the command line? > thank you > tanya > > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: Thursday, May 31, 2001 9:13 AM > To: '[EMAIL PROTECTED]' > Subject: Re: directory again > > > > >Hi, > >I need to be able to recursively go through a directory and if i > encounter > a > >file folder, perform the same actions on the files in that file folder. > is > >there a simple way to do this, like with an if-statement? > >thanks > >tanya graham > > Tanya, > > Please try to avoid replying with someone else's post, and just changing > the subject, it's confusing. > > Everyone here seems to have gone far out of their way to respond to your > earlier directory dilemma, including me, so allow me to now voice a few > suggestions. > > >From your previous post, and this one I think it's fair to assume you are > very new to perl. The reason I like this mailing list so much is > that they > are very kind to newbies, and I've never seen a flame war on this list. > Being new, it's often easy to not even know where the documentation is. > First, check the FAQ's, they are installed in HTML format when you install > ActiveState perl, many "easy" problems can be resolved right there. Many > people in response to your previous post pointed towards perldoc (perldoc > -f opendir ) as a tool to find information about function and > module usage. > Another tool is PPM, which you can use to search for modules and install > them from ActiveState's (or any other ) ppm repository. Often > it's good to > run a search for what you're looking for through there (such as "dir" or > "file" in your case), install a few "likely" sounding packages > and then run > perldoc on them to see if they offer the features you are really looking > for. You can type "help" in ppm for usage help, and perldoc perldoc will > give you more than you ever wanted to know about how to use perldoc. Also > look at the O'Reilly series of perl books, as they are invaluable > resources. You can find info on them at www.perl.com. I apoligize to all > for this long post, but while I think none of us has a problem helping, I > personally have a problem when someone doesn't help themself first. > > To answer your current question, you may want to take a look at the > File::Find module as this will recurse through a directory tree and can > perform a specified callback (subroutine) on each file it finds. > > Sorry for the long post, > > Chuck > > > > ___ > Perl-Win32-Users mailing list > [EMAIL PROTECTED] > http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users > ___ > Perl-Win32-Users mailing list > [EMAIL PROTECTED] > http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users > ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users
RE: directory again
Does anyone know where I can find information on passing parameters (flags) on the command line? thank you tanya -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 31, 2001 9:13 AM To: '[EMAIL PROTECTED]' Subject: Re: directory again >Hi, >I need to be able to recursively go through a directory and if i encounter a >file folder, perform the same actions on the files in that file folder. is >there a simple way to do this, like with an if-statement? >thanks >tanya graham Tanya, Please try to avoid replying with someone else's post, and just changing the subject, it's confusing. Everyone here seems to have gone far out of their way to respond to your earlier directory dilemma, including me, so allow me to now voice a few suggestions. >From your previous post, and this one I think it's fair to assume you are very new to perl. The reason I like this mailing list so much is that they are very kind to newbies, and I've never seen a flame war on this list. Being new, it's often easy to not even know where the documentation is. First, check the FAQ's, they are installed in HTML format when you install ActiveState perl, many "easy" problems can be resolved right there. Many people in response to your previous post pointed towards perldoc (perldoc -f opendir ) as a tool to find information about function and module usage. Another tool is PPM, which you can use to search for modules and install them from ActiveState's (or any other ) ppm repository. Often it's good to run a search for what you're looking for through there (such as "dir" or "file" in your case), install a few "likely" sounding packages and then run perldoc on them to see if they offer the features you are really looking for. You can type "help" in ppm for usage help, and perldoc perldoc will give you more than you ever wanted to know about how to use perldoc. Also look at the O'Reilly series of perl books, as they are invaluable resources. You can find info on them at www.perl.com. I apoligize to all for this long post, but while I think none of us has a problem helping, I personally have a problem when someone doesn't help themself first. To answer your current question, you may want to take a look at the File::Find module as this will recurse through a directory tree and can perform a specified callback (subroutine) on each file it finds. Sorry for the long post, Chuck ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users ___ Perl-Win32-Users mailing list [EMAIL PROTECTED] http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users