Sep 21, 2005 kl. 9:55 PM skrev Wagner, David --- Senior Programmer
Analyst --- WGO:
Tommy Nordgren wrote:
How do you split a string on the equality character?
Neither split (/=/,$myvar)
nor split ('=',$myvar)
appears to work
"Home is not where you are born, but where your heart finds peace" -
Tommy Nordgren, "The dying old crone"
Really need the context of what you were attempting. Showing
what you have in $_. The first split /=/, should work, but really
need to see what you were attempting.
Wags ;)
This is my full script:
#!/usr/bin/perl
use strict;
use warnings;
if ( @ARGV !=2) {
die "Usage: nibfixup Nibfile Applicationname\n" ;
}
my $nibfile = $ARGV[0];
my $appname = $ARGV[1];
print "Running nibtool\n";
my $dictionary = `/usr/bin/nibtool -L $nibfile`;
print "Nibtool have run\n";
my @dictionary = split(/\n/,$dictionary);
my $len = @dictionary;
print "lenght:$len\n";
open (DICT,'>','temp.strings') or die "Could not open dictionary file
\n";
for my $i (@dictionary) {
my @i = split /=/ , $i;
if (1 == length @i) {
print DICT $i,"\n";
} else {
my $j = shift @i;
print DICT "$j=";
$j = shift @i;
$j =~ s/NewApplication/$appname/e;
print DICT $j;
for $j (@i) {
print DICT "=$j";
}
print DICT "\n";
}
}
close DICT;
system ('/bin/mv' ,$nibfile ,"old.$nibfile") and die "Could not
rename nib file\n";
print "Hellow world!\n";
print "Running nibtool\n";
system ('/usr/bin/nibtool' ,'-w',$nibfile,'-d','temp.strings',"old.
$nibfile")
and die "Could not update nibfile\n";
print "Nibtool have run\n";
system ('/bin/rm', '-rf', "old.$nibfile");
For some reason, I don't get $i split on = in the lines where it occurs,
I'm trying to write a temp.strings file,
where the second, past equalty sign, occurence of the word
NewApplication,(localized)
Gets replaced by a string passed as second parameter on the command line
-------------------------------------
This sig is dedicated to the advancement of Nuclear Power
Tommy Nordgren
[EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>