[31748] in Perl-Users-Digest
Perl-Users Digest, Issue: 3011 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 30 21:09:31 2010
Date: Wed, 30 Jun 2010 18:09:15 -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 Wed, 30 Jun 2010 Volume: 11 Number: 3011
Today's topics:
Re: Expect: line endings? <zebeej@gmail.com>
Need to capture Log of each thread --Parallel::ForkMana <divyajacobpulickal@gmail.com>
Re: P5NCI Library for AIX <smallpond@juno.com>
Parsing file names with spaces <jegan473@comcast.net>
Re: Parsing file names with spaces <uri@StemSystems.com>
Re: Parsing file names with spaces <jegan473@comcast.net>
Re: Parsing file names with spaces <rvtol+usenet@xs4all.nl>
Re: Parsing file names with spaces <jak@isp2dial.com>
Re: Parsing file names with spaces <jegan473@comcast.net>
Re: Parsing file names with spaces <jegan473@comcast.net>
Re: Parsing file names with spaces <uri@StemSystems.com>
Re: Parsing file names with spaces <uri@StemSystems.com>
Re: Parsing file names with spaces <jak@isp2dial.com>
Re: Parsing file names with spaces <jak@isp2dial.com>
Re: Parsing file names with spaces <ben@morrow.me.uk>
Re: Parsing file names with spaces <uri@StemSystems.com>
Path to another server <jruffino@gailborden.info>
Re: Path to another server <ben@morrow.me.uk>
reading from a file into an array in perl <soorajspadmanabhan@gmail.com>
Re: reading from a file into an array in perl <justin.0911@purestblue.com>
Re: reading from a file into an array in perl <4ux6as402@sneakemail.com>
Re: reading from a file into an array in perl <jurgenex@hotmail.com>
Re: reading from a file into an array in perl <4ux6as402@sneakemail.com>
Re: reading from a file into an array in perl <tadmc@seesig.invalid>
Trouble installing DBD-Oracle-1.23 on Cygwin <davidmichaelkarr@gmail.com>
Re: Trouble installing DBD-Oracle-1.23 on Cygwin <ben@morrow.me.uk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 30 Jun 2010 22:05:32 +0000 (UTC)
From: Zebee Johnstone <zebeej@gmail.com>
Subject: Re: Expect: line endings?
Message-Id: <slrni2nftb.bi4.zebeej@gmail.com>
In comp.lang.perl.misc on Wed, 30 Jun 2010 09:04:13 +0200
Josef Moellers <josef.moellers@ts.fujitsu.com> wrote:
> Am 30.6.2010 schrub Zebee Johnstone:
>
>> I"m using Expect.pm to log into an HP ILO (management card for HP
>> Prliant servers) but I'm getting odd results. I'm not sure if it's
>> because I'm using Expect incorrectly or if the HP is in some odd way
>> incompatible.
>
> At times, Expect can be very confusing and tiresome.
So I'm discovering!
>
>> The problem seems to be that the second exp->expect statement either
>> doesn't run or isn't sent. Or else the /n it ends with isn't sent.
>
> You don't send linefeeds ("\n"), you send carriage-returns ("\r")!
hurrah! yes that's it, thank you. (although linefeed works for the
password, I suppose the ssh authentication is handled by a different
beastie)
Which also explains some things in the Net::SSH::Expect perldoc that
was confusing me.
zebee
------------------------------
Date: Wed, 30 Jun 2010 05:06:55 -0700 (PDT)
From: divyajacob <divyajacobpulickal@gmail.com>
Subject: Need to capture Log of each thread --Parallel::ForkManager;
Message-Id: <66528534-4ad5-4445-ba99-83cc5af16290@y2g2000pra.googlegroups.com>
Hi All,
In one of my application,i am cloning a process to 4 different
threads,using Parallel::ForkManager module.
Can anyone tell me how can i track each thread ,and is it possible to
create separate log files for each thread.
My Program is something like this....
my $child_proc_mgr=new Parallel::ForkManager($maxprocesses);
for(my $i = $from; $i <=$to; $i++)
{ my $sourcefname=$tmpfname;
my $targetfname=$targetdir;
$sourcefname .= "/".sprintf('%03s',$i);
$targetfname .= "/".sprintf('%03s',$i).".gz";
next if (-e "$targetfname");
next if (-e "$sourcefname.sorting");
next if (-e "$sourcefname.sorted");
$child_proc_mgr->start and next;
my ($src,$sorting,$sorted);
die "\nFile $sourcefname does not exists" if (! -e
"$sourcefname");
open ($src,"< $sourcefname") || die "\nCannot open
$sourcefname for reading $!";
open ($sorting,"> $sourcefname.sorting") ||
die "\nCannot open temp file $sourcefname.sorting for
writing $!";
close $src;
close $sorting;
print "\nSorting file $sourcefname";
sort_file("$sourcefname.sorting","$sourcefname.sorted");
my $sortstatus= $? >> 8;
if ($sortstatus != 0)
{ unlink $targetfname;
die "\n $sourcefname.sorting -- Sort was failed $!";
}
else
{
print "Sorting successful for file
$sourcefname.sorting to $sourcefname.sorted";
}
$child_proc_mgr->finish;
}
$child_proc_mgr->wait_all_children;
Right now proper logging is not happening,many of the print statements
i have given are not getting captured for each thred.
Any pointers to this will be highly appreciated.
Thanks,
Divya
------------------------------
Date: Wed, 30 Jun 2010 09:14:51 -0400
From: Steve C <smallpond@juno.com>
Subject: Re: P5NCI Library for AIX
Message-Id: <i0fg0j$ns$1@news.eternal-september.org>
Sachin Patil wrote:
> I downloaded P5NCI-0.30 from CPAN and tried to build it.
> I am doing this on AIX platform.
>
> After extracting and cd to P5NCI-0.30, I tried
> perl Makefile.PL
> and it is working fine.
>
> bash-3.00# perl Makefile.PL
> # running Build.PL
> Creating new 'MYMETA.yml' with configuration results
> Creating new 'Build' script for 'P5NCI' version '0.31'
> Unknown 'build_class', defaulting to 'Module::Build'
>
> After that i run make but it is giving below error message.
> bash-3.00# make
> /usr/local/bin/perl Build --makefile_env_macros 1
> gcc -maix32 -I/usr/local/lib/perl5/5.10.0/aix/CORE -c -D_ALL_SOURCE -
> D_ANSI_C_SOURCE -D_POSIX_SOURCE -DUSE_NATIVE_DLOPEN -fno-strict-
> aliasing -pipe -D_LARGE_FILES -O -o src/nci_test.o src/nci_test.c
> Use of uninitialized value $baseext in substitution (s///) at /usr/
> local/lib/perl5/5.10.0/ExtUtils/CBuilder/Platform/aix.pm line 17.
> Use of uninitialized value $args{"dl_file"} in substitution (s///) at /
> usr/local/lib/perl5/5.10.0/ExtUtils/CBuilder/Base.pm line 194.
> Insufficient information specified to Mksymlists at /usr/local/lib/
> perl5/5.10.0/ExtUtils/CBuilder/Base.pm line 197
> make: 1254-004 The error code from the last command is 9.
>
> Does any one use this library on AIX platform?
Looks like abandonware to me.
There are open bugs and no bug fix activity.
The code apparently doesn't build on OSX either.
------------------------------
Date: Wed, 30 Jun 2010 22:58:50 GMT
From: James Egan <jegan473@comcast.net>
Subject: Parsing file names with spaces
Message-Id: <K_PWn.524032$rq1.477029@en-nntp-02.dc1.easynews.com>
Assuming an array named @myfiles contained three elements like:
-rwxrwxrwx 1 777 22000 2971201 Jan 24 18:17 file1.zip
-rwxrwxrwx 1 777 22000 2969941 Jan 28 18:10 file2 onespace.zip
-rwxrwxrwx 1 777 22000 2969941 Jan 29 13:28 file3 two spaces.zip
I want to extract just the file which contain spaces to work with like:
file1.zip
file2 onespace.zip
file3 two spaces.zip
How can I extract the file names which have spaces?
I've been trying unsuccessfully with the glob function:
foreach my $f (@myfiles) {
print join "\n",glob("*")'
}
-Thanks
------------------------------
Date: Wed, 30 Jun 2010 19:09:43 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: Parsing file names with spaces
Message-Id: <878w5wgls8.fsf@quad.sysarch.com>
>>>>> "JE" == James Egan <jegan473@comcast.net> writes:
JE> Assuming an array named @myfiles contained three elements like:
JE> -rwxrwxrwx 1 777 22000 2971201 Jan 24 18:17 file1.zip
JE> -rwxrwxrwx 1 777 22000 2969941 Jan 28 18:10 file2 onespace.zip
JE> -rwxrwxrwx 1 777 22000 2969941 Jan 29 13:28 file3 two spaces.zip
are you saying your array has those lines from ls?
JE> I want to extract just the file which contain spaces to work with like:
JE> file1.zip
JE> file2 onespace.zip
JE> file3 two spaces.zip
JE> How can I extract the file names which have spaces?
JE> I've been trying unsuccessfully with the glob function:
JE> foreach my $f (@myfiles) {
JE> print join "\n",glob("*")'
JE> }
but you said you already have an array with those lines in it. why would
a glob work when globs work on directories, not arrays or lines?
you need a regex to grab the file part of the lines. but why did you
even have them in ls format? just read the dir directly with glob or
opendir/readdir and get them that way. in fact readdir will be better
as it doesn't have to care about spaces in the file names..
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Wed, 30 Jun 2010 23:18:18 GMT
From: James Egan <jegan473@comcast.net>
Subject: Re: Parsing file names with spaces
Message-Id: <_gQWn.610620$Hq1.188342@en-nntp-04.dc1.easynews.com>
> but you said you already have an array with those lines in it. why would
> a glob work when globs work on directories, not arrays or lines?
>
I'm not reading a directory with the ls command. I don't want to
complicate matters with where the long listing of file names comes
from. Suffice it to say it's a long listing, and the file names
have spaces, and I need to extract the file names.
-Thanks
------------------------------
Date: Thu, 01 Jul 2010 01:41:33 +0200
From: "Dr.Ruud" <rvtol+usenet@xs4all.nl>
Subject: Re: Parsing file names with spaces
Message-Id: <4c2bd62e$0$22942$e4fe514c@news.xs4all.nl>
James Egan wrote:
> Assuming an array named @myfiles contained three elements like:
>
> -rwxrwxrwx 1 777 22000 2971201 Jan 24 18:17 file1.zip
> -rwxrwxrwx 1 777 22000 2969941 Jan 28 18:10 file2 onespace.zip
> -rwxrwxrwx 1 777 22000 2969941 Jan 29 13:28 file3 two spaces.zip
>
>
> I want to extract just the file which contain spaces to work with like:
>
> file1.zip
> file2 onespace.zip
> file3 two spaces.zip
echo "-rwxrwxrwx 1 777 22000 2969941 Jan 29 13:28 file3 two
spaces.zip" |perl -wnle '
print substr($_, 50);
'
file3 two spaces.zip
--
Ruud
------------------------------
Date: Wed, 30 Jun 2010 23:49:55 +0000
From: John Kelly <jak@isp2dial.com>
Subject: Re: Parsing file names with spaces
Message-Id: <2gln26h1af0o4lpfqh5u0kaieur62fsjvt@4ax.com>
On Wed, 30 Jun 2010 23:18:18 GMT, James Egan <jegan473@comcast.net>
wrote:
>I'm not reading a directory with the ls command. I don't want to
>complicate matters with where the long listing of file names comes
>from. Suffice it to say it's a long listing, and the file names
>have spaces, and I need to extract the file names.
CODE:
#!/usr/bin/perl
open DATA, 'data';
@files = <DATA>;
foreach (@files) {
print;
}
contents of 'data' FILE:
file1.zip
file2 onespace.zip
file3 two spaces.zip
OUTPUT:
file1.zip
file2 onespace.zip
file3 two spaces.zip
The spaces don't matter, the newline characters in the 'data' file are
delimiters. Can you exlpain what you want to do, and why spaces are a
problem?
--
Web mail, POP3, and SMTP
http://www.beewyz.com/freeaccounts.php
------------------------------
Date: Wed, 30 Jun 2010 23:53:13 GMT
From: James Egan <jegan473@comcast.net>
Subject: Re: Parsing file names with spaces
Message-Id: <JNQWn.491708$Vq1.143617@en-nntp-03.dc1.easynews.com>
On Wed, 30 Jun 2010 23:49:55 +0000, John Kelly wrote:
> On Wed, 30 Jun 2010 23:18:18 GMT, James Egan <jegan473@comcast.net>
> wrote:
>
>>I'm not reading a directory with the ls command. I don't want to
>>complicate matters with where the long listing of file names comes from.
>> Suffice it to say it's a long listing, and the file names have spaces,
>>and I need to extract the file names.
>
> CODE:
>
> #!/usr/bin/perl
>
> open DATA, 'data';
> @files = <DATA>;
> foreach (@files) {
> print;
> }
>
>
> contents of 'data' FILE:
>
> file1.zip
> file2 onespace.zip
> file3 two spaces.zip
>
>
> OUTPUT:
>
> file1.zip
> file2 onespace.zip
> file3 two spaces.zip
>
>
> The spaces don't matter, the newline characters in the 'data' file are
> delimiters. Can you exlpain what you want to do, and why spaces are a
> problem?
I want to take these three array elements and extract the file names which
include spaces:
-rwxrwxrwx 1 777 22000 2971201 Jan 24 18:17 file1.zip
-rwxrwxrwx 1 777 22000 2969941 Jan 28 18:10 file2 onespace.zip
-rwxrwxrwx 1 777 22000 2969941 Jan 29 13:28 file3 two spaces.zip
------------------------------
Date: Wed, 30 Jun 2010 23:56:03 GMT
From: James Egan <jegan473@comcast.net>
Subject: Re: Parsing file names with spaces
Message-Id: <nQQWn.491709$Vq1.20151@en-nntp-03.dc1.easynews.com>
On Thu, 01 Jul 2010 01:41:33 +0200, Dr.Ruud wrote:
> James Egan wrote:
>
>> Assuming an array named @myfiles contained three elements like:
>>
>> -rwxrwxrwx 1 777 22000 2971201 Jan 24 18:17 file1.zip -rwxrwxrwx
>> 1 777 22000 2969941 Jan 28 18:10 file2 onespace.zip -rwxrwxrwx 1
>> 777 22000 2969941 Jan 29 13:28 file3 two spaces.zip
>>
>>
>> I want to extract just the file which contain spaces to work with like:
>>
>> file1.zip
>> file2 onespace.zip
>> file3 two spaces.zip
>
> echo "-rwxrwxrwx 1 777 22000 2969941 Jan 29 13:28 file3 two
> spaces.zip" |perl -wnle '
>
> print substr($_, 50);
> '
> file3 two spaces.zip
I should have mentioned that the dates, sizes, names, of the files, might be
different, so they won't always start at position 50.
-Thanks
------------------------------
Date: Wed, 30 Jun 2010 20:03:54 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: Parsing file names with spaces
Message-Id: <8739w4gj9x.fsf@quad.sysarch.com>
>>>>> "JK" == John Kelly <jak@isp2dial.com> writes:
JK> CODE:
JK> #!/usr/bin/perl
JK> open DATA, 'data';
always check open for success or failure
JK> @files = <DATA>;
JK> foreach (@files) {
JK> print;
JK> }
and how is that is different than?
print <DATA> ;
also don't use DATA for a file handle, it is defaulted to the __DATA__
section of the main file. also use lexical file handles. and to add one
more, that can be all done with:
use File::Slurp ;
print read_file( 'data' ) ;
JK> contents of 'data' FILE:
JK> file1.zip
JK> file2 onespace.zip
JK> file3 two spaces.zip
and what did that show? he is not reading or getting a file with just
file names in them. they are full ls listings. of course you will get
pissed off at my question but try to answer it!
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Wed, 30 Jun 2010 20:05:43 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: Parsing file names with spaces
Message-Id: <87y6dwf4mg.fsf@quad.sysarch.com>
>>>>> "JE" == James Egan <jegan473@comcast.net> writes:
JE> I should have mentioned that the dates, sizes, names, of the
JE> files, might be different, so they won't always start at position
JE> 50.
so use a regex! it isn't hard to write one to parse out the file from ls
output. and you can always assume the earlier part ofls is fixed
width. the date is always fixed width. only the size and file name can
change in width. so skip to the size, then match a number and space and
the rest is the file name so match that and grab it. easy regex.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Thu, 01 Jul 2010 00:22:21 +0000
From: John Kelly <jak@isp2dial.com>
Subject: Re: Parsing file names with spaces
Message-Id: <grnn26hhhb84o8mqu50codjnktp9llqfh6@4ax.com>
On Wed, 30 Jun 2010 23:53:13 GMT, James Egan <jegan473@comcast.net>
wrote:
>I want to take these three array elements and extract the file names which
>include spaces:
>
>-rwxrwxrwx 1 777 22000 2971201 Jan 24 18:17 file1.zip
>-rwxrwxrwx 1 777 22000 2969941 Jan 28 18:10 file2 onespace.zip
>-rwxrwxrwx 1 777 22000 2969941 Jan 29 13:28 file3 two spaces.zip
This works for me:
>#!/usr/bin/perl
>
>open DATA, 'data';
>@files = <DATA>;
>foreach (@files) {
>
> my $file;
> (undef, undef, undef, undef, undef, undef, undef, undef, $file) = split ' ', $_, 9;
> $file =~ / / and print "$file";
>
>}
--
Web mail, POP3, and SMTP
http://www.beewyz.com/freeaccounts.php
------------------------------
Date: Thu, 01 Jul 2010 00:30:56 +0000
From: John Kelly <jak@isp2dial.com>
Subject: Re: Parsing file names with spaces
Message-Id: <23on26do5jh511utihq9mjje6ia6fevq99@4ax.com>
On Wed, 30 Jun 2010 20:03:54 -0400, "Uri Guttman" <uri@StemSystems.com>
wrote:
>and what did that show? he is not reading or getting a file with just
>file names in them. they are full ls listings. of course you will get
>pissed off at my question but try to answer it!
Well he said:
>I'm not reading a directory with the ls command.
So it sounded like his data only included the file names. But in a
later post he says it does include the directory info. My post prompted
him to explain further, without treating him like a fool.
Try to relax. It's only Perl. Or does Perl make you tense.
--
Web mail, POP3, and SMTP
http://www.beewyz.com/freeaccounts.php
------------------------------
Date: Thu, 1 Jul 2010 01:38:15 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Parsing file names with spaces
Message-Id: <nk4tf7-unr.ln1@osiris.mauzo.dyndns.org>
Quoth James Egan <jegan473@comcast.net>:
> Assuming an array named @myfiles contained three elements like:
>
> -rwxrwxrwx 1 777 22000 2971201 Jan 24 18:17 file1.zip
> -rwxrwxrwx 1 777 22000 2969941 Jan 28 18:10 file2 onespace.zip
> -rwxrwxrwx 1 777 22000 2969941 Jan 29 13:28 file3 two spaces.zip
>
> I want to extract just the file which contain spaces to work with like:
>
> file1.zip
> file2 onespace.zip
> file3 two spaces.zip
>
>
> How can I extract the file names which have spaces?
ls -l output intentionally uses fixed-width columns, except for the
filename. So
for (@myfiles) {
print substr($_, 50), "\n";
}
You could also try File::Listing from the LWP distribution.
> I've been trying unsuccessfully with the glob function:
>
> foreach my $f (@myfiles) {
> print join "\n",glob("*")'
> }
Why on Earth would you have expected that to work? Apart from anything
else, you aren't even using $f...
Ben
------------------------------
Date: Wed, 30 Jun 2010 21:08:27 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: Parsing file names with spaces
Message-Id: <877hlgf1pw.fsf@quad.sysarch.com>
>>>>> "JK" == John Kelly <jak@isp2dial.com> writes:
JK> On Wed, 30 Jun 2010 20:03:54 -0400, "Uri Guttman" <uri@StemSystems.com>
JK> wrote:
>> and what did that show? he is not reading or getting a file with just
>> file names in them. they are full ls listings. of course you will get
>> pissed off at my question but try to answer it!
JK> Well he said:
>> I'm not reading a directory with the ls command.
JK> So it sounded like his data only included the file names. But in a
JK> later post he says it does include the directory info. My post prompted
JK> him to explain further, without treating him like a fool.
JK> Try to relax. It's only Perl. Or does Perl make you tense.
no, just bad and/or useless perl makes me react. you seem to be a font
of it. i will correct your posted code whenever i feel like it. note
that others didn't even come close to your way off response to the same
ambiguous OP. and you still never answered my question, what was your
code trying to even show? reading and printing a file of line
(regardless of their being file names) doesn't do anything close to what
the OP wanted. so your analytical skills need to be honed as well. best
you sit back and not respond to most posts here until you have seen what
others have to say. that is generally good advice on usenet.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Wed, 30 Jun 2010 17:16:25 -0700 (PDT)
From: Joe <jruffino@gailborden.info>
Subject: Path to another server
Message-Id: <163e8077-2893-48dc-9df4-f88d291208a3@q12g2000yqj.googlegroups.com>
We are switching from one server to another for our PERL Scripts, and
so far everything is working, but I am having problems with on program
which works on the old server but not the new one.
The problem I have is creating a file in a directory on another
server. I use "\\\\gailbapps\\cybraryn\\TDmenu\\A-Cyb_Stats\\" as my
path to the serever, and to create it, I use open (TOT_TXT,
'>{servername and filename}').
But when I try to write print TOT_TXT "Hello\n";, it does not work.
Can anyone help? I print out the path and put it in Windows Explorer
and it goes right there, so I do not know why it cannot be accessed.
The code is below:
<code>
$relative_addy = "\\\\gailbapps\\cybraryn\\TDmenu\\A-Cyb_Stats\\";
$month_year = $date_month . "_" . $date_year . ".txt";
$tot_file = $relative_addy . $month_year;
open (TOT_TXT, '>$tot_file') || die "$tot_file open failed: $!";
print "File: $tot_file<p>";
print TOT_TXT "Hello\n";
close(TOT_TXT);
</code>
------------------------------
Date: Thu, 1 Jul 2010 01:47:39 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Path to another server
Message-Id: <b65tf7-unr.ln1@osiris.mauzo.dyndns.org>
Quoth Joe <jruffino@gailborden.info>:
> We are switching from one server to another for our PERL Scripts, and
> so far everything is working, but I am having problems with on program
> which works on the old server but not the new one.
>
> The problem I have is creating a file in a directory on another
> server. I use "\\\\gailbapps\\cybraryn\\TDmenu\\A-Cyb_Stats\\" as my
> path to the serever, and to create it, I use open (TOT_TXT,
> '>{servername and filename}').
>
> But when I try to write print TOT_TXT "Hello\n";, it does not work.
In what way does it not work?
> Can anyone help? I print out the path and put it in Windows Explorer
> and it goes right there, so I do not know why it cannot be accessed.
>
> The code is below:
> <code>
> $relative_addy = "\\\\gailbapps\\cybraryn\\TDmenu\\A-Cyb_Stats\\";
Are you using 'strict'? If not, why not? If you are, where is this
variable declared?
Use forward slashes. With a few exceptions (notably paths passed to
cmd.exe and paths passed to Win32::Process) they work perfectly well on
Win32 perl.
my $relative_addy = "//gailbapps/cybraryn/TDmenu/A-Cyb_Stats/";
> $month_year = $date_month . "_" . $date_year . ".txt";
>
> $tot_file = $relative_addy . $month_year;
my $tot_file = "$relative_addy$date_month\_$date_year.txt";
> open (TOT_TXT, '>$tot_file') || die "$tot_file open failed: $!";
Presumably this line succeeds? It does not, however, do what you think
it does: single quotes don't interpolate, so you are trying to open a
file called (literally) '$tot_file' in the current directory. I didn't
think Win32 allowed filenames to have '$' in, but I may be
misremembering.
You should be using lexical filehandles and 3-arg open:
open(my $TOT_TXT, ">", $tot_file)
|| die "$tot_file open failed: $!";
> print "File: $tot_file<p>";
>
> print TOT_TXT "Hello\n";
>
> close(TOT_TXT);
You also need to check the return value of close, to make sure the data
was actually written successfully. (Checking print is neither necessary
nor sufficient.)
close($TOT_TXT) || die "writing $tot_file failed: $!";
Ben
------------------------------
Date: Wed, 30 Jun 2010 06:19:28 -0700 (PDT)
From: Sooraj S <soorajspadmanabhan@gmail.com>
Subject: reading from a file into an array in perl
Message-Id: <6a19c099-9a9b-432f-b55d-3cc8658c3110@x18g2000pro.googlegroups.com>
Hi,
I want to read all the data from a file into an array. But if there
is any "#" character in the file it should be replaced with "&"
character. How to store "$_" into an array?
This is my code:
my @tmp_arr;
open(IN,"<./ip_file");
while(<IN>)
{
if(/#/)
{
s/#/&/g;
}
-------------- //add ur code here
}
close(IN);
foreach(@tmp_arr)
{
print "$_";
}
------------------------------
Date: Wed, 30 Jun 2010 13:51:30 -0000
From: Justin C <justin.0911@purestblue.com>
Subject: Re: reading from a file into an array in perl
Message-Id: <1b0f.4c2b4be2.6a7e7@zem>
On 2010-06-30, Sooraj S <soorajspadmanabhan@gmail.com> wrote:
> Hi,
>
> I want to read all the data from a file into an array. But if there
> is any "#" character in the file it should be replaced with "&"
> character. How to store "$_" into an array?
>
> This is my code:
> my @tmp_arr;
> open(IN,"<./ip_file");
> while(<IN>)
> {
> if(/#/)
> {
> s/#/&/g;
> }
> -------------- //add ur code here
> }
> close(IN);
> foreach(@tmp_arr)
> {
> print "$_";
> }
I think you need <URL:http://oreilly.com/catalog/9780596001322>
Also, that 'if' is redundant. Just s/#/&/g without the 'if' around it,
if there isn't a '#' then there is no match and therefore no substitu-
tion.
There are a few other things that, around these parts at least, are
considered bad practice (and who am I to argue?), but, considering the
nature of the problem you have, I don't think it beneficial to point
them all out, but to suggest you read the book mentioned above.
Justin.
--
Justin C, by the sea.
------------------------------
Date: Wed, 30 Jun 2010 07:31:24 -0700 (PDT)
From: =?ISO-8859-1?Q?Peter_Valdemar_M=F8rch?= <4ux6as402@sneakemail.com>
Subject: Re: reading from a file into an array in perl
Message-Id: <5fa93c71-5190-48a9-a1c3-53bd23141dd5@z10g2000yqb.googlegroups.com>
On Jun 30, 3:19=A0pm, Sooraj S <soorajspadmanab...@gmail.com> wrote:
> =A0 =A0 =A0 =A0 -------------- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0//add ur code here}
Is this what you're looking for?
push @tmp_arr, $_;
Peter
------------------------------
Date: Wed, 30 Jun 2010 08:00:38 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: reading from a file into an array in perl
Message-Id: <hfmm269hvim2rr74ptfdg1204m5osfviap@4ax.com>
Sooraj S <soorajspadmanabhan@gmail.com> wrote:
>I want to read all the data from a file into an array.
@arr = <$F>;
Or use File::Slurp
>But if there
>is any "#" character in the file it should be replaced with "&"
>character.
AFAIR # isn't special in REs, so a simple
s/#/&/g;
should do. Or
tr/#/&/;
>How to store "$_" into an array?
You assign the value of $_ to whatever position in the array you want
$arr[123] = $_;
>This is my code:
>my @tmp_arr;
>open(IN,"<./ip_file");
You should use lexical file handles.
You should use the three-argument for of open()
You should always check for success of open()
open ($IN, '<', './ip_file') or die "Cannot open ./ip_file: $!";
>while(<IN>)
>{
> if(/#/)
> {
> s/#/&/g;
There is no reason to hide the s/// inside of an if(). If there is no #
then the s/// just won't do anything anyway.
> }
> -------------- //add ur code here
>}
>close(IN);
>foreach(@tmp_arr)
Where is this array coming from? You never declared it (are you using
warnings and strictures? You absolutely should!!!) and never defined it,
therefore it is empty and this loop will never be executed.
>{
> print "$_";
Please read "perldoc -q quoting":
What's wrong with always quoting "$vars"?
jue
------------------------------
Date: Wed, 30 Jun 2010 09:15:59 -0700 (PDT)
From: =?ISO-8859-1?Q?Peter_Valdemar_M=F8rch?= <4ux6as402@sneakemail.com>
Subject: Re: reading from a file into an array in perl
Message-Id: <8d9032bb-a621-4811-940f-b34175ac1fa3@r27g2000yqb.googlegroups.com>
On Jun 30, 5:00=A0pm, J rgen Exner <jurge...@hotmail.com> wrote:
> Where is this array coming from? You never declared it (are you using
> warnings and strictures? You absolutely should!!!) and never defined it,
> therefore it is empty and this loop will never be executed.
Uhm, didn't he in fact declare it explicitly?:
Sooraj S wrote:
> This is my code:
> my @tmp_arr;
> bla bla
Peter
------------------------------
Date: Wed, 30 Jun 2010 12:03:00 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: reading from a file into an array in perl
Message-Id: <slrni2mtu1.83s.tadmc@tadbox.sbcglobal.net>
Sooraj S <soorajspadmanabhan@gmail.com> wrote:
> I want to read all the data from a file into an array. But if there
> is any "#" character in the file it should be replaced with "&"
> character. How to store "$_" into an array?
If you want all the lines in an array, then read all of the lines
into an array in the first place.
--------------------------
#!/usr/bin/perl
use warnings;
use strict;
local @ARGV = './ip_file';
my @tmp_arr = <>;
foreach (@tmp_arr) {
tr/#/&/;
}
foreach (@tmp_arr) {
print;
}
--------------------------
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.
------------------------------
Date: Wed, 30 Jun 2010 11:33:24 -0700 (PDT)
From: "david.karr" <davidmichaelkarr@gmail.com>
Subject: Trouble installing DBD-Oracle-1.23 on Cygwin
Message-Id: <c1ce7706-4213-48e7-a7da-e17997322dfb@b35g2000yqi.googlegroups.com>
I'm on Cygwin 1.5.25, Perl 5.10, and I'm trying to install DBI-1.608
and DBD-Oracle-1.23. The DBI installation went ok, but I'm having
trouble with the DBD portion. I don't have Oracle installed locally
(I mostly only use SQuirreL for connecting to my database). I tried
following the instructions in the DBI and DBD READMEs.
I installed the instantclient basic, sdk, and even sqlplus in c:/
oracle/instantclient_11_2 (the DBD README refers to "11_1", but I
would assume nothing is checking for that name).
The DBD README doesn't mention setting ORACLE_HOME, but it appears I
have to set it to the "instantclient" directory.
I set my ORACLE_DSN and ORACLE_USERID to refer to the database my
first script will be connecting to.
Supposedly it helps if I specify the client API version on the "perl"
command line, but I'm not certain exactly what that number would be.
I tried using both "perl Makefile.PL -V 10.2.0.4" (database version)
and "perl Makefile.PL -V 11.1.0.7" (driver version), but my results
are the same.
The "perl" and "make" lines appeared to complete without serious
complaint, but when I ran "make test", I got the following:
-----------------------
/usr/bin/perl.exe "-MExtUtils::Command::MM" "-e" "test_harness(0,
'blib/lib', 'blib/arch')" t/*.t
t/01base..................# Test loading DBI, DBD::Oracle and version
t/01base..................1/6
# Failed test 'install_driver'
# at t/01base.t line 22.
Failed to load Oracle extension and/or shared libraries:
install_driver(Oracle) failed: Can't load '/c/frameworks/DBD-
Oracle-1.23/blib/arch/auto/DBD/Oracle/Oracle.dll' for module
DBD::Oracle: No such file or directory at /usr/lib/perl5/5.10/i686-
cygwin/DynaLoader.pm line 201.
at (eval 6) line 3
Compilation failed in require at (eval 6) line 3.
-----------------
That file DOES exist, and it's permissions are 755.
Any ideas? Is there a better place to ask about this?
------------------------------
Date: Wed, 30 Jun 2010 22:55:30 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Trouble installing DBD-Oracle-1.23 on Cygwin
Message-Id: <i3rsf7-t4q.ln1@osiris.mauzo.dyndns.org>
Quoth "david.karr" <davidmichaelkarr@gmail.com>:
> I'm on Cygwin 1.5.25, Perl 5.10, and I'm trying to install DBI-1.608
> and DBD-Oracle-1.23. The DBI installation went ok, but I'm having
> trouble with the DBD portion. I don't have Oracle installed locally
> (I mostly only use SQuirreL for connecting to my database). I tried
> following the instructions in the DBI and DBD READMEs.
>
> I installed the instantclient basic, sdk, and even sqlplus in c:/
> oracle/instantclient_11_2 (the DBD README refers to "11_1", but I
> would assume nothing is checking for that name).
Firstly, you may have better luck with Win32 perl. I presume your Oracle
client libs are Win32, not Cygwin, so trying to link to them from Cygwin
may be causing trouble. Alternatively, if you can find a distribution of
the Oracle client libs for Cygwin, you could try that.
> The DBD README doesn't mention setting ORACLE_HOME, but it appears I
> have to set it to the "instantclient" directory.
>
> I set my ORACLE_DSN and ORACLE_USERID to refer to the database my
> first script will be connecting to.
>
> Supposedly it helps if I specify the client API version on the "perl"
> command line, but I'm not certain exactly what that number would be.
> I tried using both "perl Makefile.PL -V 10.2.0.4" (database version)
> and "perl Makefile.PL -V 11.1.0.7" (driver version), but my results
> are the same.
I would expect it to want the version of you Oracle client libs. The
version of the database server is irrelevant, as long as client and
server are compatible.
> The "perl" and "make" lines appeared to complete without serious
> complaint, but when I ran "make test", I got the following:
>
> -----------------------
> /usr/bin/perl.exe "-MExtUtils::Command::MM" "-e" "test_harness(0,
> 'blib/lib', 'blib/arch')" t/*.t
> t/01base..................# Test loading DBI, DBD::Oracle and version
> t/01base..................1/6
> # Failed test 'install_driver'
> # at t/01base.t line 22.
> Failed to load Oracle extension and/or shared libraries:
> install_driver(Oracle) failed: Can't load '/c/frameworks/DBD-
> Oracle-1.23/blib/arch/auto/DBD/Oracle/Oracle.dll' for module
> DBD::Oracle: No such file or directory at /usr/lib/perl5/5.10/i686-
> cygwin/DynaLoader.pm line 201.
> at (eval 6) line 3
> Compilation failed in require at (eval 6) line 3.
> -----------------
>
> That file DOES exist, and it's permissions are 755.
OK. The problem here is that it can't find some *other* dll needed by
Oracle.dll, probably the Orable libs. Get depends.exe from
http://www.dependencywalker.com/ and see what libs it needs, and if it's
finding them. You may need to copy a whole lot of the Oracle libs into
your Cygwin /bin directory, assuming they still work from there.
> Any ideas? Is there a better place to ask about this?
Since this is a rather Cygwin-specific problem, you may have more luck
on a Cygwin mailing list.
Ben
------------------------------
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:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#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 V11 Issue 3011
***************************************