maybe this does not ineterest you, but:
if you wanna substitute each code (for instance 010) with its correct
name (for instance red) you can use thw script that follows.
Actually I'm working on apply this script to an entire directory and
its subdirectories (see the mail "navigate the directorie
Hi Joseph
Just a thought:
if ( !$_ or $_ eq "" ) {next;}
is a C idiom, where a string is represented as a char* which may be NULL or
may point to a zero-length string. In Perl a simple
if ( !$_ ) {next;}
or, better
next unless $_;
Cheers,
Rob
"R. Joseph Newton" <[EMAIL PROTECTE
Hi Mike.
Something like:
while (<>)
{
if ( /^(\d\d\d)\s*"([^"]+)/ )
{
($level, $text) = (0+$1, $2);
print "$level $text\n";
}
}
will do what you want. It looks for lines starting with three digits,
optional spaces and a double quote. I
Hi Mike,
Try something like the following. It actually takes an extra step, by making a hash
opf all lines, then searching it for the keys that have the desired numerical prefix.
There is a purpose to that. A few small edits will allow this to report all of the
strings, grouped by prefix.
#
Mike Burnard wrote:
>
> Hi,
Hello,
> I'm in the midst of writing my first useful perl script. It's designed to
> pull text out of a plain text file and write a xml plist.
>
> The only trouble I'm having (so far) is getting the text out the way I want
> it.
>
> The file I'm pulling data out of
- Original Message -
From: "Mike Burnard" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, December 30, 2002 11:40 PM
Subject: macthing question...
> Hi,
>
> I'm in the midst of writing my first useful perl script. It's designed to
> pull text out of a plain text file and wri
On Mon, 30 Dec 2002, Mike Burnard wrote:
>
> The file I'm pulling data out of is formatted like this:
>
> 010 "red"
>
> 011 "diamond"
>
> 012 "lion"
>
> 010 "blue"
>
> 012 "blue whale"
>
> 011 "emerald"
>
> So, I've got this to get specific groups out at once:
>
> while () {
> if(/^010/) {
Interesting, I'm working on a similar thing.
I've found it useful to use the $1, $2, etc variables. So try something
like:
if( $line =~ /\"([\w\s]*)\"/ )
{
$array[i] = $1;
}
I'm not sure if all that (like the escaped ") is necessary; I'm just
starting myself.
On Mon, 30 Dec 2002, Mi