PS: Expression problem





The $details array is read in from a text file and this works fine.
What I want to do is search the $details text for certain key words,
then take the text right after. The first if statement
.
.
I just noticed this comment about reading from a file, although you
don't show your code for that. I will share this approach which works
well for me and my team, and is nice and tidy. I call it the guerilla
approach- get into the file, snag it, get out!

die "This file will not open here is why: \n$!\n" unless open T,
'mytextfile.txt';
my @details = <T>;
close T;
for ( @details )
{
.
.
.
}


If you REALLY want a lot of info about the file and failure, you can
use some cool Perl file tests:

# lots of details...
die "aint no such file as $myFile\n" unless -e $myFile;
die "$myFile is a directory not a file!\n" unless -d $myFile;
die "the file $myFile is there but I cannot read it\n" unless -r
$myFile;
die "the file $myFile is there but I cannot open it for reading
(locked maybe?)\n$!\n"
unless open T, $myFile;
my @details = <T>;
close T;
die "I opened and read $myFile but there wasnt nothing in it, wanna
try again ace?\n"
unless @details;

Welcome to the wonderful world of Perl, you make a wise choice
grasshopper!

PS: do you own due-diligence on my and other comments and suggestions
and choose what works best for you. Larry often states that in Perl
there are MANY ways to do things. Often you'll see a lot of approaches
to questions here in CLPM - study them and choose the best for you.
Although I've read Llama, Camel, even big black cat, I would still say
that I've learned 75% of my Perl right here in this group. Often I'll
slap my forehead after seeing a reply and think "DUH how did I MISS
that!"..

.



Relevant Pages

  • interpolation
    ... Then reading in text file that uses the variable. ... Input file: ... open (MYFILE, $text) or die "cant open erik"; ...
    (comp.lang.perl.misc)
  • Linux Magazin: Perl gewinnt haushoch gegen die anderen Skriptsprachen
    ... [@Randal, in case your German's not so good: I was dismayed how they turned this contest around, to make it seem at first sight like you and Perl had completely failed. ... Klar ist es blöd, daß alle nach dem Motto programmieren, CPU und Speicher seien eh da. ... Da ich bei makepp viel Erfahrung mit Perl Optimierung gesammelt habe, bin ich da gerne ran gegangen. ... Randal hat achtlos die drei Infos pro Fußnote in einen Hash gespeichert. ...
    (comp.lang.perl.misc)
  • Re: trying to understand fork and wait
    ... > the perldoc for fork ... ... die had nothing to do with your problem. ... off checking whether functions fail: ... Unfortunately there is no one way to test for 'success' in Perl. ...
    (comp.lang.perl.misc)
  • Re: Looking for a critique
    ... S> Uri Guttman wrote: ... S> Much of my code was borrowed from recipe 12.2 of O'Reilly's "Perl ... S> "die unless" idioms, but in this case I wanted to emphasize the fact ... getting burned with reused here doc tokens, that is more a lesson for ...
    (comp.lang.perl.misc)
  • Re: flock - exclusive file locking
    ... O_WRONLY is probably always true then die() will *never* be called. ... Or use the low precedence 'or' operator: ... That error message is not listed in perldiag.pod so it is not a Perl error/warning and it doesn't match any of the error messages in your code above so something other than your Perl program is producing it. ...
    (perl.beginners)