Scott R. Godin wrote:
> Rob Dixon wrote:
> > Scott R. Godin wrote:
> > > John W. Krahn wrote:
> > > >
> > > > my %hash = do { local $/; =~ /[^\n,]+/g };
> > >
> > > but where's the implicit split of key and value there? forgive me
> > > for asking, but I just don't see it. is there some magic goin
Randal L. Schwartz wrote:
>> "Scott" == Scott R Godin <[EMAIL PROTECTED]> writes:
>
>>> my %hash = map {/\w+/g}
>>>
>>> :-)
>
> Scott> grin away. This shortcut deserves to be in the perldocs
> Scott> somewhere. I wish I'd seen this before.
>
> The problem is that it is very intolerant of
Rob Dixon wrote:
> Scott R. Godin wrote:
>> John W. Krahn wrote:
>> >
>> > Yes, there is. :-)
>> >
>> > my %hash = do { local $/; =~ /[^\n,]+/g };
>>
>> Holy Handgrenades, Batman!
>>
>> but where's the implicit split of key and value there? forgive me for
>> asking, but I just don't see it. is t
David Gilden wrote:
>
> Thanks for all of the help,
>
> Here is what I am currently going with:
>
> my $prices = '../paul_s/data/prices.txt';
>
> open (FH,$prices) || die "could not open $prices $!";
>
> while( ) {
> s/^\s*(.+)\s*$/$1/; # clean the front of each line
> next if /^\s*$/;
> "Scott" == Scott R Godin <[EMAIL PROTECTED]> writes:
>> my %hash = map {/\w+/g}
>>
>> :-)
Scott> grin away. This shortcut deserves to be in the perldocs
Scott> somewhere. I wish I'd seen this before.
The problem is that it is very intolerant of mis-formatted data. If I
had a line that h
Scott R. Godin wrote:
> John W. Krahn wrote:
> >
> > Yes, there is. :-)
> >
> > my %hash = do { local $/; =~ /[^\n,]+/g };
>
> Holy Handgrenades, Batman!
>
> but where's the implicit split of key and value there? forgive me for
> asking, but I just don't see it. is there some magic going on here?
On Tue, 18 Mar 2003, Scott R. Godin wrote:
> John W. Krahn wrote:
>
> > David Gilden wrote:
> >>
> >> OK, one problem is solved, which was the path to the data file.
> >> I know there is a simple way to read in a file like the following:
> >>
> >> apple,2
> >> banana,4
> >> kiwi,1
> >>
> >> an
Rob Dixon wrote:
> John W. Krahn wrote:
>> David Gilden wrote:
>> >
>> > OK, one problem is solved, which was the path to the data file.
>> > I know there is a simple way to read in a file like the following:
>> >
>> > apple,2
>> > banana,4
>> > kiwi,1
>> >
>> > and produce a HASH. The code below
John W. Krahn wrote:
> David Gilden wrote:
>>
>> OK, one problem is solved, which was the path to the data file.
>> I know there is a simple way to read in a file like the following:
>>
>> apple,2
>> banana,4
>> kiwi,1
>>
>> and produce a HASH. The code below works I get the feeling there is a
Thanks for all of the help,
Here is what I am currently going with:
my $prices = '../paul_s/data/prices.txt';
open (FH,$prices) || die "could not open $prices $!";
while( ) {
s/^\s*(.+)\s*$/$1/; # clean the front of each line
next if /^\s*$/; # skip blank lines
my ( $k, $v ) = sp
John W. Krahn wrote:
> David Gilden wrote:
> >
> > OK, one problem is solved, which was the path to the data file.
> > I know there is a simple way to read in a file like the following:
> >
> > apple,2
> > banana,4
> > kiwi,1
> >
> > and produce a HASH. The code below works I get the feeling there
David Gilden wrote:
>
> OK, one problem is solved, which was the path to the data file.
> I know there is a simple way to read in a file like the following:
>
> apple,2
> banana,4
> kiwi,1
>
> and produce a HASH. The code below works I get the feeling there is a more
> compact way to accomplish
David Gilden wrote:
> OK, one problem is solved, which was the path to the data file.
>
> I know there is a simple way to read in a file like the following:
>
> apple,2
> banana,4
> kiwi,1
>
>
> and produce a HASH. The code below works I get the feeling there is a more
> compact way to accompl
David Gilden wrote:
> Thanks Dave for the while loop,
>
> I need to protect against blank lines and spurious white space that
> could show up in the data. No doubt the file will edited in Note pad
> (on widows 98), and I want to put the data in to the hash in a clean
> format. and since the this
Thanks Dave for the while loop,
I need to protect against blank lines and spurious white space that could show
up in the data. No doubt the file will edited in Note pad (on widows 98), and I
want to put the data in to the hash in a clean format. and since the this is
basically a price list nam
rt
San Diego, CA 92127
1-858-676-2277 x2152
> -Original Message-
> From: David Gilden [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, March 18, 2003 10:56 AM
> To: [EMAIL PROTECTED]
> Subject: Re: PERL OSX --- reading a local text file
>
>
> OK, one problem is solved,
OK, one problem is solved, which was the path to the data file.
I know there is a simple way to read in a file like the following:
apple,2
banana,4
kiwi,1
and produce a HASH. The code below works I get the feeling there is a more
compact way to accomplish this.
---
#!/usr/bin/perl -w
use
What do you get if you run this script?
#!/usr/bin/perl -w
use strict;
my $data = "data.txt";
print `ls -l $data`;
__END__
-Michael
>>> David Gilden <[EMAIL PROTECTED]> 03/18/03 10:36AM >>>
> But what directory were you in when you ran the program? That's a
lot
> more important than where
> "David" == David Gilden <[EMAIL PROTECTED]> writes:
>> But what directory were you in when you ran the program? That's a lot
>> more important than where the program is.
David> /Users/dowda/Desktop/tmp test/read-prices.pl
David> OSX Jaguar, G4
Right. When you ran the program, were you
David Gilden wrote:
> > But what directory were you in when you ran the program? That's a
> > lot
> > more important than where the program is.
>
>
> /Users/dowda/Desktop/tmp test/read-prices.pl
>
> OSX Jaguar, G4
Try adding
use Cwd;
print cwd, "\n";
just before your open, to make sure
> But what directory were you in when you ran the program? That's a lot
> more important than where the program is.
/Users/dowda/Desktop/tmp test/read-prices.pl
OSX Jaguar, G4
Randal L. Schwartz <[EMAIL PROTECTED]>,
> The following message is a courtesy copy of an article
> that has been p
> "David" == David Gilden <[EMAIL PROTECTED]> writes:
David> Hi List,
David> Any reason why this dies? error: " could not open data.txt No such file or
directory"
--> The file and script reside in the same directory!!!
But what directory were you in when you ran the program? That's a lo
Hi List,
Any reason why this dies? error: " could not open data.txt No such file or directory"
-->The file and script reside in the same directory!!!
#!/usr/bin/perl -w
use strict;
my $data = "data.txt";
open (FH,$data) || die "could not open $data $!";
local $/;
my $tmp = ;
my @tmp =
23 matches
Mail list logo