Wednesday, May 21, 2008

I m working on loops (For- while commands). I noticed that after the loop is finished you need to close the file and opn it again so that the cursor or the line $_ will start again from the top once you tried to loop the fil again. Is there anyway to make the cursor or line to go to the top of the file again while looping instead of closing an opening the file again and start another loop?

I have a freeboard website and have a trouble with image uploading. When users try to attach an image file- they get a square box with red x in it. Until I change the file permission to 644- they can t see the image. I want a script that will automatically change the file permission to 644 the moment they upload the file- so i don t have to go through every single file to change the permissions. I found something like:

#!/usr/bin/perl
$permissionNum = 0644;
$dirtoopen = "../board/";
opendir (DIR- "$dirtoopen") or die "This is not the correct directory";
@dirdata = readdir(DIR);
closedir (DIR);
$changed = chmod 0644- @dirdata;
print "Content-type: text/html\n\n";
print "$changed files changed to $permissionNum";
BUT!!
1): the file permissions doesn t change to 644- but rather something random. also- 2) this isn t automatic. It s simply useful for changing permissions of bunch of files at once(like 1000 files). Could someone help me with the script. this is urgent!! thx!
By the way I m using windows. I ve been getting infos about how chmod is for linux only? is there a different code for windows?
So is there a specific different function for windows?

Hello-
I am currently running openWrt on wrt54gl router. I have installed full perl (5.8)- and I can run scripts that do no require any modules (other than the base ones- for example- printing "hello world" works just fine). However- when i try to run scripts with "use <module>"- I get error like this-

Can t load /usr/lib/perl/5.8/auto/IO/IO.so for module IO: Unable to resolve symbol at /usr/lib/perl/5.8/XSLoader.pm line 83.
at /usr/lib/perl/5.8/IO.pm line 9
Compilation failed in require at /usr/lib/perl/5.8/IO/Handle.pm line 256.
BEGIN failed--compilation aborted at /usr/lib/perl/5.8.0/IO/Handle.pm line 256.
Compilation failed in require at /usr/lib/perl/5.8.0/IO/Socket.pm line 11.
BEGIN failed--compilation aborted at /usr/lib/perl/5.8.0/IO/Socket.pm line 11.
Compilation failed in require.
BEGIN failed--compilation aborted.

Any one know how to fix it?? thanks
OK so after some investigation- it turned out that it was a kernel problem- and after I updated perl- and recompiled some modules- everything was fine.

Sample Data:
<tocelement name="New classification and
<tocelement name="Gestational diabetes mellitus
<tocelement name="Glycohaemoglobin: a
1997" ca= "ANZ"
<tocelement name="The prevention
<tocelement name="Diabetes and
</tocdivision>

Program:
while (<TEMP1>)
{
$CountTB=substr $_-0-1;
print $CountTB;
if ($CountTB eq "<")
{
print TEMP2 $_;
}
else
{
print "OK";
print "\b"- TEMP2 $_;
}
}

Problem:
I want the " 1997......" to be in 1 line before it. Meaning all lines must first start with "<" since the file is an xml. how am i gonna do it. i have a sample program but everytime i ran it- it stops at the sntence " 1997......" please help????

Correct output i want:
<tocelement name="New classification and
<tocelement name="Gestational diabetes mellitus
<tocelement name="Glycohaemoglobin: a 1997" ca= "ANZ"
<tocelement name="The prevention
<tocelement name="Diabetes and
</tocdivision>

No comments: