From: "Biju Ramachandran" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED], [EMAIL PROTECTED]
Subject: RE: reading a text file
Date: Mon, 30 Jun 2003 13:51:50 -0400
This is an extract from spl liscenece log file
06/16/03 10:07:46 NOTICE: "./spm_key (Ver.1.1.11)" started to i
need more info on this
Thanks
Biju
From: "Dan Muey" <[EMAIL PROTECTED]>
To: "Biju Ramachandran" <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]>
Subject: RE: reading a text file
Date: Mon, 30 Jun 2003 11:02:02 -0500
> Hi there
Howdy
>
> In perl h
> Hi there
Howdy
>
> In perl how do I read a text file and search for multiple
use open() or possibly File::SLurp
perldoc -f open
perldoc File::Slurp or search.cpan.prg
> matching patterns
Use regular expressions, this is a big topic.
if($text_file_guts =~ m/JoeMama/i) { ...
> and once fou
Hi there
In perl how do I read a text file and search for multiple matching patterns
and once found, write it to an Mysql
Thanks
Biju
_
Protect your PC - get McAfee.com VirusScan Online
http://clinic.mcafee.com/clinic/ibuy/campa
chop $states{$code};
>chop $states{$code};
>print "$code $states{$code}\n";
>}
>
>Best Regards,
>
>Katherine Qiang
>http://home.cwru.edu/~qxq2
>http://kittyqiang.tripod.com
>
>
>
>>From: "Will Crain" <[EMAIL PROTECTED]>
&g
s{$code}\n";
}
Best Regards,
Katherine Qiang
http://home.cwru.edu/~qxq2
http://kittyqiang.tripod.com
>From: "Will Crain" <[EMAIL PROTECTED]>
>To: "Debbie Christensen" <[EMAIL PROTECTED]>,
>[EMAIL PROTECTED]
>Subject: RE: reading a text file
>D
Debbie, your problem seemed easy enough. See if this works for you:
my $state;
my $code;
my $currCode = 0;
my $outLine = "";
open(STATES, ") {
$line =~ /^(\w+): (\d+)/;
if($code == $currCode) {
$outLine .= ", " . $1;
}
else {
unle
Sorry... let me correect my previous mail.
Try this:
open(STATES,"state.txt")||die "can't open file";
while () {
($myval, $mykey) = split /[:\s]+/, $_; # Corrected this line from my
previous mail :-)
$myhash{$mykey} .= $myval.', ';
}
close STATES;
# Let's write the output
foreach $loopkey
acavallari would like to recall the message, "Re: reading a text file".
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Why don't you try this:
open(STATES,"state.txt")||die "can't open file";
while () {
($mykey, $myval) = split /\s+/, $_;
$myhash{$mykey} .= $myval.', ';
}
close STATES;
# Let's write the output
foreach $loopkey (keys %myhash) {
$myhash{$loopkey }=~s/,\s$//; # Remove last comma and space
Debbie,
Debbie Christensen wrote:
> I am able to open the file and read it with no problem. Where I get lost is
> My boss wants the data to come out like
> 702 OH, PA, ND
> 703 NJ, NY, CA
There's surely other ways to do this, and many may be better, but here
is a solution for you. It makes us
hi Debbie,
perhaps this is what you want.
#!/usr/bin/perl -w
use strict;
open STATES, ") {
$num =~ s/^\s+//;
$num =~ s/\s+$//;
push @{ $states{$num} }, $state;
}
for (keys %states) {
print "$_ ", join ( ',', @{ $states{$_} } ), "\n";
}
Am Dienstag, 24. Juli 2001 21:03 schrieb Debbie
a bit with Perl.
Wags ;)
-Original Message-
From: Abdulaziz Ghuloum [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 24, 2001 12:45
To: [EMAIL PROTECTED]
Subject: Re: reading a text file
Hello,
This is not a flame.
You provided a small program that does nothing but print the file. I
Hello,
This is not a flame.
You provided a small program that does nothing but print the file. If
you need help, you really should help yourself a little more by first
thinking how the program should function. What are the logical steps
that need to be performed to achieve what you want. Wh
> -Original Message-
> From: Debbie Christensen [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, July 24, 2001 3:03 PM
> To: [EMAIL PROTECTED]
> Subject: reading a text file
>
>
> I am brand new to perl; I am only on chapt 4 of the learning
> perl book. My
I love it when i write up complete crap about needing to check existance of
keys...
the following code will merrily suffice:
#
open I, "state.txt";
my %codes;
while () {
chomp; #remove newline
s/\s+//g; #remove white space
my @entry = split ':'; #split on :
pu
x27; ) {
$MyLine =~ s/,\s+$//g;
print "$MyLine\n" ;
}
__DATA__
OH: 702
PA: 702
ND: 702
NJ :703
NY: 703
Ca: 703
^ End of data
Wags ;)
-Original Message-
From: Debbie Christensen [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 24, 2001 12:03
To: [EMAIL PROTECTED]
Subje
I took 2 looks at this problem and figured i'd need to use a hash of array
references.
now, i'm debating whether i should just hand you the code to get this job
done, or whether to realy explain how these things work.
i decided to do a bit of both, so bear with me here.
what we want is a list o
Debbie - You probably want to use references. A situation very similar to
yours is covered in one of the perl documentation pages: type "perldoc
perlreftut" on your command line.
HTH,
Bill.
On 2001.07.24 12:03 Debbie Christensen wrote:
> I am brand new to perl; I am only on chapt 4 of the learn
I am brand new to perl; I am only on chapt 4 of the learning perl book. My
boss has already given me a project to do that I am really struggling with.
I know you are all really busy, but I would really appreciate any help you
can give.
I have a text file that looks something like this
OH: 702
20 matches
Mail list logo