[19356] in Perl-Users-Digest
Perl-Users Digest, Issue: 1551 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 17 14:06:17 2001
Date: Fri, 17 Aug 2001 11:05:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <998071512-v10-i1551@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 17 Aug 2001 Volume: 10 Number: 1551
Today's topics:
Re: "shifting" values of the @_ array?? <miscellaneousemail@yahoo.com>
Any ASCII graph plotting modules? <zigouras@mail.med.upenn.edu>
Re: capitalisation/DBD/mysql (Helgi Briem)
Re: capitalisation/DBD/mysql (Tad McClellan)
comparing lines in file (Hedy)
Re: comparing lines in file <rsherman@ce.gatech.edu>
Re: comparing lines in file (Anno Siegel)
Re: Embedded perl question (Robert J. Lee)
eval and reading in a file <juslin@take-me-avay-iastate.edu>
Re: eval and reading in a file <ilya@martynov.org>
Free open source CMS's written in perl? (=?ISO-8859-1?Q?Morten_Tanger=E5s?=)
Re: Free open source CMS's written in perl? <ilya@martynov.org>
Re: Importing subroutines into the CORE::GLOBAL package <murat.uenalan@gmx.de>
Re: Is MD5 in standard installation (Helgi Briem)
Re: local exec via cgi <jurgenex@hotmail.com>
Re: Looking for Script <dennis@noreplies.com>
Re: need opinions (derelixir)
newbie regexp question <achatz@forthnet.gr>
Re: newbie regexp question <ilya@martynov.org>
Re: newbie regexp question <holland@origo.ifa.au.dk>
Re: OT: Why is there so much white space in perl docume <miscellaneousemail@yahoo.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 17 Aug 2001 15:36:58 GMT
From: Carlos C. Gonzalez <miscellaneousemail@yahoo.com>
Subject: Re: "shifting" values of the @_ array??
Message-Id: <MPG.15e6e8379e4c1039989777@news.edmonton.telusplanet.net>
In article <74f348f7.0108170152.7d42e73c@posting.google.com>, Yves Orton
at demerphq@hotmail.com says...
> Yes. I wrote it in google, [snip]
How do you write something in google (the search engine?).
---
Carlos
www.internetsuccess.ca
*NOTE*: Internet Success is NOT yet fully operational so although you are
welcomed to visit and take a look, trying to subscribe will only be a
frustration for you as your data will not be saved at this time.
------------------------------
Date: Fri, 17 Aug 2001 13:17:35 -0400
From: Nico F Zigouras <zigouras@mail.med.upenn.edu>
Subject: Any ASCII graph plotting modules?
Message-Id: <Pine.OSF.4.10.10108171312100.4438-100000@dolphin.upenn.edu>
Are there any Perl modules out there that will plot a graph with ascii
text. For example it will take two arrays for the X and Y data and output
a bar graph in characters. Something like what you see for the graphs on
web log analyzers that use little square gif images to build the bars -
like Analog. I searched CPAN but could not find anything. Thanks in
advance.
------------------------------
Date: Fri, 17 Aug 2001 16:45:33 GMT
From: helgi@NOSPAMdecode.is (Helgi Briem)
Subject: Re: capitalisation/DBD/mysql
Message-Id: <3b7d4666.2188852233@news.isholf.is>
On Fri, 17 Aug 2001 10:15:55 +0100, "Paul Fortescue"
<paul@net366.com> wrote:
>Old thread was getting confusing ...
>
>On Windows 2000, ActivePerl, IIS
>I have installed, using PPM
>
> DBD
> DBI::mysql
>
>which appear to have worked.
Impossible. DBD does not exist and neither
does DBI::mysql. I guess you must have installed
DBI and DBD::Mysql.
I did that. Took 5 seconds and 2 commands.
>I write in .pl
>
> use CGI;
Now why the hell would want to do that when
you still havent figured out how to run the
database driver yet? Lose the CGI bit for now
and concentrate on getting things to run on
the command line first.
>now either
>
> DBI->install_driver('mysql'); OR
Works fine for me.
> DBI->connect(DBI:mysql:database=d;hostname=localhost);
>
That however doesn't. It produces an error:
syntax error at script line 5, near "DBI:"
syntax error at script line 5, near "localhost)"
Execution of script aborted due to compilation errors.
So, I tried to do it the way perldoc -X DBD::Mysql
says to do it:
use DBI;
use DBD::Mysql;
DBI->install_driver('mysql');
my $driver = "mysql";
my $hostname ="foo";
my $database = "moo";
my $dsn = "DBI:$driver:database=$database;host=$hostname";
my $dbh = DBI->connect($dsn, undef, undef);
__END__
and get the error message:
DBI->connect(database=moo;host=foo) failed:
Unknown MySQL Server Host (foo) (0) at script line 11
Presumably (wild stab in the dark) the database
moo doesn't exist on foo.
Anyway, I can't get any further for you, because
I don't have a Mysql database to hand to try
connecting to it, but it doesn't seem to hard
to get the Perl part up and running.
Regards,
Helgi Briem
------------------------------
Date: Fri, 17 Aug 2001 11:44:59 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: capitalisation/DBD/mysql
Message-Id: <slrn9nqevr.avo.tadmc@tadmc26.august.net>
Paul Fortescue <paul@net366.com> wrote:
>> I doubt that you can only output to a browser.
>>
>> Have you _tried_ outputting to the command line?
>>
>I can, but I am only a poor user of the server, which is in a country not
>adjacent to mine.
FTP does not care where in the world the data is.
>I can't.
Yes you can, though it may be that you don't know how to.
>> Run from the command line when debugging.
>>
>I can't.
Yes you can.
>See above, but thanks anyway!
I do not see anything above that precludes running from the command line.
FTP the program to your home or office computer, and run it from
the command line.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 17 Aug 2001 09:16:37 -0700
From: citromos@yahoo.com (Hedy)
Subject: comparing lines in file
Message-Id: <cdc6e6b9.0108170816.4287f2c8@posting.google.com>
Hi,
I need some help because I am not sure where to start with this
problem. I have a large log file that looks like this:
user number|collection|subcollection|option1|option2
sample lines:
100|Main|AA|1|1
101|Main|AA||1
101|Main|AA||1
101|Main|BB|1|1
102|System2|AA|1|1
102|Main|BB|1|1
103|System3|AA|1|1
103|System3|AA|1|1
104|Main|CC|1|1
105|Main|AA|1|1
105|Main|AA|1|1
105|Main|BB|1|1
105|Main|AA|1|1
What I need to produce is a list that summarizes how many times 1)a
user appears, 2)the number of times that the entire line is the same
and 3)whether 1 & 2 are equal.
So for the sample above:
user number|how many times they appear|how many of their lines are
dups (or Not Applicable if 1)|Y or N
100|1|NA|NA
101|3|2|N
102|2|0|N
103|2|2|Y
104|1|NA|NA
105|3|2|N
Any help will be most appreciated.
Thanks,
Hedy
------------------------------
Date: Fri, 17 Aug 2001 13:06:07 +0500
From: Robert Sherman <rsherman@ce.gatech.edu>
Subject: Re: comparing lines in file
Message-Id: <3B7CD06F.DBDE1ED@ce.gatech.edu>
Hedy wrote:
>
> Hi,
>
> I need some help because I am not sure where to start with this
> problem. I have a large log file that looks like this:
>
> user number|collection|subcollection|option1|option2
>
> sample lines:
>
> 100|Main|AA|1|1
> 101|Main|AA||1
> 101|Main|AA||1
> 101|Main|BB|1|1
> 102|System2|AA|1|1
> 102|Main|BB|1|1
> 103|System3|AA|1|1
> 103|System3|AA|1|1
> 104|Main|CC|1|1
> 105|Main|AA|1|1
> 105|Main|AA|1|1
> 105|Main|BB|1|1
> 105|Main|AA|1|1
>
> What I need to produce is a list that summarizes how many times 1)a
> user appears, 2)the number of times that the entire line is the same
> and 3)whether 1 & 2 are equal.
>
> So for the sample above:
> user number|how many times they appear|how many of their lines are
> dups (or Not Applicable if 1)|Y or N
> 100|1|NA|NA
> 101|3|2|N
> 102|2|0|N
> 103|2|2|Y
> 104|1|NA|NA
> 105|3|2|N
>
> Any help will be most appreciated.
>
> Thanks,
> Hedy
look at using a hash...
this is the standard 'how many times does X appear in an array' snippet
from the Cookbook:
%count=();
foreach $element (@array) {
$count{$element}++;
}
use split to chuck the various fields into arrays and then count them
using variations of the above snippet...
--
robert sherman
css, cee
georgia institute of technology
atlanta, ga, usa
------------------------------
Date: 17 Aug 2001 17:44:10 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: comparing lines in file
Message-Id: <9ljl5a$j75$1@mamenchi.zrz.TU-Berlin.DE>
According to Robert Sherman <rsherman@ce.gatech.edu>:
> Hedy wrote:
> >
> > Hi,
> >
> > I need some help because I am not sure where to start with this
> > problem. I have a large log file that looks like this:
> >
> > user number|collection|subcollection|option1|option2
> >
> > sample lines:
> >
> > 100|Main|AA|1|1
> > 101|Main|AA||1
> > 101|Main|AA||1
> > 101|Main|BB|1|1
> > 102|System2|AA|1|1
> > 102|Main|BB|1|1
> > 103|System3|AA|1|1
> > 103|System3|AA|1|1
> > 104|Main|CC|1|1
> > 105|Main|AA|1|1
> > 105|Main|AA|1|1
> > 105|Main|BB|1|1
> > 105|Main|AA|1|1
> >
> > What I need to produce is a list that summarizes how many times 1)a
> > user appears, 2)the number of times that the entire line is the same
> > and 3)whether 1 & 2 are equal.
> >
> > So for the sample above:
> > user number|how many times they appear|how many of their lines are
> > dups (or Not Applicable if 1)|Y or N
> > 100|1|NA|NA
> > 101|3|2|N
> > 102|2|0|N
> > 103|2|2|Y
> > 104|1|NA|NA
> > 105|3|2|N
> >
> > Any help will be most appreciated.
> >
> > Thanks,
> > Hedy
>
>
> look at using a hash...
Two or three, most likely. One for counting the appearance of each
user, one for counting the lines that are "equal" (to the first line
a user appeared in, I'll assume), and one hash to store the first line
each user appeared in.
> this is the standard 'how many times does X appear in an array' snippet
> from the Cookbook:
>
> %count=();
> foreach $element (@array) {
> $count{$element}++;
> }
>
> use split to chuck the various fields into arrays and then count them
> using variations of the above snippet...
There is no need for a full split, the way the problem was posed.
We only need to extract the user number from the line. "( $user) =
/([^|]*)/" does that for pipe-separated data.
Anno
------------------------------
Date: 17 Aug 2001 09:53:04 -0700
From: Zarlock@pretty.co.uk (Robert J. Lee)
Subject: Re: Embedded perl question
Message-Id: <262e5e2a.0108170853.6956475e@posting.google.com>
Benjamin Goldberg <goldbb2@earthlink.net> wrote in message news:<3B78D068.DAEF0CD6@earthlink.net>...
> Robert J. Lee wrote:
> >
> > Is there any easy way of saving the state of the perl interpretor to a
> > file (i.e. the values of all variables AND any subroutines which have
> > been processed)?
> >
> > Basically, I've decided to use embedded perl to add scripting
> > capabilities to a MUD I'm writing in C++, which has to be stopped and
> > restarted periodically as code changes (needing recompiling). So,
> > obviously, I need to save any changes to the perl bits as well.
>
> Do you? Wouldn't it be easier to have it so that "perl bit" are always
> put into files, and then loaded via require?
Well, that would be one way of saving and restoring everything
important, but it has it's problems. In order to save functions, you
would have to save every function as it was declared (on the C++
side), but then when you restore it, you have the problem of variables
resetting themselves to the value they had when they were initialised
in the first incarnation. (i.e. A function initialises a variable,
another function changes it, the MUD re-starts and its value would be
re-initialised).
> > I've got as far as getting a hashtable of all data out of the stash,
> > which should contain globs of all the data AFAICT. But the docs don't
> > seem to give much explanation on what I should be doing with globs
> > ("GV*"s) to turn them into data to save. (Also, I seem to be getting
> > "SV*"s from the hash and I don't know how to turn them into "GV*"s).
>
> This is the wrong way to do it, since it contains so much data, and you
> don't really want to save *everything*. If you need data saved, you can
> use Data::Dumper or Storable.pm or whatever, but remember that you
> should only save that which *needs* to be saved.
This brings the problem of knowing what needs to be saved; as perl
functions can effectively overwrite or create any variable. You'd need
to write an entire parser just to figure out which variables you were
using as you typed in each function. The whole point of using perl was
to avoid having to write a scripting language of my own...
>
> What are you adding scripting for? I *hope* it's not so people can add
> aliases for long commands... people can get special clients to do that,
> and most serious mudders already have one, which they like -- they're
> not garunteed to like whatever syntax you end up making up, and would
> rather use the client they're used to. Also, giving users scripting
> ability is a real security hazard [even with Safe.pm].
No; not for aliases (:-)).
The idea is that administrators of the MUD can write subroutines to
control how the mud operates (every time someone does something, a
perl subroutine is called that checks if any others need to be called
to change anything in the MUD). That way, administrators can control
exactly what the MUD does in any situation without learning C++,
writing lots of messy code and shutting the MUD down to recompile, and
without needing direct access to the server to recompile everything.
Thus leaving me free to focus on implementing more C++ things.
> Anyway, do you really expect that the perl code you had before a compile
> will work well with everything after a recompile? I don't think so.
I don't know. I would have thought that as long as the perl side stays
the same, and it doesn't use any callbacks into C++ code, that
recompiling the C++ side shouldn't make any difference. Wether it
would work after being reloaded into memory, I have no idea (pointers
to memory areas that have moved etc.). If it *can* be done, then I'm
sure someone here will know how...
> Any bits of perl code you need should probably be put each in their own
> file, and loaded from those files when the MUD starts [or better yet,
> only when they're needed]. Saving the state that the loaded pieces of
> code were in when the mud was last up is probably wrong.
Except if their state has changed since they were put each in their
own file. Which is very likely in this case.
It looks like I'll have to save the subroutines as they are created,
and re-load them first on start-up, saving the variables on shut-down,
and re-loading them after subroutines to change their values back to
what they should be. I was hoping that it could be done more easily
than this.
- Rob.
------------------------------
Date: Fri, 17 Aug 2001 11:35:36 -0500
From: Jukka Juslin <juslin@take-me-avay-iastate.edu>
Subject: eval and reading in a file
Message-Id: <3B7D47D8.A6D871CC@take-me-avay-iastate.edu>
Why is this kind a thing not working in Perl 5.005:
eval `cat eval.fis`;
Then I want to access one elementl like this:
print "FSR Name = $FSR->{Name}, ll = $ll\n";
I have no access to the elements. What to do?
I tried opening the file with OPEN etc instead
of cat, but I just cannot access the structure
I have in the file eval.fis is reading the value from.
Thanks.
Jukka
------------------------------
Date: 17 Aug 2001 21:49:50 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: eval and reading in a file
Message-Id: <87itfmfuf5.fsf@abra.ru>
JJ> Why is this kind a thing not working in Perl 5.005:
JJ> eval `cat eval.fis`;
Do you want to run Perl code in eval.fis? Then it should work. But it
is much more easier to do just
do 'eval.fis'
See 'perldoc -tf do'.
JJ> Then I want to access one elementl like this:
JJ> print "FSR Name = $FSR->{Name}, ll = $ll\n";
JJ> I have no access to the elements. What to do?
JJ> I tried opening the file with OPEN etc instead
JJ> of cat, but I just cannot access the structure
JJ> I have in the file eval.fis is reading the value from.
Unless you show us what data structure you have in $FSR nobody will
help you.
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/) |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/) |
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: Fri, 17 Aug 2001 17:45:20 GMT
From: morten@tangeraas.com (=?ISO-8859-1?Q?Morten_Tanger=E5s?=)
Subject: Free open source CMS's written in perl?
Message-Id: <1eyaurw.1urbiu2hcf334N%morten@tangeraas.com>
Are there any free and flexible open source content management systems,
similar to the OpenCMS project (opencms.org - it's written in java)?
Morten
------------------------------
Date: 17 Aug 2001 21:54:20 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: Free open source CMS's written in perl?
Message-Id: <87elqafu7n.fsf@abra.ru>
MT> Are there any free and flexible open source content management systems,
MT> similar to the OpenCMS project (opencms.org - it's written in java)?
Maybe http://sourceforge.net/projects/mason-cm/ ?
It is written in Perl and uses HTML::Mason.
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/) |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/) |
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: Fri, 17 Aug 2001 19:25:44 +0200
From: "Murat Uenalan" <murat.uenalan@gmx.de>
Subject: Re: Importing subroutines into the CORE::GLOBAL package does not work (perlbug)
Message-Id: <9ljjso$9mrf5$1@ID-71895.news.dfncis.de>
Murat: The thread is closed via a personal communication with gurusamy (i
just copy+paste it here):
>The subroutine is correctly installed into the CORE::GLOBAL namespace
>(as verfied by a dump of the package):
>
> CORE::GLOBAL::
> CORE::GLOBAL::BEGIN *CORE::GLOBAL::BEGIN
> CORE::GLOBAL::flops *CORE::GLOBAL::flops
CORE::GLOBAL only works for builtins--it can't be used to override user
defined subroutines. (I think the latter is a bad idea. Why not be explicit
and call Some::Package::flops() directly?)
Sarathy
gsar@ActiveState.com
gurusamy
<nobull@mail.com> schrieb im Newsbeitrag
news:u9elqbw27w.fsf@wcl-l.bham.ac.uk...
> "Murat Uenalan" <murat.uenalan@gmx.de> writes:
>
> > After getting ill not getting it work for me, if found this posting:
> >
> > [ID 20001220.004] CORE::GLOBAL support broken in 5.6.0
> >
> > with the above heading at a perl5-porters bug reports.
> >
> > Is this true for all perl 5.6+ ? And how to circumvent this ?
>
> The CORE::GLOBAL mechanism in 5.6.0 looks OK to me.
>
> I'd guess this is simply a bogus bug report. I'm further guessing
> that nobody has closed it because in the absence of a recipie to
> reproduce the OP's problem it is impossible to proove that the report
> is bogus.
>
> --
> \\ ( )
> . _\\__[oo
> .__/ \\ /\@
> . l___\\
> # ll l\\
> ###LL LL\\
------------------------------
Date: Fri, 17 Aug 2001 16:49:34 GMT
From: helgi@NOSPAMdecode.is (Helgi Briem)
Subject: Re: Is MD5 in standard installation
Message-Id: <3b7d4ad9.2189991711@news.isholf.is>
On Fri, 17 Aug 2001 09:23:46 GMT, "John P"
<john@availcheck.com> wrote:
>Hi there All (I posted this yesterday but I couldn't see my postings or any
>replies due to a fault so sorry if you've seen or replied to this already)
I think everyone in the universe has by now.
>I am distributing scripts which have the line.
>use Digest::MD5 qw (md5_base64);
>
>Most of the time the scripts are fine but on some systems the users are
>getting the error message
>
>Can't locate Digest/MD5.pm in @INC (@INC contains:
>/usr/local/lib/perl5/5.6.0/i686-linux /usr/local/lib/perl5/5.6.0
>/usr/local/lib/perl5/site_perl/5.6.0/i686-linux
>/usr/local/lib/perl5/site_perl/5.6.0 /usr/local/lib/perl5/site_perl .)
>
>I thought that this was a standard module. found in a standard location.
>Does anyone have any ideas please. I have asked them to check their Shebang
>lines are correct but they still get the error. I have some rather irrate
>customers!
>
This is something like the 10th time you have posted the
same stupid question. You're out.
*Plonk*
Regards,
Helgi Briem
------------------------------
Date: Fri, 17 Aug 2001 09:31:27 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: local exec via cgi
Message-Id: <3b7d46e0@news.microsoft.com>
"GunneR" <ds@ss.com> wrote in message
news:129rntscc67ecs5cm8hehf82cpet5618fi@4ax.com...
> I know this is very insecure, and im not sure if its even perl
> related, but...
No, your are right: this has nothing to do with Perl
> Im trying to write a cgi script that executes local code (via system,
> exec, etc) on the system that visits the page.
Let me get this straight:
- The Perl script is running as a CGI program on the web server
- You want this script to start/run some program on the client
Luckily this is not possible! It would be a security hole as large as
Alaska.
Just imagine you are visiting my web site and my CGI script would run a
"format" on your computer....
> My alternative is to use socket (server, client) stuff to talk back
> and fourth (Linux, Windows) but that could get messy.
For IE you could use an ActiveX control, but of course that's not portable.
jue
------------------------------
Date: Fri, 17 Aug 2001 11:23:36 -0400
From: "Dennis H" <dennis@noreplies.com>
Subject: Re: Looking for Script
Message-Id: <vBaf7.56128$rV6.2628169@e420r-atl2.usenetserver.com>
You could do this by making a floating static route... when the main route
goes down the floating static will take over... no need to logon and
reconfigure anything...
"T Mesbah" <tmesbah@hotmail.com> wrote in message
news:6e9d9699.0108170605.2eddec74@posting.google.com...
> The reason of using a static route is that we use encryptor on front
> of the router and these encryptor block all routing protocols and the
> only way to make it working is to use static route. I am looking for
> script to remove the static route and use an another path without
> caming in at the office and remove them manually.
>
> Thanks
>
>
> "Ian M" <ian.mulvihill.no.spam@computer.org> wrote in message
news:<3b7bc173$0$227$cc9e4d1f@news.dial.pipex.com>...
> > "Dennis H" <dennis@noreplies.com> wrote in message
> > news:KGOe7.42984$rV6.2110903@e420r-atl2.usenetserver.com...
> > >
> > >
> > > Uhhhh... why?
> > >
> > >
> > > "T Mesbah" <tmesbah@hotmail.com> wrote in message
> > > news:6e9d9699.0108151340.4493cafd@posting.google.com...
> > > > Hi,
> > > >
> > > > 1) I have two Cisco router routerA and routerB.
> > > > 2) In routerA I have static route "ip route X.X.X.X Y.Y.Y.Y Z.Z.Z.Z"
> > > > to access routerB.
> > > >
> > > > I am looking for script that ping routerB each 5 minutes and if
> > > > routerB is down then the script need to telnet to routerA and remove
> > > > these static route.
> > > >
> > > > Many Thanks
> > >
> > >
> >
> > That's what routing protocols are for. Is this too easy and efficient?
> >
> > Either you have a more complicated and unsual reason to do it this way,
or
> > misunderstand the (preferable) options. Do you want clarify what you're
> > trying to solve, and we could make some suggestions?
> >
> >
> > Cheers,
> > Ian
------------------------------
Date: 17 Aug 2001 08:35:47 -0700
From: derelixir@my-deja.com (derelixir)
Subject: Re: need opinions
Message-Id: <fd50a1dc.0108170735.20e683b9@posting.google.com>
I think I like the idea of turning the hash around...but I'm not sure
how to code it...I think it's simple but since I'm a newbie...I might
see this complicated...
I have input file which contains
e.g.
500,94,104
501,100,105
502,92,130
500 = city_id
94 = lat
104 = long
and hash array:
> %LOCATION = {
> 'California' => 500,
> 'Hollywood' => 500,
> 'Leeds' => 501,
> 'London' => 501,
> 'New York' => 502,
> 'Oklahoma' => 500,
> 'Washington' => 502
> };
>
open (INPUT_FILE, "<$INPUT_FILE") || die "cannot read file
$INPUT_FILE\n";
while (<INPUT_FILE>) {
chomp;
( $city_id, $lat, $long ) = split(/,/);
pseudo:
if $city_id is equal/match to value in %LOCATION then
print key of %LOCATION,$lat,$long;
Note that the input file never contains duplication....So I want to
duplicate the data based on location with same city id...
I hope it wont be that hard...
Your help is much appreciated
Regards.
------------------------------
Date: Fri, 17 Aug 2001 19:14:42 +0300
From: Tassos Chatzithomaoglou <achatz@forthnet.gr>
Subject: newbie regexp question
Message-Id: <3B7D42F2.4AA522E5@forthnet.gr>
$string = [1.2.3.4.5.6];
$string =~ s/[\[\]]//g;
@string_temp = split(/\./,$string);
$string = join(".", $string_temp[0],$string_temp[1],$string_temp[2],$string_temp[3]);
print "str=$string\n";
desired output
--------------
str=1.2.3.4
I'm sure someone will have a cleverer idea....
--
***************************
Chatzithomaoglou Anastasios
Network Operations Center
FORTHnet S.A.
<achatz@forthnet.gr>
***************************
------------------------------
Date: 17 Aug 2001 20:30:34 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: newbie regexp question
Message-Id: <87r8uafy39.fsf@abra.ru>
TC> $string = [1.2.3.4.5.6];
Is it $string = '[1.2.3.4.5.6]' ?
TC> $string =~ s/[\[\]]//g;
TC> @string_temp = split(/\./,$string);
TC> $string = join(".", $string_temp[0],$string_temp[1],$string_temp[2],$string_temp[3]);
TC> print "str=$string\n";
TC> desired output
TC> --------------
TC> str=1.2.3.4
TC> I'm sure someone will have a cleverer idea....
$string = '[1.2.3.4.5.6]'
($string) = $string =~ /^ \[ (\d+\.\d+\.\d+\.\d+) .* \] $/x;
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/) |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/) |
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: 17 Aug 2001 19:00:20 +0200
From: Steve Holland <holland@origo.ifa.au.dk>
Subject: Re: newbie regexp question
Message-Id: <w4766bm8vvf.fsf@origo.ifa.au.dk>
Tassos Chatzithomaoglou <achatz@forthnet.gr> writes:
> $string = [1.2.3.4.5.6];
>
> $string =~ s/[\[\]]//g;
> @string_temp = split(/\./,$string);
> $string = join(".", $string_temp[0],$string_temp[1],$string_temp[2],$string_temp[3]);
>
> print "str=$string\n";
>
>
> desired output
> --------------
> str=1.2.3.4
>
> I'm sure someone will have a cleverer idea....
Here's one method. You can generalise it by making the for loop
ending a variable, and by making the separator a variable. It will
look nicer if you turn it into a subroutine.
#! /usr/local/bin/perl -Tw
use strict;
my $string = "[1.2.3.4.5.6]"; # Don't forget the quotes
$string =~ s/^\[//; # No need for this to be global
$string =~ s/\]$//;
my @s = split(/\./,$string);
$string = undef;
for ( my $i=0; $i<4; $i++ ) {
$string .= "$s[$i].";
}
$string =~ s/\.$//;
print "str=$string\n";
=====================================================================
To find out who and where I am look at:
http://www.nd.edu/~sholland/index.html
Spammers: Please send spam to: abuse@aol.com and abuse@yahoo.com
=====================================================================
------------------------------
Date: Fri, 17 Aug 2001 15:33:57 GMT
From: Carlos C. Gonzalez <miscellaneousemail@yahoo.com>
Subject: Re: OT: Why is there so much white space in perl documentation??
Message-Id: <MPG.15e6e767f9d34f08989776@news.edmonton.telusplanet.net>
In article <74f348f7.0108162358.3b3f855b@posting.google.com>, Yves Orton
at demerphq@hotmail.com says...
> Sorry? Windows was designed? I thought it congealed out of the
> remains of a crashed C/PM box and slowly mutated into a money maker
> for gate$...
You know just as an afterthought for all of Windows faults it has done
exceptionally well in terms of who it was designed for. The average Joe
and Mary on the street who just wants to get stuff done. Bravo to
Windows for that.
> > everything is saved, etc. in case Windows crashes again. Knowing that
> > Windows WILL crash again is always in the back of my mind.
>
> Second. Switch to NT, or more realistically switch to 2000 (NT5). I
> went from as you say about 3 BSOD's a day on W98 to 1 BSOD a quater on
> NT4SP6 to 1 BSOD all this year (because of a bad driver I installed)
> on 2000.
Wow! I will definitely have to look into that. I had heard things like
that before but I never did anything about it figuring it would cost
me hundreds to get either Windows NT or 2000. I will have to look into
current prices.
> > No I certainly would not use the poor tool that Windows is as an excuse
> > for not trying to look things up myself but I'll tell you what. It's
> > frustrating sometimes to work on Windows. I mean just today I was trying
> > to install the DBD::CSV module. It took me about an hour to an hour and
> > a half just to figure out where to get it, how to use the ActiveState PPM
> > installation utility,
>
> Carlos, I am a lttle concerned to hear that it took you that long to
> use ppm. Its a pretty simple tool compared to CPAN (which still
> drives me crazy sometimes! :-)
Now that I reread my comments it would have me concerned too. =:) I
guess in my haste to author a posting masterpiece =:) I neglected to say
that it just wasn't learning to use PPM. It is a relatively simple
tool to use. Your right Yves. I couldn't remember how to use it since
the last time I did so I had to look around and get info on it (took
about 10-15 tops tops). Most of time was spent trying to figure out
where to get DBD::CSV and read information about it, whether to use it at
all in place of DB_File, trying to find examples of how to use it and
toying with them, trying to work around encountered bugs on my first
attempts, etc..
> On the other hand you are getting hundreds or thousands of hours of
> development work for free. An hour or so to learn to use it is hardly
> unfair.
Agreed. I guess I have gotten so used to getting free info off the
Internet that I hardly ever think anymore about the fact that someone,
somewhere took a heck of a lot of time to write and upload everything.
Thanks for reminding me Yves.
Still I wish things were easier and simpler for a beginning Perl
programmer trying to learn Perl and getting advice from a usenet group
mainly working on Unix. I think I see a market niche here for a book on
this. I think I will write one and offer it through my newsletter. When
I figure it all out I mean =:). Maybe I could title it "Exodus to the
command prompt - a programmers journey". =:) =:)
> Its called experience. :-)
Well I will say one nice thing about the experience I am gaining. For
all the touting that is done about Perl being an easy language to learn
and use (coughing and trying to sound believable =:) it has dawned on me
that Perl and programming in it is not for the faint of heart.
Especially for Window programmers. As such it would seem that my job
security is increased in learning a language that not too many will know
how to use really well or perhaps will want to hassle with learning
really well. In fact it may be that the more Perl is promoted the more
the market for Perl programmers increases. Due to frustrated Perly
persons giving up trying to use it themselves and deciding to hire a real
Perl programmer like me =:) to do it for them.
> As a tip carlos I strongly suggest that if you plan to use a MS based
> OS that you do the following.
>
> 1. Switch to one of the NT based OS's. W2000 is probably the stablest
> and easiest to use.
> 2. Find and download the full set of Cygwin utilities. These include
> virtually all of the standard unix tools, but for an MS os. This
> includes a replacement shell called Bash.
> 3. Go to www.sysinternals.com and download any and all tools that they
> offer for free for your OS (whichever it is that you decide) Some of
> these tools are great.
Excellent suggestions Yves. I guess I will concentrate on selling more
leminade for a while so I can affort Windows 2000. Maybe I can get my
kids to help me. It's for a good cause =:).
Thank you.
---
Carlos
www.internetsuccess.ca
*NOTE*: Internet Success is NOT yet fully operational so although you are
welcomed to visit and take a look, trying to subscribe will only be a
frustration for you as your data will not be saved at this time.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 1551
***************************************