Unix administration - perl code problem (open file)

This is Interesting: Free IT Magazines  
Home > Archive > Unix administration > August 2005 > perl code problem (open file)





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author perl code problem (open file)
yezi

2005-08-30, 6:00 pm

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

Mike

2005-08-30, 6:00 pm

On 2005-08-30, yezi <ye_line@hotmail.com> 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
Robert Melson

2005-08-30, 6:00 pm

In article <H11Re.20835$1g2.20562@fe05.lga>,
Mike <mikee@mikee.ath.cx> writes:
> On 2005-08-30, yezi <ye_line@hotmail.com> wrote:
>
> 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
-----

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com