Professional Web Applications Themes

perl code problem (open file) - Linux / Unix Administration

HI, Everyone: I have question regarding to the perl code. The task is open a tons of files one by one according to the serial number order and process the context in these files.However the file should be specified by the serial number and site name. The name of file has structure like that: serial number. site name . * .like : 0.site1.1.23.txt.rd.ed 1.site1.2.23.txt.rd.ed 3.site1.3.24.txt.rd.ed which means only one column "site1" is same, so my question is can I write following code to open them ? open myfile,"$serial.$site.*.ed" or die "Could not open file $serial.$site for reading/n"; Can I use ...

  1. #1

    Default perl code problem (open file)

    HI, Everyone:

    I have question regarding to the perl code. The task is open a tons of
    files one by one according to the serial number order and process the
    context in these files.However the file should be specified by the
    serial number and site name.

    The name of file has structure like that:
    serial number. site name . * .like :

    0.site1.1.23.txt.rd.ed
    1.site1.2.23.txt.rd.ed
    3.site1.3.24.txt.rd.ed

    which means only one column "site1" is same, so my question is can I
    write following code to open them ?

    open myfile,"$serial.$site.*.ed" or die "Could not open file
    $serial.$site for reading/n";

    Can I use * in the open file function? I tried, but fail. I do not know
    why, how to relize the function?

    thanks for any comments

    yezi Guest

  2. #2

    Default Re: perl code problem (open file)

    On 2005-08-30, yezi <com> wrote: 

    Use the glob command.

    $ perldoc -f glob
    Mike Guest

  3. #3

    Default Re: perl code problem (open file)

    In article <H11Re.20835$lga>,
    Mike <ath.cx> writes: 
    >
    > Use the glob command.
    >
    > $ perldoc -f glob[/ref]

    I'd also suggest "subscribing" to comp.lang.perl.misc or
    comp.lang.perl.moderated. Both are inhabited by experienced perl users who
    are, for the most part, happy to answer questions about their favorite language.

    Bob Melson

    --
    Robert G. Melson | Rio Grande MicroSolutions | El Paso, Texas
    -----
    "One of the greatest delusions in the world is the hope that the evils in this world are to be cured by legislation." Thomas Reed
    -----

    Robert Guest

Similar Threads

  1. Replies: 1
    Last Post: February 19th, 06:24 PM
  2. Open file, make changes, save file, close, re-open, file contents not changed
    By brock@bergdesign.com in forum Adobe Illustrator Macintosh
    Replies: 7
    Last Post: March 7th, 07:29 PM
  3. cli file open problem
    By Gareth Thomas in forum PHP Development
    Replies: 0
    Last Post: August 4th, 03:50 AM
  4. Replies: 3
    Last Post: July 16th, 01:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139