On 24 February 2010 15:03, HACKER Nora <nora.hac...@stgkk.at> wrote: >> Normally <ARGV> - shortened to <> is preferable over <STDIN>; > > I initially used this syntax but received an error because I start my > script with 1-2 parameters (one required, second one optional): > > oracle:/opt/data/magna/wartung>dbmove.pl T D > Can't open T: No such file or directory at > /opt/data/magna/wartung/dbmove.pl line 291. > Can't open D: No such file or directory at > /opt/data/magna/wartung/dbmove.pl line 291. > > With <STDIN> this works.
<STDIN> suggest dynamic input from the user during runtime. While @ARGV/<ARGV>/<> refers to commandline arguments sent before running the program. If you iterate over them using the idiomatic while(<>){} loop, you'll have a better way of making sure you only run over the values that were given. Also, what Shlomi mentions is a practice, not a rule, if you prefer calling for input from <STDIN> rather than a command-line argument, that's your prerogative. > I am very sorry but I do not understand what you mean. My aim is to > enable the user to define a complete substitution syntax for getting a > username from a database name (after a fixed scheme). (See the code from > the config file above.) > Some here tends to miss the whole "beginner" part of the list and go for the throat. There are ways in Perl to do almost anything you can think of, but they tend to be somewhat more complicated and rely on more thorough knowledge of the language and what it can do (and how it does it). At any rate, the answer is what you need to do. If you always need to remove "db$", then all you need to do is write that in your code and keep a list of the values in your config part: my $cuttux='db'; ... $deftux =~ s/$cuttux$//g; However, part of the answer is knowing the question. If this doesn't do the trick for you, a more thorough description would come in handy. For instance, where will "db" come from, how many of these you want to use and how to call them, etc. Hope this helps, -- Erez Support the New Israeli Fund - http://www.nif.org/ -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/