[22773] in Perl-Users-Digest
Perl-Users Digest, Issue: 4994 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 16 14:06:06 2003
Date: Fri, 16 May 2003 11:05:19 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 16 May 2003 Volume: 10 Number: 4994
Today's topics:
[OT] Re: [The/My] trouble with Perl <simon.andrews@bbsrc.ac.uk>
Re: [The/My] trouble with Perl <bigj@kamelfreund.de>
Re: [The/My] trouble with Perl <bigj@kamelfreund.de>
Re: [The/My] trouble with Perl <simon.andrews@bbsrc.ac.uk>
A script that can (conditionally) return 3 different ex (A Epstein)
Re: A script that can (conditionally) return 3 differen <dont@want.spam>
Re: A script that can (conditionally) return 3 differen <jurgenex@hotmail.com>
Re: A script that can (conditionally) return 3 differen <nobull@mail.com>
Re: A script that can (conditionally) return 3 differen <TruthXayer@yahoo.com>
Re: concise code competition (Sara)
Re: concise code competition <tassilo.parseval@rwth-aachen.de>
Re: Conversion systems <nospam4me@yahoohoo.com>
Dynamic Module Installation <palladium@spinn.net>
Exporter not doing what I expect <michael.p.broida@boeing.com>
find and replace script... please help. (john z)
Re: find and replace script... please help. (Helgi Briem)
Re: find and replace script... please help. <mbudash@sonic.net>
Re: find and replace script... please help. <allanon@hotmail.com>
Re: find and replace script... please help. <noreply@gunnar.cc>
Re: find and replace script... please help. (Veky)
Re: find and replace script... please help. (Helgi Briem)
Re: find and replace script... please help. <bjm-nntp@vsca.ca>
Re: finding out array size (JR)
Re: Guessing content-type from file <dont@want.spam>
How to pass the fullpath file name using start_multipar <news1@jarunee.org>
Re: How to pass the fullpath file name using start_mult <news1@jarunee.org>
Re: How to Store and Print this Array? <dodger@dodger.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 16 May 2003 15:16:32 +0100
From: Simon Andrews <simon.andrews@bbsrc.ac.uk>
Subject: [OT] Re: [The/My] trouble with Perl
Message-Id: <3EC4F2C0.70400@bbsrc.ac.uk>
Helgi Briem wrote:
> On Fri, 16 May 2003 08:51:06 +0100, Simon Andrews
> <simon.andrews@bbsrc.ac.uk> wrote:
>
>
>>PS If you want a reason to not use Perl/Tk, then try interacting nicely
>>with windows print queues - but that's another thread :-)
>
>
> What on earth does interacting with print queues have
> to do with Tk???
Knew I shouldn't have added the throw away comment :-)
Not wishing to start a new thread about this, but... the one thing I
can't get to work right on my Tk-based app is getting a native interface
to selecting a printer under Windows. I've had to put a kludgy work
around in instead. I've yet to see a good solution to make Perl/Tk look
like other windows apps in this respect.
Simon.
------------------------------
Date: Fri, 16 May 2003 13:01:05 +0200
From: "Janek Schleicher" <bigj@kamelfreund.de>
Subject: Re: [The/My] trouble with Perl
Message-Id: <pan.2003.05.16.10.47.04.926046@kamelfreund.de>
Henk van Bree wrote at Fri, 16 May 2003 15:21:39 +0200:
>> You could give an example of such an incompatible widget?
>
> I meant that widget sets are incompatible with each other, not
> incompatible with itself on a different platform. If I am
> unclear at times, please bear with me, this is not my native
> language.
>
> That aside, I've made good progress with Tk, it works as
> needed.
And a native "Perl widget set" would only be another different
incompatible platform!
And usually "builting widget sets" are also incompatible to the normal
standards. E.g., look to Java. Each Java program looks the same on
different platform. But it has nearly never the typical standard outlook
behaviour of the platform. If I set any theme on red hat box, every Java
program ignores it (they must think, I'm X window system with my
preferences, just because I've been drunken). It's the same with themes
under win* systems or somewhere else.
Better we trust external libraries specialiced, like Qt, Tk, ..., that
have found the necessary ways to handle these problems.
Greetings,
Janek
------------------------------
Date: Fri, 16 May 2003 13:01:08 +0200
From: "Janek Schleicher" <bigj@kamelfreund.de>
Subject: Re: [The/My] trouble with Perl
Message-Id: <pan.2003.05.16.10.56.01.765369@kamelfreund.de>
Henk van Bree wrote at Fri, 16 May 2003 15:34:15 +0200:
>> I mean, I just used ppm to install Tk, then wrote
>> the code as per examples and instructions from
>> perldoc Tk. In some cases, I used perl2exe to package
>> the final result, but if I were doing it today I would use
>> PAR.
>
> That should work, but it starts to get very ugly if
> things *don't* work for whatever reason.
>
> If "perl -e MCPAN 'install GD'" gets you nowhere but
> pages and pages of errors it is not trivial to know
> how to fix things. Not for me, at least.
That's why there are such Perl user lists like this one in the world.
If you have a specific problem, just ask in the usenet (or on
www.perlmonks.org). Given a good and detailed description, you'll get
normally good and detailed answers specific to your problem.
Of course, that would be inacceptable for your clients (they have perhaps
paid for). But to solve that problems package archivers like PAR,
perl2exe, AppPerl, ... are created. If you have problems using them, also
the usenet will help you.
But it's to easy to say, that it is a design error of Perl not to bundle
in e.g. Tk or any other widget set automatically. IMHO, it's one of the
best design features of Perl. It's similar to Linux. It also has no built
in window manager. (Of course, Xwindow system is the de-facto-standard,
but it's not the only way, and it's right not to bundle in the Linux).
Greetings,
Janek
------------------------------
Date: Fri, 16 May 2003 15:13:25 +0100
From: Simon Andrews <simon.andrews@bbsrc.ac.uk>
Subject: Re: [The/My] trouble with Perl
Message-Id: <3EC4F205.2050806@bbsrc.ac.uk>
Henk van Bree wrote:
> Simon Andrews wrote:
>
>
>>>Hmm, I was under the impression I required at least 'tk?.dll'
>>>and some windows registry settings. I'll look into that!
>>
>>You are under a mistaken impression. We use the pp utility within the
>>PAR module distribution to bundle up Perl/Tk apps into Windows
>>executables.
>
>
> This is really great, I must have done something wrong/differently with
> my initial test setup then. I'll try again.
>
> One big .exe (for the Windows boxes) is prefered.
You will probably have to compile your own version of Perl for this to
work then as the ActiveState version uses shared libraries. It's not
that much hassle distributing perl56.dll (or whatever) with your app
though. It also means that if you're distributing several applications
you only have to send the dll once.
> Have you also done this on Linux?
Not personally, but others have and it works. One thing to ensure is
that if you are builing a linux executable then you shouldn't use the
latest glibc on your build machine as these binaries may be incompatible
with older versions. Older builds should be forward compatible though.
> If it works it solves almost all of my problems! (Still have to get
> GD to play nice, but that I'm confident about).
GD on windows is a doddle. Install ActivePerl then type
ppm install GD
..like wise for Tk
ppm install Tk
..how easy is that?
You may also want to subscribe to the PAR mailing list if you have any
problems with this. The people there were helpful to me when I was
packaging up my app.
Simon.
------------------------------
Date: 16 May 2003 06:50:54 -0700
From: epstein_asaf@emc.com (A Epstein)
Subject: A script that can (conditionally) return 3 different exit codes
Message-Id: <a82b1086.0305160550.41d4f8d2@posting.google.com>
I have to write a script that exists with exit code 0 on success, exit
code 1 on a user interactivity error (such as misspelling a word), and
exit code 2 if there is a system error that causes the script to fail.
The first two codes (0, 1) are easy. I just check if the user makes a
mistake and exit with 1. Otherwise it will exit with 0. But what
about the exiting with code 2 if there is a system problem?
Someone else's program or script will have to pick on these codes
after calling my script so this is important (for me :)).
Any suggestions?
Thanks,
A E
------------------------------
Date: Fri, 16 May 2003 16:41:03 +0100
From: Chris Lowth <dont@want.spam>
Subject: Re: A script that can (conditionally) return 3 different exit codes
Message-Id: <jE7xa.5895$sJ4.184@newsfep4-winn.server.ntli.net>
A Epstein wrote:
> I have to write a script that exists with exit code 0 on success, exit
> code 1 on a user interactivity error (such as misspelling a word), and
> exit code 2 if there is a system error that causes the script to fail.
> The first two codes (0, 1) are easy. I just check if the user makes a
> mistake and exit with 1. Otherwise it will exit with 0. But what
> about the exiting with code 2 if there is a system problem?
>
> Someone else's program or script will have to pick on these codes
> after calling my script so this is important (for me :)).
>
> Any suggestions?
>
> Thanks,
> A E
Rocket science coming up ....
exit 2;
Exiting with 2 is just as easy as exiting with 1 or 0.
--
Real address: chris at lowth dot sea oh em.
GPL e-mail anti-virus: http://protector.sourceforge.net
IPTables wizzards: http://www.lowth.com/LinWiz
------------------------------
Date: Fri, 16 May 2003 16:58:29 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: A script that can (conditionally) return 3 different exit codes
Message-Id: <VM8xa.33782$Ur1.26@nwrddc03.gnilink.net>
A Epstein wrote:
> I have to write a script that exists with exit code 0 on success, exit
> code 1 on a user interactivity error (such as misspelling a word), and
> exit code 2 if there is a system error that causes the script to fail.
> The first two codes (0, 1) are easy. I just check if the user makes a
> mistake and exit with 1. Otherwise it will exit with 0. But what
> about the exiting with code 2 if there is a system problem?
Maybe the following line will work:
exit 2;
jue
------------------------------
Date: 16 May 2003 18:10:18 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: A script that can (conditionally) return 3 different exit codes
Message-Id: <u93cjeg6md.fsf@wcl-l.bham.ac.uk>
epstein_asaf@emc.com (A Epstein) writes:
> I have to write a script that exists with exit code 0 on success, exit
> code 1 on a user interactivity error (such as misspelling a word), and
> exit code 2 if there is a system error that causes the script to fail.
> The first two codes (0, 1) are easy. I just check if the user makes a
> mistake and exit with 1. Otherwise it will exit with 0. But what
> about the exiting with code 2 if there is a system problem?
I'm not sure I understand what you are asking. If indeed you are
asking anything.
The exit code from perl in the event of abnornal termination is as
described in 'perldoc -f die'.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Fri, 16 May 2003 10:29:49 -0700
From: TruthXayer <TruthXayer@yahoo.com>
To: =?iso-8859-1?Q?J=FCrgen?= Exner <jurgenex@hotmail.com>
Subject: Re: A script that can (conditionally) return 3 different exit codes
Message-Id: <3EC5200D.F89E2DCE@yahoo.com>
"J=FCrgen Exner" wrote:
> =
> A Epstein wrote:
> > I have to write a script that exists with exit code 0 on success, exi=
t
> > code 1 on a user interactivity error (such as misspelling a word), an=
d
> > exit code 2 if there is a system error that causes the script to fail=
=2E
> > The first two codes (0, 1) are easy. I just check if the user makes =
a
> > mistake and exit with 1. Otherwise it will exit with 0. But what
> > about the exiting with code 2 if there is a system problem?
> =
> Maybe the following line will work:
> =
> exit 2;
> =
> jue
my $exit =3D $user_error? 1 :
$system_error? 2: 0;
exit $exit;
Check perldoc -f system, on how to save exit status after
system call...
=
-- =
thanks
-Tr=DCtH
------------------------------
Date: 16 May 2003 10:05:22 -0700
From: genericax@hotmail.com (Sara)
Subject: Re: concise code competition
Message-Id: <776e0325.0305160905.db5e822@posting.google.com>
"joeri" <jvandervloet@hotmail.com> wrote in message news:<CD2xa.4452$1u5.337@afrodite.telenet-ops.be>...
> Hi folks,
>
> we're having ourselves a little competition here
> on making the following code as concise as possible,
> without loosing any performance. Here's the code as it is now:
>
> opendir(DIR, $dir="c:/dir") or die "$!";
> mkdir("$dir/output");
>
> for(grep(/\.txt$/, readdir(DIR))) {
> open(FILE, "$dir/$_") or die "$!";
> $out = "$dir/output/$_";
> open(OUT, ">$out") if !-e $out || -z $out;
> for(@strings=<FILE>) {
> $_ =~ s/=/\n/g;
> print OUT;
> }
> close OUT;
> close FILE;
>
.
.
.
Reconsider your use it quotes. Anytime you see
"$var"
an alarm should go off in your, better written of course as
$var
Also, parens are nearly always optional, and it makes the program LESS readable.
mkdir("$dir/output");
better written as mkdir $dir.'/output';
perhaps? Another idiom that should set off alarms?
if (!something);
better written as
unless $something;
Cheers,
Gx
------------------------------
Date: 16 May 2003 17:46:26 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: concise code competition
Message-Id: <ba385i$853$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Sara:
> "joeri" <jvandervloet@hotmail.com> wrote in message news:<CD2xa.4452$1u5.337@afrodite.telenet-ops.be>...
>> opendir(DIR, $dir="c:/dir") or die "$!";
>> mkdir("$dir/output");
>>
>> for(grep(/\.txt$/, readdir(DIR))) {
>> open(FILE, "$dir/$_") or die "$!";
>> $out = "$dir/output/$_";
>> open(OUT, ">$out") if !-e $out || -z $out;
>> for(@strings=<FILE>) {
>> $_ =~ s/=/\n/g;
>> print OUT;
>> }
>> close OUT;
>> close FILE;
> Reconsider your use it quotes. Anytime you see
>
> "$var"
>
> an alarm should go off in your, better written of course as
>
> $var
True.
> Also, parens are nearly always optional, and it makes the program LESS
> readable.
>
> mkdir("$dir/output");
>
> better written as mkdir $dir.'/output';
And even better written as
mkdir "$dir/output";
Implicit concatenation through interpolation within strings is more
readable, IMO. And it could be further improved yet:
mkdir "$dir/output" or error_handling($!);
:-)
> perhaps? Another idiom that should set off alarms?
>
> if (!something);
>
> better written as
>
> unless $something;
Debatable. This is not necessary more readable for everyone. For me,
being a non-native speaker of English, it is not so I'd always prefer
the first. I'd leave such things up to personal preferences.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Sat, 17 May 2003 00:01:30 +1000
From: nospam4me <nospam4me@yahoohoo.com>
Subject: Re: Conversion systems
Message-Id: <3EC4EF3A.53DDE6B6@yahoohoo.com>
Kuba wrote:
>
> Today I stroke upon an idea about writing script in Perl, what it would be
> recount from number givin' in one system for other systems (eg: When I would
> entered the number '255' in decimal system this program shows me other
> values like that
> > Enter the number what you can recount (prompt from programm): 255, and in
> next a few lines program gives me other values in other systems (sth like
> that):
>
> 255 (dec) ----- [0]377 (oct) ----- [0b]1111111 (bin) ----- [0x]FF
>
> I would like, that this program working in this case that when I enter some
> number in one of every systems this program gives other values in other
> systems itself.
>
#!/bin/perl
use strict;
use warnings;
$_=$ARGV[0]||(print("Enter the number: ")and$_=<>);
chomp;
my $bin=unpack("B32",pack("N",$_));
$bin =~ s/(^0*)(1.*)/$2/;
printf("%d (dec) ----- [0]%o (oct) ----- [0b]%s ----- [0x]%X", $_, $_, $bin, $_);
------------------------------
Date: Fri, 16 May 2003 11:06:52 -0600
From: "Rodney" <palladium@spinn.net>
Subject: Dynamic Module Installation
Message-Id: <vca6mti5hqa54e@corp.supernews.com>
Hey perl Gurus;
I have a design question. I noticed (perldoc CPAN) mentions that the only
stable interface to CPAN is shell. I was wondering if I am smoking crack
here. I want to create a CPAN mirror internally (firewall issues). And then
have my clients grab their modules dynamically from my mirror based upon the
use clause within each script sent to the client. for instance, if I use
XML::Simple I want the client to connect to my mirror and download the
XML::Simple and all dependant modules required for XML::Simple. This is for
an ESM project that keeps all the clients configured the same for Change
Control reasons. I know that there is a programmers interface to CPAN, but
if it is flaky, I would rather just manually copy the proper packages to the
client at script installation time, (I have (10000+) clients.).
Any Thoughts?
Thanks,
Rod
------------------------------
Date: Fri, 16 May 2003 17:40:37 GMT
From: "Michael P. Broida" <michael.p.broida@boeing.com>
Subject: Exporter not doing what I expect
Message-Id: <3EC52295.F59E24CF@boeing.com>
Hi!
OK, it's probably something I'm not doing correctly, but...
I've setup XYZ.pm as a package. It contains (among other things):
use strict;
use warnings;
require Exporter
my @ISA = qw(Exporter);
my @EXPORT = qw(FunctionOne, FunctionTwo);
From reading (and re-reading and re-reading) the Camel book, it
seems that this SHOULD limit the "users" of XYZ to being able to
access ONLY those functions/variables that are in the EXPORT list.
But that's not happening. The "users" can call ANY function in
XYZ with no errors/warnings.
The "users" of XYZ (my main Perl script and another package) both
have (among other things):
use strict;
use warnings;
use XYZ;
If I comment out all of the Exporter stuff in XYZ.pm, then they
can't call ANY of the XYZ functions. This I expected.
I know that I -could- be explict on the "use XYZ" statement and
list all the functions to be used.
But if the "users" can get full access to everything without
listing them, what good is the EXPORT list in XYZ.pm anyway??
It seems to be exporting EVERYTHING even if the list does not
contain everything.
Mike
------------------------------
Date: 16 May 2003 08:42:03 -0700
From: jzizak@firstam.com (john z)
Subject: find and replace script... please help.
Message-Id: <38c5151a.0305160742.50f0a395@posting.google.com>
hello,
first off, i will tell you my perl skillz are rudimentary. but i know
perl can do what i am looking for.
i have a file (file.txt) about 50k in size. i need to search for
instances of variables out of cfg.txt within file.txt.
for example, cfg.txt is 4k in size in the format of:
abc123:def456
blahblah:testtest
and so on...
i need my script to loop through cfg.txt and look for def456 in
file.txt, if it finds it, replace it with abc123... and so on through
out cfg.txt.
any help will be greatly appreciated.
Thanks!
Best regards,
jz
------------------------------
Date: Fri, 16 May 2003 15:55:03 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: find and replace script... please help.
Message-Id: <3ec508fa.3114059270@news.cis.dfn.de>
On 16 May 2003 08:42:03 -0700, jzizak@firstam.com (john z)
wrote:
>first off, i will tell you my perl skillz are rudimentary.
So are your spelling skills.
>i have a file (file.txt) about 50k in size. i need to search for
>instances of variables out of cfg.txt within file.txt.
>
>for example, cfg.txt is 4k in size in the format of:
>
>abc123:def456
>blahblah:testtest
>and so on...
>
>i need my script to loop through cfg.txt and look for def456 in
>file.txt, if it finds it, replace it with abc123... and so on through
>out cfg.txt.
Use a hash to store the replacements, i.e.+
my ($old,$new) = split /:/,$line;
%replacement_for{$old} = $new;
For the rest, you'll need the usual stuff,
open, die, while, split, close, s///, print.
Read about them with perldoc
perldoc -f open
perldoc -f die
perldoc perlsyn
perldoc -f split
perldoc -f close
perldoc perlrequick
perldoc -f print
--
Regards, Helgi Briem
helgi DOT briem AT decode DOT is
------------------------------
Date: Fri, 16 May 2003 15:55:02 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: find and replace script... please help.
Message-Id: <mbudash-D18817.08550116052003@typhoon.sonic.net>
In article <38c5151a.0305160742.50f0a395@posting.google.com>,
jzizak@firstam.com (john z) wrote:
> hello,
>
> first off, i will tell you my perl skillz are rudimentary. but i know
> perl can do what i am looking for.
>
> i have a file (file.txt) about 50k in size. i need to search for
> instances of variables out of cfg.txt within file.txt.
>
> for example, cfg.txt is 4k in size in the format of:
>
> abc123:def456
> blahblah:testtest
> and so on...
>
> i need my script to loop through cfg.txt and look for def456 in
> file.txt, if it finds it, replace it with abc123... and so on through
> out cfg.txt.
>
> any help will be greatly appreciated.
> Thanks!
>
> Best regards,
> jz
what have you tried so far with your admittedly rudimentary perl skillz
[sic]?
--
Michael Budash
------------------------------
Date: Fri, 16 May 2003 16:56:35 +0100
From: "Allanon" <allanon@hotmail.com>
Subject: Re: find and replace script... please help.
Message-Id: <ba31nl$pso@newton.cc.rl.ac.uk>
"john z" <jzizak@firstam.com> wrote in message
news:38c5151a.0305160742.50f0a395@posting.google.com...
> hello,
>
> first off, i will tell you my perl skillz are rudimentary. but i know
> perl can do what i am looking for.
>
> i have a file (file.txt) about 50k in size. i need to search for
> instances of variables out of cfg.txt within file.txt.
>
> for example, cfg.txt is 4k in size in the format of:
>
> abc123:def456
> blahblah:testtest
> and so on...
>
> i need my script to loop through cfg.txt and look for def456 in
> file.txt, if it finds it, replace it with abc123... and so on through
> out cfg.txt.
open(FILE,"file.txt");
@file = <FILE>;
close(FILE);
open(CFG,"cfg.txt");
while(<CFG>)
{
@tmp = split /:/,$_;
foreach $line(@file)
{
$line =~ s/$tmp[1]/$tmp[0]/;
}
}
close(CFG);
open(FILE,">file.txt");
print FILE @file;
close(FILE);
That assumes you want a case-sensitive match and that there may only be one
incidence of $tmp[0] per line of file.txt. There's probably a way of doing
it with less lines too, but that's the way I know.
Allanon
------------------------------
Date: Fri, 16 May 2003 18:02:25 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: find and replace script... please help.
Message-Id: <ba322j$ohgke$1@ID-184292.news.dfncis.de>
john z wrote:
> first off, i will tell you my perl skillz are rudimentary. but i
> know perl can do what i am looking for.
I agree that Perl can do it. So, please let us know about your
thoughts so far about a Perl solution to the problem. Where have you
looked for guidance? Maybe you could provide us with some code?
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Fri, 16 May 2003 16:08:56 +0000 (UTC)
From: veky@cromath.math.hr (Veky)
Subject: Re: find and replace script... please help.
Message-Id: <ba32en$8f2$1@bagan.srce.hr>
Dok je Veky citao comp.lang.perl.misc, pod PIDom 22504 (290021 off, 0 to go...),
primijetio je kreaturu zvanu jzizak@firstam.com (john z),
ispod cijih su prstiju izasle (izmedu ostalih) sljedece rijeci:
|i have a file (file.txt) about 50k in size. i need to search for
|instances of variables out of cfg.txt within file.txt.
|
|for example, cfg.txt is 4k in size in the format of:
|
|abc123:def456
|blahblah:testtest
|and so on...
|
|i need my script to loop through cfg.txt and look for def456 in
|file.txt, if it finds it, replace it with abc123... and so on through
|out cfg.txt.
Place this into file "s" :
BEGIN{open F,"cfg.txt";/^(.*):(.*)$/ and$ss{$2}=$1 while<F>}
s/$_/$ss{$_}/g for keys%ss
Then execute perl -pi s file.txt ...
If you have any questions, just ask.
--
\#{% Sad gradi svoj grad iz snova... znaj da mozes i znaj da znas...
------------------------------
Date: Fri, 16 May 2003 16:23:52 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: find and replace script... please help.
Message-Id: <3ec51075.3115974654@news.cis.dfn.de>
On Fri, 16 May 2003 15:55:03 GMT, helgi@decode.is (Helgi
Briem) wrote:
>>i need my script to loop through cfg.txt and look for def456 in
>>file.txt, if it finds it, replace it with abc123... and so on through
>>out cfg.txt.
>
>Use a hash to store the replacements, i.e.+
>my ($old,$new) = split /:/,$line;
Sorry, misread the requirements, should be
my ($new,$old) = split /:/,$line;
--
Regards, Helgi Briem
helgi DOT briem AT decode DOT is
------------------------------
Date: Fri, 16 May 2003 17:12:59 GMT
From: Brad Murray <bjm-nntp@vsca.ca>
Subject: Re: find and replace script... please help.
Message-Id: <v_8xa.13$O72.20283@news2.telusplanet.net>
Helgi Briem <helgi@decode.is> wrote:
HB> Use a hash to store the replacements, i.e.+
HB> my ($old,$new) = split /:/,$line;
HB> %replacement_for{$old} = $new;
%repl = ( %repl,split(/:/,$line));
/me hides
--
Brad Murray * The trouble with troubleshooting is that trouble
VSCA Founder * sometimes shoots back -- <Rejo>
------------------------------
Date: 16 May 2003 09:06:10 -0700
From: jrolandumuc@yahoo.com (JR)
Subject: Re: finding out array size
Message-Id: <b386d54b.0305160806.518abd5d@posting.google.com>
"leeper" <sav_me_to_nospam@hotmail.com> wrote in message news:<ba1ikk$omh$1@perki.connect.com.au>...
> If I had the number of bytes (ie. 7375765348000) and want to break it up
> with commas, how do I find out the elements size
## This sub will commify whole numbers.
sub commify {
my $number = reverse shift;
$number =~ s/(\d\d\d)(?=\d)/$1,/g;
return scalar reverse $number;
}
## This sub will commify most number types (see page 64 of the Perl Cookbook)
sub commify {
my $number = reverse shift;
$number =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g;
return scalar reverese $number;
}
I'm not sure this is what you are trying to do, though. Good luck.
------------------------------
Date: Fri, 16 May 2003 16:44:07 +0100
From: Chris Lowth <dont@want.spam>
Subject: Re: Guessing content-type from file
Message-Id: <aH7xa.5900$sJ4.3323@newsfep4-winn.server.ntli.net>
Thomas Güttler wrote:
> Hi!
>
> Is there a perl module which can guess
> a content-type of a file by:
> - extension (.txt, .pl, ...)
> - by looking at it (like file)
>
> The content-type should be a mime.type like
> in /etc/mime.types: Example application/postscript.
>
> I looked at CPAN but, didn't found it.
>
> thomas
On linux (you dont say what platform you are interested in) the shell
command 'file' can return mime types - with the '-i' option.
eg (simplistic) ..
$type = `file -i '$filename'`;
Chris
--
Real address: chris at lowth dot sea oh em.
GPL e-mail anti-virus: http://protector.sourceforge.net
IPTables wizzards: http://www.lowth.com/LinWiz
------------------------------
Date: Fri, 16 May 2003 18:28:17 +0200
From: GauthK <news1@jarunee.org>
Subject: How to pass the fullpath file name using start_multipart_form
Message-Id: <3ec5118b$0$17321$626a54ce@news.free.fr>
Hi,
I have the following code :
a first web form with filefield(browse) open a second web form and pass
the filename using GET
*** example file1.pl****************
#!/usr/bin/perl
use CGI;
use File::Basename;
$query = new CGI;
print $query->header(); #-cookie=>$cookie);
print $query->start_html("Files Selection for CIV1&2:");
print "<body bgcolor='#00FF00'>";
print
$query->start_multipart_form(-method=>GET,-action=>'http://localhost/civ-perl/file2.pl',-target=>'civ-parametres');
print $query->filefield('current_file','starting value',50,80);
print $query->submit(-name=>'=> civ processing options');
print $query->endform;
print $query->end_html;
********** end of the example ********************
The goal of this first page is to pass as argument the 'current_file'
file name to file2.pl ; or when I submit the script open the URL:
http://ddsfsdffdsf...file2.pl?current_file=filename&........ even if in
the current_file field on file1.pl it appears the full path :
/home/toto/here/filename.
I'm very disappointed with file , this method has worked under apache
and linux last year and still work under IIS and activeperl; but I
cannot make it works now .
If someone can help me to finish this nightmare ....
Thanks
------------------------------
Date: Fri, 16 May 2003 19:17:02 +0200
From: GauthK <news1@jarunee.org>
Subject: Re: How to pass the fullpath file name using start_multipart_form
Message-Id: <3ec51cf8$0$17310$626a54ce@news.free.fr>
It's a browser problem , I've just try to access the same web page from
a windows station and it works ; so I'm looking how to make it works
with linux/mozilla
> GauthK wrote:
> Hi,
> I have the following code :
> a first web form with filefield(browse) open a second web form and pass
> the filename using GET
> *** example file1.pl****************
> #!/usr/bin/perl
> use CGI;
> use File::Basename;
>
> $query = new CGI;
> print $query->header(); #-cookie=>$cookie);
> print $query->start_html("Files Selection for CIV1&2:");
> print "<body bgcolor='#00FF00'>";
> print
> $query->start_multipart_form(-method=>GET,-action=>'http://localhost/civ-perl/file2.pl',-target=>'civ-parametres');
>
> print $query->filefield('current_file','starting value',50,80);
> print $query->submit(-name=>'=> civ processing options');
> print $query->endform;
> print $query->end_html;
> ********** end of the example ********************
> The goal of this first page is to pass as argument the 'current_file'
> file name to file2.pl ; or when I submit the script open the URL:
> http://ddsfsdffdsf...file2.pl?current_file=filename&........ even if in
> the current_file field on file1.pl it appears the full path :
> /home/toto/here/filename.
>
> I'm very disappointed with file , this method has worked under apache
> and linux last year and still work under IIS and activeperl; but I
> cannot make it works now .
> If someone can help me to finish this nightmare ....
>
> Thanks
>
>
------------------------------
Date: Fri, 16 May 2003 09:33:11 -0500
From: Dodger <dodger@dodger.org>
Subject: Re: How to Store and Print this Array?
Message-Id: <Xns937D4D2C1E7CFdodgerdodgerorg@216.166.71.239>
On 14 May 2003, dave_h4@yahoo.com (Hunter) in
news:27ad91d2.0305140543.5eb9d3ec@posting.google.com said something that
resembled:
> "Bob Dover" <dover@nortelnetworks.com> wrote in message
> news:<b9r1k7$h08$1@zcars0v6.ca.nortel.com>...
>> "Hunter" wrote...
>> > Hi - I need to query a database and print the rows returned.
>>
>> Homework Alert -- How's the weather up in Oregon, btw?
>
>
> Hmm. What are you talking about? I'm Canadian and this is definitely
> not homework.
>
> Thanks for the (bizarre) respsonse anyway.
>
> dave
>
For the record, though, it's rainy. (What did you expect the weather in
Oregon to be?)
B^)
--
Dodger
------------------------------
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 4994
***************************************