[22795] in Perl-Users-Digest
Perl-Users Digest, Issue: 5016 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed May 21 00:05:55 2003
Date: Tue, 20 May 2003 21:05:10 -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 Tue, 20 May 2003 Volume: 10 Number: 5016
Today's topics:
Re: advice re perl modules <REMOVEsdnCAPS@comcast.net>
Re: advice re perl modules <mgjv@tradingpost.com.au>
Re: advice re perl modules <maxw@sgi.com>
Re: advice re perl modules <maxw@sgi.com>
Re: can fork() be an alternative to while (1)? <mgjv@tradingpost.com.au>
Re: error handling on file open <REMOVEsdnCAPS@comcast.net>
Re: error handling on file open <krahnj@acm.org>
Finding files and moving them in perl (david)
Re: Newbie Questions: functions <bwalton@rochester.rr.com>
Passing arguments by reference <spamtrap@cfm-consulting.com>
Re: Passing arguments by reference <spam@thecouch.homeip.net>
Re: Passing arguments by reference <REMOVEsdnCAPS@comcast.net>
Perl 5.8.0 i/o to serial port(s)? (Bob Mariotti)
Re: Problem with regular expression evaluation from per <REMOVEsdnCAPS@comcast.net>
Re: Searching and replacing strings in a file (Vinod. K)
Re: Sending email with perl. <bwalton@rochester.rr.com>
Re: While loops and arrays <jurgenex@hotmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 20 May 2003 20:08:08 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: advice re perl modules
Message-Id: <Xns9381D7031ADCEsdn.comcast@216.166.71.239>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
Max Waterman <maxw@sgi.com> wrote in
news:badquj$1l18qg$1@fido.engr.sgi.com:
> Noone seems to want to answer this question.
Two hours is a _very_ short time to wait for an answer on Usenet. If
nobody has answered your question in two *days*, then you might draw that
conclusion.
- --
Eric
print scalar reverse sort qw p ekca lre reh
ts uJ p, $/.r, map $_.$", qw e p h tona e;
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBPsrReWPeouIeTNHoEQLjkgCg/R2eKndkjf3r5K3iXl1/OHM44WsAn1i2
sVfDRDlj1mbkP9S7mhwohM5T
=S5J6
-----END PGP SIGNATURE-----
------------------------------
Date: Wed, 21 May 2003 01:06:19 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: advice re perl modules
Message-Id: <slrnbclk8b.88a.mgjv@verbruggen.comdyn.com.au>
On Tue, 20 May 2003 22:58:57 GMT,
w i l l <willis_31_40@yahoo.com> wrote:
> On Tue, 20 May 2003 09:26:31 -0700, Max Waterman <maxw@sgi.com> wrote:
>
>>Hi,
>>
>>I can install perl modules, but I should not update any that are already
>>installed since other applications rely on them.
> I think someone beat me to the punch, but just install the modules in
> their own specific directory away from the other modules. I'd clear
> out the @INC dir then
Why would you want to do that? All modules that are in standard
locations would suddenly not be found anymore.
> use lib qw(/path/to/my/modules);
> so that the application is only looking in that specific directory for
> those modules. You will have no problems that way.
This will put /path/to/my/modules first in @INC, which would mean that
any modules installed there would be found before any others. Why
wouldn't that be sufficient? What sort of problems do you foresee that
could occur?
Martien
--
|
Martien Verbruggen | We are born naked, wet and hungry. Then
Trading Post Australia | things get worse.
|
------------------------------
Date: Tue, 20 May 2003 18:11:08 -0700
From: Max Waterman <maxw@sgi.com>
Subject: Re: advice re perl modules
Message-Id: <baejpa$1l1vje$1@fido.engr.sgi.com>
See my other post...
Thanks though.
Max.
Eric J. Roode wrote:
> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
>
> Max Waterman <maxw@sgi.com> wrote in
> news:badquj$1l18qg$1@fido.engr.sgi.com:
>
>
>>Noone seems to want to answer this question.
>
>
> Two hours is a _very_ short time to wait for an answer on Usenet. If
> nobody has answered your question in two *days*, then you might draw that
> conclusion.
>
> - --
> Eric
> print scalar reverse sort qw p ekca lre reh
> ts uJ p, $/.r, map $_.$", qw e p h tona e;
>
> -----BEGIN xxx SIGNATURE-----
> Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
>
> iQA/AwUBPsrReWPeouIeTNHoEQLjkgCg/R2eKndkjf3r5K3iXl1/OHM44WsAn1i2
> sVfDRDlj1mbkP9S7mhwohM5T
> =S5J6
> -----END PGP SIGNATURE-----
------------------------------
Date: Tue, 20 May 2003 19:05:54 -0700
From: Max Waterman <maxw@sgi.com>
Subject: Re: advice re perl modules
Message-Id: <baen02$1l51da$1@fido.engr.sgi.com>
w i l l wrote:
> On Tue, 20 May 2003 09:26:31 -0700, Max Waterman <maxw@sgi.com> wrote:
>
> I think someone beat me to the punch, but just install the modules in
> their own specific directory away from the other modules. I'd clear
> out the @INC dir then
> use lib qw(/path/to/my/modules);
> so that the application is only looking in that specific directory for
> those modules. You will have no problems that way.
>
> However, you may have problems with trying to run new versions of
> modules with old versions of perl. Some modules need to get updated
> with newer versions of perl.
Right, but if I copy the perl executable and it's dependancies, then I
might be alright....
>
> anyway, there's my $.02
Thanks very much. A little bit more explicit than the other post, which I
haven't had time to act on yet.
Thanks.
Max.
------------------------------
Date: Wed, 21 May 2003 01:39:17 GMT
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: can fork() be an alternative to while (1)?
Message-Id: <slrnbclm65.88a.mgjv@verbruggen.comdyn.com.au>
On Tue, 20 May 2003 07:48:14 GMT,
Andrej Hocevar <ah@siol.net> wrote:
> Hello,
> I've never forked anyhing until now, but this time I may have to do it.
> I have a curses program that does things for different key-presses,
> all of which is inside a while (1) {...} loop. (Of course,) this
> takes over the cpu.
Since you're using curses, maybe you should use the getch (or friends)
in delay mode (you're probably using it in nodelay mode. Extract from
getch() manual page for ncurses;
The getch, wgetch, mvgetch and mvwgetch, routines read a
character from the window. In no-delay mode, if no input is waiting,
the value ERR is returned. In delay mode, the program waits until
the system passes text through to the program. Depending on the
setting of cbreak, this is after one character (cbreak mode), or
after the first newline (nocbreak mode). In half-delay mode, the
program waits until a charac- ter is typed or the specified timeout
has been reached.
Also look at the manual page for cbreak(), nodelay() and halfdelay().
The manual pages for curses on Solaris have similar wording. The
Curses documentation does not mention any of these as not supported,
so you should be able to use them.
> Is it possible to do such things with fork? What is the basic idea
> behind that? Or is there maybe another trick to wait until a key
> really is pressed and then execute the loop?
You are not looking for something like fork. You're looking for
something that blocks until a key is pressed. Curses already has that.
Martien
--
|
Martien Verbruggen | Freudian slip: when you say one thing but
Trading Post Australia | mean your mother.
|
------------------------------
Date: Tue, 20 May 2003 20:20:49 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: error handling on file open
Message-Id: <Xns9381D929FFF0Bsdn.comcast@216.166.71.239>
"Rene Scheibe" <Rene.Scheibe@gmx.net> wrote in news:baebsj$slmfu$1@ID-
65612.news.dfncis.de:
> i have some questions about handling errors
> when opening files. for example you can do
>
> open (FILE, "filenpath") or die("cannot open file");
>
> my questions:
> 1) what is the difference using "or" or "||"?
Precedence, nothing else. In your line above, using "or" or || would
make no difference. Many people like to omit the parentheses, however,
and thus need to use "or":
open FILE, "filenpath" or die "cannot open file";
is
(open FILE, "filenpath") or (die "cannot open file");
while
open FILE, "filenpath" || die "cannot open file";
is
open FILE, ("filenpath" || (die "cannot open file"));
Not what you want.
> 2) how can i run more than one command after "or"?
> the following doesnt work:
> open (FILE, "filepath") or {
> print "cannot open file";
> print "exiting script";
> exit; }
unless (open FILE, "filepath")
{
...do stuff
}
--
Eric
print scalar reverse sort qw p ekca lre reh
ts uJ p, $/.r, map $_.$", qw e p h tona e;
------------------------------
Date: Wed, 21 May 2003 03:45:59 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: error handling on file open
Message-Id: <3ECAF628.76EFC3E9@acm.org>
Rene Scheibe wrote:
>
> i have some questions about handling errors
> when opening files. for example you can do
>
> open (FILE, "filenpath") or die("cannot open file");
>
> my questions:
> 1) what is the difference using "or" or "||"?
"or" has lower precedence then most other operators including "||". If
you use "||" then you have to put parenthesis around the arguments to
open() or "||" will apply to the last argument instead of open().
> 2) how can i run more than one command after "or"?
> the following doesnt work:
> open (FILE, "filepath") or {
> print "cannot open file";
> print "exiting script";
> exit; }
open( FILE, 'filepath' ) or do {
print 'cannot open file';
print 'exiting script';
exit;
}
Or:
unless ( open FILE, 'filepath' ) {
print 'cannot open file';
print 'exiting script';
exit;
}
John
--
use Perl;
program
fulfillment
------------------------------
Date: 20 May 2003 19:13:36 -0700
From: dwlepage@yahoo.com (david)
Subject: Finding files and moving them in perl
Message-Id: <b09a22ae.0305201813.138fefa8@posting.google.com>
Im wondering if someone can help me with this simple perl problem. I
have files in a directory /opt/scripts of the format:
QF12345
DF12345
QF23456
DF23456
If I find files that start with QF(.*) and DF$1 I want to copy them to
a different directory. I've been toying with File::Find and
File::Copy, and seem to have a way to find and a seperate way to copy
the files but cannot seem to implement the right solution. Here is
what I have so far:
#!/usr/bin/perl
use strict;
use File::Find;
use File::Copy;
sub findfile {
if ($File::Find::name=~/QF(.*)/i or $File::Find::name=~/DF$1/i) {
print $File::Find::name;
print "\n";
}
}
find \&findfile, '/opt/scripts';
Any idea how I can get the files I find to then copy them to a
seperate directory?
Thanks!
Dave
------------------------------
Date: Wed, 21 May 2003 01:13:52 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Newbie Questions: functions
Message-Id: <3ECAD17D.7000503@rochester.rr.com>
ThePotPlants wrote:
> I want to write my programme as functions and call them from a main
> programme.
>
> I've seen you can call subroutines, and pass variables. how do I do this if
> it is a seperate file?
>
> Also, I want the subroutine/function to chew through a list, can I pass
> multiple values to a subroutine?
> eg.call subroutine copy_table $taskname %table
> (and $table could be 10 tables.)
If you want to define subs in separate files, there are a couple of ways
of proceeding. One way is to put your subs in one or more files, just
as if they were in your main program. Then (if using require) put a 1;
as the last line of the file (so it returns a true value when executed)
and put:
do 'filename.pl';
or
require 'filename.pl';
in your main program file at the point where you would like the subs to
become defined. You can put any Perl code in such a file -- the do or
require statement executes it as if it were inline at the point where
the do or require statement occurs. See:
perldoc -f do
perldoc -f require
Another (probably better but also more complex) way to do it is to
define your subs as object methods in a Perl module. This topic is
complex enough that you should pick up a book on the subject, perhaps
"Object Oriented Perl" by Damian Conway. You can also read the various
Perl docs about object-oriented programming, such as:
perldoc perlboot
perldoc perltoot
perldoc perltooc
perldoc perlbot
etc.
Regarding the question about calling subs with multiple arguments, you
gave an example with a scalar and a hash. When passing arrays or hashes
to subs, in general you will want to pass a reference to each array or
hash. This is because all the arguments to a sub get flattened into one
list (called @_) in the sub. It then becomes difficult to determine
which elements belong to what array or hash. Example:
copy_table($taskname,\%table); #call sub copy_table
...
sub copy_table{
my $name_of_task=shift;
my $hashref=shift; #obtain reference to hash
my $val=$$hashref{key};
$$hashref{key2}='value';
...
}
Note that when you pass a reference, you are dealing with the
referred-to entity itself, not a copy of it. So the
$$hashref{key2}='value'; line above will modify %table in the calling
program.
For more detail, see:
perldoc perlsub
HTH.
--
Bob Walton
------------------------------
Date: Wed, 21 May 2003 02:35:07 GMT
From: "Eric" <spamtrap@cfm-consulting.com>
Subject: Passing arguments by reference
Message-Id: <vBBya.52145$rt6.20098@sccrnsc02>
Hi all,
Could you please take a peek at the following code:
use strict ;
use Data::Dumper ;
my %hash = (
'Manfred' => {
'Color' => 'Brown',
'Size' => 'X-Large',
},
'Diego' => {
'Color' => 'Orange',
'Size' => 'Medium',
},
'Sid' => {
'Color' => 'Green',
'Size' => 'Small',
}
) ;
sub movePtr {
my ($ptr,$key) = @_ ;
print "$ptr $_[0]\n" ; # Addresses are the same, it's cool
$ptr = $ptr->{$key} ; # This doesn't seem to do anything
# $_[0]= $_[0]->{$key} ; # Line that fixes it
}
my $ptr = \%hash ;
movePtr($ptr,'Diego') ;
print Dumper($ptr) ;
As it is, I'd expect $ptr to hold the address of whatever the 'Diego' key is
pointing to. Instead of that, I get the whole %hash. the print "$ptr
$_[0]\n" lines shows that $ptr is pointing to the address stored in $_[0],
so it would stand to reason that the value at this address get modified by
movePtr.
To get the script to work to the level of my expectation, I have to work
directly with @_, but I cannot explain myself why that would work, but
assigning $_[0] to a variable wouldn't...
Please shed some light !
------------------------------
Date: Tue, 20 May 2003 23:22:20 -0400
From: Mina Naguib <spam@thecouch.homeip.net>
Subject: Re: Passing arguments by reference
Message-Id: <MhCya.18818$7B6.383971@wagner.videotron.net>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
Eric wrote:
> Hi all,
>
> Could you please take a peek at the following code:
>
> use strict ;
> use Data::Dumper ;
> my %hash = (
> 'Manfred' => {
> 'Color' => 'Brown',
> 'Size' => 'X-Large',
> },
> 'Diego' => {
> 'Color' => 'Orange',
> 'Size' => 'Medium',
> },
> 'Sid' => {
> 'Color' => 'Green',
> 'Size' => 'Small',
> }
> ) ;
>
> sub movePtr {
> my ($ptr,$key) = @_ ;
> print "$ptr $_[0]\n" ; # Addresses are the same, it's cool
> $ptr = $ptr->{$key} ; # This doesn't seem to do anything
> # $_[0]= $_[0]->{$key} ; # Line that fixes it
> }
>
> my $ptr = \%hash ;
> movePtr($ptr,'Diego') ;
> print Dumper($ptr) ;
>
> As it is, I'd expect $ptr to hold the address of whatever the 'Diego' key is
> pointing to. Instead of that, I get the whole %hash. the print "$ptr
> $_[0]\n" lines shows that $ptr is pointing to the address stored in $_[0],
> so it would stand to reason that the value at this address get modified by
> movePtr.
>
> To get the script to work to the level of my expectation, I have to work
> directly with @_, but I cannot explain myself why that would work, but
> assigning $_[0] to a variable wouldn't...
The answer lies in perldoc -f my
my localizes a variable to the enclosing block. Inside your sub
movePtr, you create a new variable $ptr and assign it a few values, a
couple of times. That's great while you're inside sub movePTR, however
once that sub's done, that $ptr disappears, and the main $ptr global
variable remains untouched. I think you may be a bit confused because
you're using the same name for both. Try a different name inside the
sub for clariness.
Best of luck.
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQE+yvDveS99pGMif6wRAlRWAKDc9qKioQQAcIv1LMC033sEcJympQCg0bCo
0bj/d3ufyQQWfK6uRcThZ8s=
=KVnf
-----END PGP SIGNATURE-----
------------------------------
Date: Tue, 20 May 2003 23:03:54 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Passing arguments by reference
Message-Id: <Xns9382A3FE2E6sdn.comcast@216.166.71.239>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
"Eric" <spamtrap@cfm-consulting.com> wrote in
news:vBBya.52145$rt6.20098@sccrnsc02:
> Hi all,
>
> Could you please take a peek at the following code:
>
> use strict ;
> use Data::Dumper ;
> my %hash = (
> 'Manfred' => {
> 'Color' => 'Brown',
> 'Size' => 'X-Large',
> },
> 'Diego' => {
> 'Color' => 'Orange',
> 'Size' => 'Medium',
> },
> 'Sid' => {
> 'Color' => 'Green',
> 'Size' => 'Small',
> }
> ) ;
>
1. > sub movePtr {
2. > my ($ptr,$key) = @_ ;
3. > print "$ptr $_[0]\n" ; # Addresses are the same, it's cool
4. > $ptr = $ptr->{$key} ; # This doesn't seem to do anything
5. > # $_[0]= $_[0]->{$key} ; # Line that fixes it
> }
>
6. > my $ptr = \%hash ;
7. > movePtr($ptr,'Diego') ;
> print Dumper($ptr) ;
>
> As it is, I'd expect $ptr to hold the address of whatever the 'Diego'
> key is pointing to. Instead of that, I get the whole %hash. the print
> "$ptr $_[0]\n" lines shows that $ptr is pointing to the address stored
> in $_[0], so it would stand to reason that the value at this address
> get modified by movePtr.
$ptr is simply a scalar variable. I numbered some of your lines above.
On line 2, you assign $_[0] to $ptr. Based on lines 6 and 7, $ptr now
contains a reference to %hash. Fine.
On line 4, you assign $ptr->{Diego}, which is to say $hash{Diego}, to
$ptr. You could have assigned 'fruit salad' to $ptr, for all it's
worth... $ptr is simply a scalar variable. On line 2 it contained a
reference to %hash, but on line 4 you broke that link.
If you wanted to change line 6's $ptr, the only way to do that is by
using $_[0], which contains a reference to $ptr (NOT %hash).
There's a bit of confusion because you used the name $ptr twice. The
$ptr in lines 2 through 5 has nothing to do with the one on lines 6 and
7. They're completely separate variables. This is a feature.
HTH.
- --
Eric
print scalar reverse sort qw p ekca lre reh
ts uJ p, $/.r, map $_.$", qw e p h tona e;
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBPsr6n2PeouIeTNHoEQJNXgCfWy62MS2kesd8vbpdBbEjwCNJ8S0AoPdy
V+Tirbooa5W8dcKJ2n3CrtIj
=YQAU
-----END PGP SIGNATURE-----
------------------------------
Date: Wed, 21 May 2003 02:25:26 GMT
From: R.Mariotti@FinancialDataCorp.com (Bob Mariotti)
Subject: Perl 5.8.0 i/o to serial port(s)?
Message-Id: <3ecac2a7.5200433@news.cshore.com>
Calling for help after a few frustrating days.
We are migrating an perl application suite from AIX to RH8.0.
We have an IO subroutine that writes a string to the RH server's
serial port (/dev/tty0100) which is connected to a local serial port
on a different server. While we can get data to go back and forth
using the keyboard(s) (using print/echo and cat) we cannot from within
our perl program(s).
We are assuming the problem lies with the handling of EOL based on \r
and/or \r sequences. We've tried adding either and both in various
order to the string being output without success.
Does anyone have any suggestion and/or recommendations as to what we
can look at? How should we configure the port on RH? Using stty?
Please provide any guidance and suggestions you can?
Thanks a million (or two if your suggestions work).
Frustrated perl programmer.
------------------------------
Date: Tue, 20 May 2003 20:14:35 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Problem with regular expression evaluation from perl 5.6 to 5.8
Message-Id: <Xns9381D81B19321sdn.comcast@216.166.71.239>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
"Gregory K. Deal" <nospam.gregory.deal@unisys.com> wrote in
news:bads0v$rsn$1@trsvr.tr.unisys.com:
> We have a regular expression that runs as expected in perl 5.6, yet
> functions differently (and thought to be wrong) in 5.8. Did RE
> handling change in 5.8, were we doing something illegal or
> implementation dependent, or what? Thanks for any input.
>
> Original statement in 5.6 :
> regular expression as an IF argument : if ($inst2_key =~
> /_${index}$/) { . . . .
> This finds the pattern specified in the $index variable at the end
> of
> the line. But, in 5.8, the IF did not match.
>
> Modified statement in 5.8 :
> regular expression now : if ($inst2_key =~ /_${index}/m) { .
> . . . This works as expected in 5.6 and 5.8
>
Please post sample *data* so that others can attempt to replicate the
problem, for crying out loud.
- --
Eric
print scalar reverse sort qw p ekca lre reh
ts uJ p, $/.r, map $_.$", qw e p h tona e;
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBPsrS+2PeouIeTNHoEQL5tgCdGYoqsGvwyUewXt7Osj2IVeKVOjoAn2OJ
BrcQWwTTBjClRrQhy0mBFyQ7
=5HEC
-----END PGP SIGNATURE-----
------------------------------
Date: 20 May 2003 20:28:59 -0700
From: pkvinu@indiatimes.com (Vinod. K)
Subject: Re: Searching and replacing strings in a file
Message-Id: <bde4ceed.0305201928.11a23aa9@posting.google.com>
"Allanon" <allanon@hotmail.com> wrote in message news:<bact1t$12je@newton.cc.rl.ac.uk>...
> "Vinod. K" <pkvinu@indiatimes.com> wrote in message
> news:bde4ceed.0305200105.592b2e9f@posting.google.com...
> > Hello All,
> >
> > I have 2 questions ( Here my working environmet is unix):
> >
> > 1.) In unix environment, I got a text file in which I need to search
> > and replace a string/s. Is there any specific module or command ????
>
> Not 100% sure about the file path syntax for unix, but u could use sth like:
>
> # variables
> $str_to_replace = "blah";
> $replace_with = "blah blah";
>
> # get file into array
> open(FILE,"/usr/data/myfile");
> @lines = <FILE>;
> close(FILE);
>
> # perform string replace
> foreach(@lines){
> $_ =~ s/$str_to_replace/$replace_with/g; # add i after g to make
> case-insensitive
> }
>
> # write back to file
> open(FILE,">/usr/data/myfile");
> foreach(@lines){
> print FILE $_;
> }
> close(FILE);
>
> > 2.) I want to create some text file which I can able to open in
> > windows word application. I mean - read a input file and create output
> > file which should be a word document. is this possible to create the
> > word document??? and other question is - is it possible to insert a
> > log into this document or any other text file ???
>
> A Microsoft Word file is normally a binary file due to all the formatting
> and ibjects you can insert. However, you can create a normal text file with
> the extension ".doc" and it will open in Word. When it's opened it'll
> default to something like Courier font.
>
> Allanon
Thanks,guys.
I got the solutions. Thanks for ur help.
- vinod.
------------------------------
Date: Wed, 21 May 2003 01:22:53 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Sending email with perl.
Message-Id: <3ECAD39A.60907@rochester.rr.com>
Chip wrote:
...
>>> system("mailx administrator@host.com", "Alert", "Server $_ is
down", ".", " ");
> Chip
> "Andrew Rich" <andrew.rich@bigpond.com> wrote in message
> news:pan.2003.05.20.06.18.04.557063@bigpond.com...
>
...
>> system ("mail -v -s HOST_DOWN email@address");
...
>>system ("mail -v -s $file email@address < $file ");
...
If you had turned on warnings, you would have seen that you attempted to
interpolate array @host or @address into your command string. You need
to escape the @ when it appears in a "" string.
Thus, the statement "the script never sent mail" is likely incorrect --
it just never sent mail to the intended recipient.
--
Bob Walton
------------------------------
Date: Wed, 21 May 2003 03:23:33 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: While loops and arrays
Message-Id: <ViCya.29039$Hy3.22650@nwrddc02.gnilink.net>
Jday wrote:
> I am writing a script to iterate through each element of one array and
> compare each element with another array to pick out the corresponding
> value. I have popluated my arrays by using while loops, as my data is
> contained in comma delimited format:
>
> while (<FILE>) {
> @data = split /,/;
> }
>
> My frustration is that I can't figure out how to keep and use the data
> in the array after the while loop has ended. For example, if I were
> to do this:
>
> while (<FILE>) {
> @data = split /,/;
> print "@data\n";
> }
>
> I get all the data in the array,
No, you don't. Or sort of. At any moment in time @data will contain all the
information from the _current line_ which you are currently processing. But
in each loop it will be overwritten with the information from the next line
and after the loop it will contain the information from the last line.
> whereas if I do this:
>
> while (<FILE>) {
> @data = split /,/;
> }
> print "@data\n";
>
> I get the last row of data in the array.
Actually it is exactly the same scenario. It's just that you don't print
@array for each and every line, therefore you don't observe the intermediate
content of @array.
> How can I "transfer" the
> data in the array from within the while loop so I can use that full
> array in another portion of the script?
If you want just all elements in one single array, thereby destroying the
previous structure of lines, then in each loop just append the new elements
from that line to the existing data. At the moment you are overwriting them:
@array = (@array, split /,/);
Of course the more perlish way to write this is to use push:
push @array, split/,/;
If you want to preserve the structure then you need an array of arrays. In
that case you may want to read up on references. A good starting point would
be "perldoc perlreftut"
jue
------------------------------
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 5016
***************************************