in reply to reading values from file

How about:
my $debug = shift @ARGV; print "debug mode\n" if $debug; # where is INFILE opened? while (<INFILE>) { # assuming you want what is between the '' after version chomp($old_version) && last if ($old_version) = /ver = '(.*?)'/; } close INFILE; # assuming .pro is end of projectPath my ($projlabl) = $projectPath =~ /(.*)\.pro$/; $projlabl .= 'labeler';

Replies are listed 'Best First'.
Re^2: reading values from file
by Aristotle (Chancellor) on Jan 24, 2006 at 17:41 UTC

    Why are you chomping a value that cannot contain any newlines? Not to mention that sticking that all on a single line is unnecessarily dense.

    Makeshifts last the longest.

        That bit is correct.

        But your post goes to show what I meant when I said it’s needlessly dense – it’s too easy to misread the intent.

        Makeshifts last the longest.

      In case my assumption was incorrect and there could be a newline at the end of version, only the regex needs to be modified.

      Should have thrown that in a comment as well, thanks for pointing it out to the poster.

Re^2: reading values from file
by perlNinny (Beadle) on Jan 24, 2006 at 21:21 UTC
    Hmmm...tried your version below:
    while (<INFILE>) { # assuming you want what is between the '' after version chomp($old_version) && last if ($old_version) = /ver = '(.*?)'/; } close INFILE;
    and it didn't retrieve the string and put it in $old_version...or at least it didn't show it on a subsequent print statement.