469,323 Members | 1,575 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,323 developers. It's quick & easy.

%USERPROFILE% - What is this?

Hello All,
I have Perl code that looks like the following. $file is pointing to a directory on the C: drive that has 2 text files in it (let's say text_file_name1.txt and text_file_name2.txt).The lines of code to print out the names of the text files in the directory are:

[HTML]foreach $file(@result_files)
{
print "$file\n";
}[/HTML]

Can someone tell me why the print out gives me this:

C:/%USERPROFILE$
C:/text_file_name1.txt
C:/text_file_name2.txt

What is %USERPROFILE$? And why is it showing up???

Terra
Nov 28 '07 #1
8 6575
KevinADC
4,059 Expert 2GB
might be a file that is usually hidden from the user but perl picks it up.
Nov 28 '07 #2
numberwhun
3,503 Expert Mod 2GB
If you go into your file system browser and go to Tools->Folder Options, then go to the view tab in the window that appears, there is an option to "Show hidden files and folders". Select that radio button, hit Ok, and go to the folder and see what is there.

Regards,

Jeff
Nov 28 '07 #3
Thank you for your responses. i went into the Options folder and selected the ' Show hidden files and folders'. nothing showed up in my folder except the files that i expected. but Perl still picks up the %USERPROFILE%. Interesting.

Is there a way for Perl to ignore it? I tried to use shift(), which removes the first element in the array (and i thought it wouldd remove the %USERPROFILE% since it shows up first), but it didn't, it removed the first real file in my folder that i need to keep and kept printing the %USERPROFILE%.

This %USERPROFILE% is really messing up my overall script!!!

Help please!!
Nov 29 '07 #4
Here's a follow up to my previous reply...

I found a line that is supposed to ignore hidden files:

[HTML]next if $file =~ /^\./;[/HTML]

But Perl is still printing out the hidden file %USERPROFILE%. Does anyone know if this is close to being correct?


However, i think that %USERPROFILE% is a Windows Environment Variable, that should be dealt with differently than a hidden file...

Terra
Nov 29 '07 #5
eWish
971 Expert 512MB
See if this works for you.

Expand|Select|Wrap|Line Numbers
  1. foreach my $file (@array) {
  2.     next if $file =~ (/^\%/);
  3.     print $file, "\n";
  4. }
--Kevin
Nov 29 '07 #6
Well,
I figured out a solution, unless there is a better way to do it.

This line of code skips over the %USERPROFILE% hidden file as it goes through the array:

[HTML]foreach $file(@result_files)
{
next if $file eq 'C:\Folder Name\%USERPROFILE%';
print "$file\n";
}[/HTML]

It works, so i'm happy!

Terra
Nov 29 '07 #7
numberwhun
3,503 Expert Mod 2GB
Well,
I figured out a solution, unless there is a better way to do it.

This line of code skips over the %USERPROFILE% hidden file as it goes through the array:

foreach $file(@result_files)
{
next if $file eq 'C:\Folder Name\%USERPROFILE%';
print "$file\n";
}

It works, so i'm happy!

Terra
Thank you for letting us know! Thanks for assisting the OP with this problem eWish!

Regards,

Jeff
Nov 29 '07 #8
docdiesel
297 Expert 100+
Hi,

What is %USERPROFILE%? And why is it showing up???
as you guessed, %USERPROFILE% is a windows environment variable. It points to your windows settings and documents folder, usually paced under c:\docs and settings\username . What windows version are you working with? Is it Vista? I'm not sure, but afaik Vi$ta is working with some special and sometimes hidden entries in the home filesystem. This could be one of it.

Regards,

Bernd
Dec 1 '07 #9

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by James | last post: by
5 posts views Thread by Scott D | last post: by
2 posts views Thread by Nick | last post: by
1 post views Thread by Madhusudan Singh | last post: by
2 posts views Thread by Alexander Ross | last post: by
2 posts views Thread by msnews.microsoft.com | last post: by
11 posts views Thread by bsagert | last post: by
1 post views Thread by bsagert | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.