Re: MAC and install CPAN

2007-04-29 Thread Tom Phoenix
On 4/29/07, Tom Allison <[EMAIL PROTECTED]> wrote: Warning: prerequisite Mac::Carbon 0.77 not found. We have 0.71. Have you tried installing a newer version of Mac::Carbon? Cheers! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e

MAC and install CPAN

2007-04-29 Thread Tom Allison
Greetings. I've been using perl for years under Unix and yesterday I picked up a MacBook. It doesn't come with DBI, so I tried to instal it from CPAN... And installing from CPAN I always started with Bundle::CPAN to get a "clean slate" I haven't had any success with it and I'm really unfami

Re: creating hash from scalar variable

2007-04-29 Thread Matthew J. Avitable
Given the original string ... my $test = 'NAS-IP-Address = 192.168.42.1 ... Acct-Unique-Session-Id = "87d380e1881d226c" Timestamp = 1177282824'; You could also invoke perl 5.8's ability to treat an in-memory string as a file: ## get a filehandle on $test open(my $fh, '<', \$test

Re: creating hash from scalar variable

2007-04-29 Thread Rob Dixon
Rodrick Brown wrote: use Data::Dumper; my %h; map { $h{$_->[0]}=$_->[1] } map { [ split/=/,$_ ] } split/\n/,$test; print Dumper(\%h); Or, more intelligibly, my %h; foreach (split /\n/, $test) { my ($key, $val) = split /=/; $h{$key} = $val; } Rob -- To unsubscribe, e-mail: [EMAIL P

Re: creating hash from scalar variable

2007-04-29 Thread Rodrick Brown
On 4/29/07, Goksie <[EMAIL PROTECTED]> wrote: hello, Can someone help me correct this code. if i print, it only print the first line. Goksie #!/usr/bin/perl use strict; my $test = 'NAS-IP-Address = 192.168.42.1 Quintum-NAS-Port = "0 0/0/c1dc2a26" NAS-Port-Type = Async Use

creating hash from scalar variable

2007-04-29 Thread Goksie
hello, Can someone help me correct this code. if i print, it only print the first line. Goksie #!/usr/bin/perl use strict; my $test = 'NAS-IP-Address = 192.168.42.1 Quintum-NAS-Port = "0 0/0/c1dc2a26" NAS-Port-Type = Async User-Name = "192.168.42.8" Called-Station-Id =

Re: creating hash from scalar variable

2007-04-29 Thread Martin Barth
Hi, if you're reading a config file to get the string maybe Config::General is handy. HTH Martin On Sun, 29 Apr 2007 14:27:52 +0100 Goksie <[EMAIL PROTECTED]> wrote: > hello, > > Can someone help me correct this code. > > if i print, it only print the first line. > > Goksie > > #!/usr/bin

Re: creating hash from scalar variable

2007-04-29 Thread Rob Dixon
Goksie wrote: hello, Can someone help me correct this code. if i print, it only print the first line. Goksie #!/usr/bin/perl use strict; my $test = 'NAS-IP-Address = 192.168.42.1 Quintum-NAS-Port = "0 0/0/c1dc2a26" NAS-Port-Type = Async User-Name = "192.168.42.8" Call

Re: creating hash from scalar variable

2007-04-29 Thread yaron
Hi, The line --> my %test = my($fname, $fvalu)=split(/=/, $test); Will insert only two elements into %test. Try: my %test = split (/=/,$test); Yaron Kahanovitch - Original Message - From: "Goksie" <[EMAIL PROTECTED]> To: "Perl Beginners" Sent: Sunday, April 29, 2007 4:27:52 PM (GMT+0

Re: creating hash from scalar variable

2007-04-29 Thread David Van Ginneken
I think something like this would work for you. my %test; map { my ($fn,$val) = split(/=/,$_,2); $test{$fn}=$val;} split(/\n/, $test); I noticed some of your values had equal signs in them, so in the inside split, I also specified you wanted 2 values so that you receive the full expected value b

Re: creating hash from scalar variable

2007-04-29 Thread Rob Coops
Hi there, Your problem here is that perl is kind enough to see the whole scalar as one line. So what you would have to do is break it up in several linse shove them in an array. Then do a foreach on the array to split and drop it in the hash like so: my @array = split( /\n/, $test ); foreach m

creating hash from scalar variable

2007-04-29 Thread Goksie
hello, Can someone help me correct this code. if i print, it only print the first line. Goksie #!/usr/bin/perl use strict; my $test = 'NAS-IP-Address = 192.168.42.1 Quintum-NAS-Port = "0 0/0/c1dc2a26" NAS-Port-Type = Async User-Name = "192.168.42.8" Called-Station-Id =

Re: pure perl replacment for "/usr/bin/file"

2007-04-29 Thread Martin Barth
> Hello, > > > I want to determine the character encoding of some strings I have. > > Something similar to the "file" tool, > > http://search.cpan.org/~knok/File-MMagic-1.27/ > > John Hi, I am sorry John, i think that won't help me :-( File::MMagic works like File::Type ( which says its a impr

Re: really bad use of postfix

2007-04-29 Thread Dr.Ruud
Ken Foskey schreef: > Just like to show how NOT to use postfix. I have had a frustrating > day tackling this type of unreadable code. > >> exec_rqst('stga2k_vps.pl',$FileNameIn) if ($a2kqual[4] eq >> "VPS"); >> exec_rqst('stga2kif.sh',$FileNameIn) if ($a2kqual[4] ne >> "VPS"); >>

Re: hellp improve efficiency

2007-04-29 Thread yaron
Hi, You can use the following it will reduce the amount of : ... while (<>) { $uri = (split)[0]; $uri =~ s#www\.example\.com/(v\d?|so)#$1.example.com# or $uri =~ s#www\.example\.com/admin/\?.*#www.example.com/admin/# or $uri =~ s#www\.example\.com/([wulp])(\d+)/#$2.$1.example.com# or $u