Hi,
I guess what you can do is:
$string="false";
open(FNAME, 'c:\Scripts\phile.txt') or die "I can't find your file\n";
while (<FNAME>){
if(/word/){
$string = "true";
last;
}
}
close(FNAME);
print $string;
Miller,
Thanks for your reply. I can't say I fully understand what's going on yet. I'm a quasi-programmer who only codes if I have a project that requires some sort of automated file/text manipulation (and that's very rare). I will read up on what exactly every line in your code does.
Thanks...
Hi Kevin,
The ijk's are going to be loop variables. So it's like writing out the summation series in loops. Anyway I've decided to do it a more complicated way, so that I can make sure the substitution takes place even if there're random whitespace characters in the square brackets. Here's my...
Thanks Kevin. Even though the example I gave was two dimensional, there are potentially multi-dimensional equations, such as Vin[i, j, k]. Is there a more general way of searching and replacing within the square brackets? Thanks!
Hi,
For the following string,
$str = "Vin[i,j] + Vout[i,j] + Uin[i,j] + Uout[i,j]";
I want to replace the i's and j's in the square brackets with actually indices. So something like "$str =~ s/i/2/g", except for that changes the variable name as well (Vin becomes V2n). So my questions is, how...
Thanks Kevin! I'll check it out. What about my previous question:
I have created a Date object with the following line:
$myDate = Date::Calc->today();
How do I find out which day of the week it is? One way to do so is:
print Day_of_Week($myDate->year(),$myDate->month(),$myDate->day());
but...
One quick question:
I have created a Date object with the following line:
$myDate = Date::Calc->today();
How do I find out which day of the week is it? One way to do so is:
print Day_of_Week($myDate->year(),$myDate->month(),$myDate->day());
but it feels like there's gotta be some easier way...
Kevin,
Thanks. Now that makes sense. So you are saying that by using the module, I'm just using its member subroutines to manipulate 3-element arrays?
Thanks again!
Hi,
I've had some past experience in C++ and Java but I'm pretty new to Perl. I was trying to use the Date::Calc module, after briefly looking through the Calc.pod page on CPAN, I realized that I didn't even know how to create a new Date object. In Java, it would be something like:
Date...
I haven't used a Mac in a while but I think all you have to do is to change the permission of the Perl script to executable and you will be able to launch it by double clicking.
Hi,
I tried following the instructions on CSPAN for installing Perl modules under CygWin, but it was not successful at all. Does anyone know any webpage with instructions to do so?
Sorry if this is a n00b question - I'm just starting to pick up Perl!
Thanks in advance!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.