Re: Using Substr and Regular expressions.



On Feb 23, 10:21 am, "Dan Mercer" <damer...@xxxxxxxxxxx> wrote:

My guess is that if you have to ask this question, you're not ready
to program in perl yet. A number of solutions are available:

use strict;
use warnings;
my $num;
my $name;
($num,$name) = (split /_/,$ARGV[0])[1,2];

is just one of many possibilities.

Dan Mercer


Dan,

Your blunt response "My guess is that if you have to ask this
question, you're not ready to program in perl yet." is not far from
the truth.

I only recently started to "learn" perl ( 2 days ago). I am modifying
a script that was given to me to preform a specific task. I wanted to
make the script easier to use but I was not having much luck with the
tutorials I found on the web. I figured posting here was a great
place to find information that I required.

I have tried both Manish and your suggestions ( both of which work
fine) with a few modifications.

Some of my main holdbacks on perl where syntactical ( I actually had
something similar to your version using the split function but only
one variable).

Anyway, thanks to everyone for all of your examples and help! Now I
have a lot of things to research.
Kent




.



Relevant Pages

  • Re: Using Substr and Regular expressions.
    ... :> to program in perl yet. ... :> Dan Mercer ... make the script easier to use but I was not having much luck with the ... tutorials I found on the web. ...
    (comp.lang.perl.misc)
  • Re: Using Substr and Regular expressions.
    ... :> to program in perl yet. ... :> Dan Mercer ... make the script easier to use but I was not having much luck with the ... tutorials I found on the web. ...
    (comp.lang.perl.misc)
  • Ways of ensuring integers in the database are seen as numbers in perl?
    ... I'd like my database returned integers to look like integers to Perl but they currently don't until I add 0 to them. ... The reason for this is that adding 0 to a Perl scalar seems to persuade Perl the scalar is an integer. ... $num as returned from database: ...
    (perl.dbi.users)
  • Re: join two binary numbers
    ... use warnings; ... Perl is doing an bitwise or of each *byte* of the two strings, padding $num of the right with two zero bytes to match the length of $res. ...
    (comp.lang.perl.misc)
  • Re: Integer data type
    ... print $num; ... Why $num is bigger than LONG_MAX? ... Perl doesn't have an int and string and char ... Perl has a scalar and an array and a hash. ...
    (perl.beginners)