perl code problem (open file) - Unix

This is a discussion on perl code problem (open file) - Unix ; 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 ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: perl code problem (open file)

  1. 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


  2. Re: perl code problem (open file)

    On 2005-08-30, yezi wrote:
    > 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
    >


    Use the glob command.

    $ perldoc -f glob

  3. Re: perl code problem (open file)

    In article ,
    Mike writes:
    > On 2005-08-30, yezi wrote:
    >> 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
    >>

    >
    > Use the glob command.
    >
    > $ perldoc -f glob


    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
    -----


+ Reply to Thread