[29498] in Perl-Users-Digest
Perl-Users Digest, Issue: 742 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 10 16:09:41 2007
Date: Fri, 10 Aug 2007 13:09:07 -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, 10 Aug 2007 Volume: 11 Number: 742
Today's topics:
file info on XP <jpreston@general-steel.com>
File::Find problem? <dale.schmitz@offutt.af.mil>
Re: File::Find problem? <glex_no-spam@qwest-spam-no.invalid>
Re: File::Find problem? <dale.schmitz@offutt.af.mil>
Re: File::Find problem? <dale.schmitz@offutt.af.mil>
Re: File::Find problem? <rkb@i.frys.com>
Re: File::Find problem? <dale.schmitz@offutt.af.mil>
Re: Help: Newbie Question <wahab-mail@gmx.de>
Re: match and group across 2 lines <wahab-mail@gmx.de>
Need help writing a basic script print to text file <neilverling@gmail.com>
Re: Need help writing a basic script print to text file <glex_no-spam@qwest-spam-no.invalid>
Re: Need help writing a basic script print to text file <news@lawshouse.org>
Re: Out of memory in vec <paduille.4061.mumia.w+nospam@earthlink.net>
Perl On Apache <t051315@hotmail.com>
Re: Perl On Apache <wahab-mail@gmx.de>
Re: Perl On Apache (Jens Thoms Toerring)
share a variable from multiple process forked in a read <asuter@cisco.com>
Re: share a variable from multiple process forked in a <ts@dionic.net>
Re: share a variable from multiple process forked in a xhoster@gmail.com
Re: Using DBI, Bind with Update <jwcarlton@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 10 Aug 2007 14:26:41 -0500
From: "Jerry" <jpreston@general-steel.com>
Subject: file info on XP
Message-Id: <13bpeun4o0hhfb9@corp.supernews.com>
Hi!
Is there a way to find out who made the last change, user id, to a file and
if it is IP or local or remote?
Can it be done on Linuix from Perl?
Thanks,
Jerry
------------------------------
Date: Fri, 10 Aug 2007 19:06:51 -0000
From: Monty <dale.schmitz@offutt.af.mil>
Subject: File::Find problem?
Message-Id: <1186772811.571452.254610@d30g2000prg.googlegroups.com>
I'm using the File::Find module to search through a directory tree and
perform operations on files with a .hdr suffix for the file name. I
have a test environment set up and known defects in the files, but I
get an error I hadn't expected with the find() function. The set up
is like this:
use File::Find;
find (\&process_file,".");
sub process_file {
if (/\.hdr/) {
print "$File::Find::name\n";
open HDR_FILE, "<$File::Find::name" or die "Can't open file
for input: $!\n";
...etc.
It prints the correct file name, complete with relative path, but it
dies on the open statement every time. What am I doing wrong?
Thanks in advance.
------------------------------
Date: Fri, 10 Aug 2007 14:21:42 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: File::Find problem?
Message-Id: <46bcbac7$0$505$815e3792@news.qwest.net>
Monty wrote:
> I'm using the File::Find module to search through a directory tree and
> perform operations on files with a .hdr suffix for the file name. I
> have a test environment set up and known defects in the files, but I
> get an error I hadn't expected with the find() function. The set up
> is like this:
>
> use File::Find;
>
> find (\&process_file,".");
>
> sub process_file {
> if (/\.hdr/) {
Note: this only means that '.hdr' occurs in the name of the file. It
would match some.file.hdr.gif too.
> print "$File::Find::name\n";
print " is readable\n" if -r $File::Find::name;
print " does exist\n" if -e $File::Find::name;
> open HDR_FILE, "<$File::Find::name" or die "Can't open file
> for input: $!\n";
> ...etc.
>
> It prints the correct file name, complete with relative path, but it
> dies on the open statement every time. What am I doing wrong?
Well, what's the error?
What's a value of $File::Find::name?
Do you have read access to the file?
Is it a symlink to a file that doesn't exist?
------------------------------
Date: Fri, 10 Aug 2007 19:42:01 -0000
From: Monty <dale.schmitz@offutt.af.mil>
Subject: Re: File::Find problem?
Message-Id: <1186774921.944743.292060@g12g2000prg.googlegroups.com>
Ah, I left a few things out.
The error is as in the die statement: Can't open file for input. All
files in the test environment have permissions of 777 (that includes
the directories and sub-directories), so anyone should be able to
read, write, or execute them (although they're plain text files). On
top of that, I'm running this as root.
Also, I mistyped the 'if' statement some, it actually reads 'if (/\.hdr
$/)'. That part seems to work just fine.
I'm stumped, but thanks for taking a look at this.
Monty
------------------------------
Date: Fri, 10 Aug 2007 19:42:44 -0000
From: Monty <dale.schmitz@offutt.af.mil>
Subject: Re: File::Find problem?
Message-Id: <1186774964.054252.157240@j4g2000prf.googlegroups.com>
Oh yes, none of these files are symbolic links.
Monty
------------------------------
Date: Fri, 10 Aug 2007 13:00:33 -0700
From: Ron Bergin <rkb@i.frys.com>
Subject: Re: File::Find problem?
Message-Id: <1186776033.318839.279900@q4g2000prc.googlegroups.com>
On Aug 10, 12:42 pm, Monty <dale.schm...@offutt.af.mil> wrote:
> Ah, I left a few things out.
>
> The error is as in the die statement: Can't open file for input. All
What's the second half of the error message i.e., what's the value of
$! (the OS portion of the error)?
> files in the test environment have permissions of 777 (that includes
> the directories and sub-directories), so anyone should be able to
> read, write, or execute them (although they're plain text files). On
> top of that, I'm running this as root.
>
> Also, I mistyped the 'if' statement some, it actually reads 'if (/\.hdr
> $/)'. That part seems to work just fine.
>
> I'm stumped, but thanks for taking a look at this.
>
> Monty
------------------------------
Date: Fri, 10 Aug 2007 20:04:27 -0000
From: Monty <dale.schmitz@offutt.af.mil>
Subject: Re: File::Find problem?
Message-Id: <1186776267.381995.270470@q3g2000prf.googlegroups.com>
The O/S portion of the error is "No such file or directory".
The file exists where $File::Find::name says it is. I wonder if the
problem is in the relative pathing?
------------------------------
Date: Fri, 10 Aug 2007 20:56:46 +0200
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: Help: Newbie Question
Message-Id: <f9id3a$l9p$1@mlucom4.urz.uni-halle.de>
Amy Lee wrote:
> In our Bioinformatics Department, we need to convert some files into a
> suitable formation.
> The original formation is:
>> 16jh_0101.b1.abi Chromat File {descriptions......}
> ATCCGTACTGC............................................
This looks like a fairly standard fasta format,
which would look like:
12345678901234567890 . . . . . . . . . . .. . . . . . . . 60c
------------------------------------------------------------
1| > 16jh_0101.b1.abi Chromat File descriptions [\n]
2| ATCCGTACTGCATCCGTACTGCATCCGTACATCCGTACTGCATCCGTACTGCATCCGTAC[\n]
3| (more sequence until the next "\n>" record tag
> I hope that it can be this:
>> 16>jh_0101>ATCCGTACTGC............................................
>
> In one file, there are many template like above, so I need a script can
> solve the problem.
Which problem? To convert the fasta header
from "> 16jh_0101.b1.abi ... \nATCCG..."
to "> 16>jh_0101>ATCCG"
What exactly is the "problem" you are trying to solve?
Regards
M.
------------------------------
Date: Fri, 10 Aug 2007 17:30:52 +0200
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: match and group across 2 lines
Message-Id: <f9ibik$kob$1@mlucom4.urz.uni-halle.de>
ktlind@gmail.com wrote:
> I would like to group six numbers separated by commas into $1 thru $6.
> The problem is that four of the numbers are on the first line and two
> of the numbers are on the second line. Here is an example of those 2
> lines:
>
> SLN499 = LINE/994.455930,-49.320125,347.561019,994.456333 $
> ,-49.320486,347.560579
>
> How can I reach down one more line and get the other two numbers?
$_='
SLN499 = LINE/994.455930,-49.320125,347.561019,994.456333 $
,-49.320486,347.560579
';
my @sixnumbers = /(?<=[,\/])-?[\d\.]+/gs;
Regards
M.
------------------------------
Date: Fri, 10 Aug 2007 11:52:12 -0700
From: chewdon <neilverling@gmail.com>
Subject: Need help writing a basic script print to text file
Message-Id: <1186771932.131299.302860@e9g2000prf.googlegroups.com>
I am trying to write a cgi script that will print text to a txt file
with the name of the txt file being the date and time it was created.
I am new to this and the only script I have been able to write is
Hello World!. From what I have found on the internet I tried to write
this but of course it does not work. This is what I have written.
#!/usr/local/bin/perl
#sends user back to my home page
Location: "http://www.mywebsite.com/index.html
print "text file data"; >> textfile.txt
This seems like it should be a pretty simple script but I can not
figure it out. Can anybody please tell me how to create this script?
Thanks
------------------------------
Date: Fri, 10 Aug 2007 14:26:35 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Need help writing a basic script print to text file
Message-Id: <46bcbbec$0$10303$815e3792@news.qwest.net>
chewdon wrote:
> I am trying to write a cgi script that will print text to a txt file
> with the name of the txt file being the date and time it was created.
> I am new to this and the only script I have been able to write is
> Hello World!. From what I have found on the internet I tried to write
> this but of course it does not work. This is what I have written.
>
> #!/usr/local/bin/perl
>
> #sends user back to my home page
>
> Location: "http://www.mywebsite.com/index.html
>
> print "text file data"; >> textfile.txt
>
> This seems like it should be a pretty simple script but I can not
> figure it out. Can anybody please tell me how to create this script?
To learn how to open and write to a file, you can read your
local documentation that comes with perl:
perldoc -f open
There are a lot of documents online for CGI and perl. Typically
you'd use the CGI module:
http://search.cpan.org/~lds/CGI.pm-3.29/CGI.pm
------------------------------
Date: Fri, 10 Aug 2007 20:37:27 +0100
From: Henry Law <news@lawshouse.org>
Subject: Re: Need help writing a basic script print to text file
Message-Id: <1186774606.16679.0@proxy02.news.clara.net>
chewdon wrote:
> I am trying to write a cgi script that will print text to a txt file
> with the name of the txt file being the date and time it was created.
> I am new to this and the only script I have been able to write is
> Hello World!. From what I have found on the internet I tried to write
> this but of course it does not work. This is what I have written.
>
> #!/usr/local/bin/perl
>
> #sends user back to my home page
>
> Location: "http://www.mywebsite.com/index.html
>
> print "text file data"; >> textfile.txt
That's not what you're trying to run; it isn't syntactically correct
Perl, nor any other language with which I'm familiar. Many things will
make it harder for people to help you: that's one of them. Always copy
and paste in your real code.
That said I'm not even sure what you want to do. Some Perl statements
which will write text to a named file would include
open THATFILE, '>', "namedfile" or die "Open failed:$!";
print THATFILE "stuff\n";
But instead of "namedfile" you want something like "yyyy-mm-dd-hh-mm-ss"
and to get that you need the "localtime" and "time" commands; look them
up in your Perl help and have a go at writing the code.
Write a small program that works out your file's name, based on the date
and time, and opens it for writing. Don't worry with CGI for now. When
you've got the thing working, or if you can't and need help, post again.
--
Henry Law Manchester, England
------------------------------
Date: Fri, 10 Aug 2007 13:22:09 -0500
From: "Mumia W." <paduille.4061.mumia.w+nospam@earthlink.net>
Subject: Re: Out of memory in vec
Message-Id: <13bpcdtctl4d624@corp.supernews.com>
On 08/10/2007 11:26 AM, Ted Zlatanov wrote:
> On 10 Aug 2007 07:35:48 GMT anno4000@radom.zrz.tu-berlin.de wrote:
>
> a> Mumia W. <paduille.4061.mumia.w+nospam@earthlink.net> wrote in comp.lang.perl.misc:
> a> [...]
>
>>> I then went to writing the transposition program. A gigabyte (1e6 rows ×
>>> 1000 columns) is a lot of memory, so I wanted to avoid forcing each item
>>> to take an entire byte, and since A, C, T and G are only four distinct
>>> values, an entire byte is not needed to encode them, so I opted to use
>>> four bits for each item and the vec() function:
>
> a> Why four? You only need two bits to encode four bases.
>
> "--" was also allowed as data besides a pair of letters, so you have
>
> [ACGT][ACGT] = 4 bits (which is what Mumia means by "item", I think)
> plus "--" as a value = 5 bits
>
> Ted
I started programming before Jie submitted any sample data, so I thought
of [ACGT] as an item. I would've liked to use three bits, but vec() does
not seem to allow that.
This program
----------------------
my $buffer = '';
vec($buffer, 0, 3) = 7;
----------------------
produces "Illegal number of bits in vec at ...", so I'm stuck with using
four bits.
Now that Jie has give us some data, I can find a way to get [ACGT][ACGT]
into a single four-bit group.
------------------------------
Date: Fri, 10 Aug 2007 18:13:58 GMT
From: Louis <t051315@hotmail.com>
Subject: Perl On Apache
Message-Id: <GV1vi.72956$Io4.34431@edtnps89>
I have a web application that at some point I would like to run a perl
script on the web server to update an excel spreadsheet on the server.
My problem is..Apache seems to be running it as a cgi script(?). It
displays the script on the browser!
Is there a way to do this? What is needed to configure Apache to run it
as a "normal" script?
Thank you.
------------------------------
Date: Fri, 10 Aug 2007 20:37:42 +0200
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: Perl On Apache
Message-Id: <f9ibvg$ktp$1@mlucom4.urz.uni-halle.de>
Louis wrote:
> I have a web application that at some point I would like to run a perl
> script on the web server to update an excel spreadsheet on the server.
>
> My problem is: Apache seems to be running it as a cgi script(?). It
> displays the script on the browser!
>
> Is there a way to do this? What is needed to configure Apache to run it
> as a "normal" script?
If you could be so kind and provide some
details regarding ...
- your operating system and version,
- your apache version and install location,
- your Perl version and install location,
... I'm sure everybody in this news group, which
is among the most frendliest and professional
groups in the usenet world, would start to
present a matching solution fast.
Regards
M.
------------------------------
Date: 10 Aug 2007 18:52:01 GMT
From: jt@toerring.de (Jens Thoms Toerring)
Subject: Re: Perl On Apache
Message-Id: <5i3qehF3n1aq7U1@mid.uni-berlin.de>
Louis <t051315@hotmail.com> wrote:
> I have a web application that at some point I would like to run a perl
> script on the web server to update an excel spreadsheet on the server.
> My problem is..Apache seems to be running it as a cgi script(?). It
> displays the script on the browser!
The output (to stdout) of a script run by Apache goes into the
page that gets returned by the server. That's what allowing a
web server to run scripts at all is meant for.
> Is there a way to do this? What is needed to configure Apache to run it
> as a "normal" script?
If you want to update a file when the URL associated with your
script is requested by a client then in the script open the
file you want to update and write to that file instead of
stdout. Or write a wrapper script that gets invoked instead
on a request and in this wrapper script run the first script
with its stdout redirected to the file you want to update.
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
------------------------------
Date: Fri, 10 Aug 2007 11:09:25 -0700
From: "Asim Suter" <asuter@cisco.com>
Subject: share a variable from multiple process forked in a read-write manner
Message-Id: <1186769366.18681@sj-nntpcache-3.cisco.com>
What is the easiest way to share a variable from multiple process forked in
a read-write manner.
The children have their own symbol tables and thus they dont affect parent's
What options do I have to modify one siggle variable from parents as well as
children. and the locking reqired.
Perl 5.6
Thanks!
------------------------------
Date: Fri, 10 Aug 2007 20:09:50 +0100
From: Tim Southerwood <ts@dionic.net>
Subject: Re: share a variable from multiple process forked in a read-write manner
Message-Id: <46bcb7e7$0$641$5a6aecb4@news.aaisp.net.uk>
Asim Suter coughed up some electrons that declared:
>
>
> What is the easiest way to share a variable from multiple process forked
> in a read-write manner.
> The children have their own symbol tables and thus they dont affect
> parent's
>
> What options do I have to modify one siggle variable from parents as well
> as children. and the locking reqired.
>
> Perl 5.6
>
> Thanks!
Hi
IPC::Shareable I reckon - it's not that efficient, but it is quite high
level (arbitrary data structure complexity and locking support). Based on
standard shared memory with some perl magic to make it friendly.
If however, your variable is a simple counter, then it might be easier to
use a semaphore as you may be using it in the intended manner anyway - I
wouldn't know without further info.
HTH
Tim
------------------------------
Date: 10 Aug 2007 19:10:06 GMT
From: xhoster@gmail.com
Subject: Re: share a variable from multiple process forked in a read-write manner
Message-Id: <20070810151008.287$c6@newsreader.com>
"Asim Suter" <asuter@cisco.com> wrote:
> What is the easiest way to share a variable from multiple process forked
> in a read-write manner.
> The children have their own symbol tables and thus they dont affect
> parent's
>
> What options do I have to modify one siggle variable from parents as well
> as children. and the locking reqired.
I find that the easiest way is usually to redesign the code so that this is
not necessary. Barring that, there is forks::shared, but to use that you
need to start your forked processes using the same semantics you would use
if they were threads rather than forks, which can be annoying.
You can also use IPC::Sharable or IPC::ShareLite, but I generally find them
to be more trouble than they are worth.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Fri, 10 Aug 2007 12:34:46 -0700
From: Jason <jwcarlton@gmail.com>
Subject: Re: Using DBI, Bind with Update
Message-Id: <1186774486.905725.122030@e9g2000prf.googlegroups.com>
> Gah. How do you read something like that? Why not simply
> $rows[0] = "1000|Test|20070809|Jason|jwcarl...@gmail.com|Test
> Comment";
Nah, I was just trying to slap something together to make it easier
for you guys to read. The actual array is coming from a
fetchrow_arrayref, but I didn't want you to have to sort through a lot
of unnecessary code.
> 90% correct. It's not the name of the field that matters, or how many
> arguments are in the SET or WHERE clauses. It's the number of
> placeholders (ie, question marks) in the query. If you used a real
> value for the third one:
> UPDATE subjects SET lastmodified=?, firstname=?, shortdesc="foobar"
> WHERE id=?
> then you would bind parameters 1 for lastmodified, 2 for firstname,
> and 3 for id.
>
> > I'm also guessing that $sth_subjects->execute($lastmodified,
> > $firstuser, $shortdesc, $key) wouldn't be the same?
>
> Assuming you meant $id here instead of $key,
I did! That's what I get for posting at 6am.
> no, that's not correct.
> They would be exactly the same. From the DBI docs:
> If any arguments are given, then execute will effectively call
> "bind_param" for each value before executing the statement. Values
> bound in this way are usually treated as SQL_VARCHAR types unless the
> driver can determine the correct type (which is rare), or unless
> bind_param (or bind_param_inout) has already been used to specify the
> type.
>
> Calling execute with a list of parameters is a shortcut for having to
> call bind_param however many times.
>
> Paul Lalli
Exactly what I needed to know! Thanks, Paul.
Jason
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 V11 Issue 742
**************************************