a numbering question

Discussion in 'Perl Misc' started by Geoff Cox, May 4, 2005.

  1. Geoff Cox

    Geoff Cox Guest

    Hello,

    I have some images named as

    pic001.gif through pic010.gif to pic200.gif

    I am not clear how I can use something like

    pic$number++

    any pointers please!

    Cheers

    Geoff
     
    Geoff Cox, May 4, 2005
    #1
    1. Advertising

  2. Geoff Cox wrote:

    > Hello,
    >
    > I have some images named as
    >
    > pic001.gif through pic010.gif to pic200.gif
    >
    > I am not clear how I can use something like
    >
    > pic$number++
    >
    > any pointers please!
    >
    > Cheers
    >
    > Geoff


    check out sprintf.

    Mark
     
    Mark Clements, May 4, 2005
    #2
    1. Advertising

  3. Geoff Cox wrote:
    > I have some images named as
    > pic001.gif through pic010.gif to pic200.gif
    > I am not clear how I can use something like
    > pic$number++


    Does it have to be a separate "pic" and $number or would it be possible to
    increment the file name as a whole?

    my $name = "pic001";
    for (0..20) {
    print $name++ . ".gif\n";
    }

    jue
     
    Jürgen Exner, May 4, 2005
    #3
  4. Geoff Cox <> wrote:

    > I have some images named as
    >
    > pic001.gif through pic010.gif to pic200.gif
    >
    > I am not clear how I can use something like
    >
    > pic$number++
    >
    > any pointers please!



    my $filename = sprint 'pic%03d.gif', $number++; # untested


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, May 4, 2005
    #4
  5. Geoff Cox

    Geoff Cox Guest

    On Wed, 04 May 2005 13:17:38 GMT, "Jürgen Exner"
    <> wrote:

    Jue,

    Thanks for your suggestion below - it made me realise my silly mistake
    - I had an initial value of 1 for $number ! When I changed to 0001 all
    is well.

    Thanks

    Geoff

    >Geoff Cox wrote:
    >> I have some images named as
    >> pic001.gif through pic010.gif to pic200.gif
    >> I am not clear how I can use something like
    >> pic$number++

    >
    >Does it have to be a separate "pic" and $number or would it be possible to
    >increment the file name as a whole?
    >
    >my $name = "pic001";
    >for (0..20) {
    > print $name++ . ".gif\n";
    >}
    >
    >jue
    >
     
    Geoff Cox, May 4, 2005
    #5
  6. Geoff Cox

    Geoff Cox Guest

    On Wed, 4 May 2005 11:48:27 -0500, Tad McClellan
    <> wrote:

    > my $filename = sprint 'pic%03d.gif', $number++; # untested


    Thanks Tad - will give it a try.

    Cheers

    Geoff
     
    Geoff Cox, May 4, 2005
    #6
  7. Geoff Cox

    Geoff Cox Guest

    On 04 May 2005 19:59:15 GMT, Abigail <> wrote:

    >Geoff Cox () wrote on MMMMCCLXIV
    >September MCMXCIII in <URL:news:>:
    >)) Hello,
    >))
    >)) I have some images named as
    >))
    >)) pic001.gif through pic010.gif to pic200.gif
    >))
    >)) I am not clear how I can use something like
    >))
    >)) pic$number++
    >))
    >)) any pointers please!
    >
    >
    >$ perl -wle '$f = "pic001"; print + $f ++ . ".gif" for 1 .. 10'


    Thanks - will try this out..

    Cheers

    Geoff

    >pic001.gif
    >pic002.gif
    >pic003.gif
    >pic004.gif
    >pic005.gif
    >pic006.gif
    >pic007.gif
    >pic008.gif
    >pic009.gif
    >pic010.gif
    >
    >
    >Abigail
     
    Geoff Cox, May 4, 2005
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. buran

    numbering rows in datagrid

    buran, Jul 7, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    483
    Saravana
    Jul 7, 2003
  2. buran

    numbering rows in datagrid

    buran, Oct 15, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    537
    Cowboy \(Gregory A. Beamer\)
    Oct 15, 2003
  3. =?Utf-8?B?Q2hyaXM=?=

    form field auto numbering with unique value

    =?Utf-8?B?Q2hyaXM=?=, Dec 31, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    465
    John Saunders
    Jan 1, 2005
  4. Andy Fish
    Replies:
    2
    Views:
    469
    Andy Fish
    Apr 5, 2005
  5. Richard Shea
    Replies:
    7
    Views:
    1,282
    Paul A. Hoadley
    Jan 16, 2004
Loading...

Share This Page