[22391] in Perl-Users-Digest
Perl-Users Digest, Issue: 4612 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Feb 23 18:05:34 2003
Date: Sun, 23 Feb 2003 15:05:06 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 23 Feb 2003 Volume: 10 Number: 4612
Today's topics:
Re: compiling perlcc generated c code with gcc <goldbb2@earthlink.net>
Re: Creating a variable from 3 other variables (descrip <PleaseDontThrowSpam@Me.com>
extract string from another string <pdhze@yahoo.co>
Re: extract string from another string <krahnj@acm.org>
hashes and lists <dan@no-spam.sghms.ac.uk>
Re: hashes and lists <graham.drabble@lineone.net>
Re: hashes and lists <krahnj@acm.org>
Re: hashes and lists <dan@no-spam.sghms.ac.uk>
Re: hashes and lists <dan@no-spam.sghms.ac.uk>
Re: How do I get path to .java scripts (Sherman)
Re: Just wanted to share this technique (and hear some <krahnj@acm.org>
Just wanted to share this technique (and hear some opin <bik.mido@tiscalinet.it>
Re: map two lists <johannes.fuernkranz@t-online.de>
Re: map two lists <johannes.fuernkranz@t-online.de>
Newbie request for script review <asu1@c-o-r-n-e-l-l.edu>
On Windows: how to drag&drop files onto a perl script f <ivec@myrealbox.com>
Re: Problem installing Perl dbd::mysql in Windows XP. P <randy@theoryx5.uwinnipeg.ca>
Re: sorting multidimensional arrays on one subkey <jd142@hotmail.com>
Re: Switch order of sprintf conversions <goldbb2@earthlink.net>
Re: Switch order of sprintf conversions <noreply@gunnar.cc>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 23 Feb 2003 13:16:33 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: compiling perlcc generated c code with gcc
Message-Id: <3E591001.48EDECA5@earthlink.net>
stig wrote:
>
> Benjamin Goldberg wrote:
>
> > stig wrote:
> > [snip]
> >> as gcc begins to parse the c file it generates 4-5 lines of
> >> warnings per line c code, and ends in error
> >>
> >> this is how the errors and warnings begin
> >> myprogram.c:1:20: EXTERN.h: No such file or directory
> >> myprogram.c:2:18: perl.h: No such file or directory
> >> myprogram.c:3:18: XSUB.h: No such file or directory
> >
> > You need to have the perl source installed on your machine to be
> > able to compile the output of perlcc... that is where those headers
> > are.
>
> hi again. it seems like the sources solved some of the problems.
> an object file is now created, however then gcc complains again.
>
> myprogram.o: In function `perl_init_aaaa':
> myprogram.c:3278: undefined reference to `Perl_Gthr_key_ptr'
>
> and so on for other function, spits out a couple of hundred rows
>
> any further hints?
Is the perl source you got for the same version of perl that you're
running?
If you are running perl5.6.1, and the perlcc which comes with it, but
you've downloaded the sources of a different version, then of course
you're going to have problems.
--
$;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
$__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print
------------------------------
Date: Sun, 23 Feb 2003 21:04:07 -0000
From: "Mikey" <PleaseDontThrowSpam@Me.com>
Subject: Re: Creating a variable from 3 other variables (description of initial errors)
Message-Id: <b3bct9$kqq$1@wisteria.csv.warwick.ac.uk>
"Jürgen Exner" <jurgenex@hotmail.com> wrote in message
news:AY56a.4890$ES3.653@nwrddc04.gnilink.net...
> Mikey wrote:
> > "Martien Verbruggen" <mgjv@tradingpost.com.au> wrote in message
> > news:slrnb5g2fl.2fm.mgjv@martien.heliotrope.home...
> >> You forgot to answer the question posed: Which error do you get when
> >> using "$year$month$day"?
> > Code used:
> > my $date = $year$month$day;
>
> This is not the same code as you showed us in your first posting:
>
> >>>>If I try the following, I will get errors:
> >>>> my $date = "$year$month$day";
>
> The code you showed us in your first posting works fine. That's why
everyone
> was rather mystified about why you would get an error message at all and
> insisted on seeing that error message.
> Can you see how is essential it is to copy(!) and paste the exact,
actual(!)
> code and not to retype it?
>
> > Errors given:
> >
> > Scalar found where operator expected at league line 94, near
> > "$year$month$day"
> > (Missing operator before $month?)
> > Hope you find these errors interesting\confusing!
>
> Enlighting and clarifying would be a more accurate term. If you would have
> shown us those messages earlier then probably we would have guessed that
you
> are not showing us the real code.
> Thanks for sending everyone on a fool's errand.
>
> jue
>
A mistake, I'm sorry.
Mikey
------------------------------
Date: Sun, 23 Feb 2003 22:35:07 GMT
From: piet <pdhze@yahoo.co>
Subject: extract string from another string
Message-Id: <Usenet.pemtljpi@localhost>
$teststring = 'stuff 650 N other stuff'
another example of string 'stuff stuff stuff stuff 90 N'
What would I do to extract 650 N and 90 N from the string?
650 N is an example: it can be from 111 A to 999 Z
90 N is an example: it can be from 10 A to 99 N
They are not on a specific place in the string.
I know how to check if they are in the string, but I don't now how to
extract them. So I need 650 N and 90 N stored in a variable or an array
This is what I already have:
if ($teststring =~ /\d\d\d [a-zA-Z]|\d\d [a-zA-Z]/) {
print $teststring;
}
Thanks for your help
piet
------------------------------
Date: Sun, 23 Feb 2003 22:50:02 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: extract string from another string
Message-Id: <3E59500C.D77036A4@acm.org>
piet wrote:
>
> $teststring = 'stuff 650 N other stuff'
> another example of string 'stuff stuff stuff stuff 90 N'
>
> What would I do to extract 650 N and 90 N from the string?
>
> 650 N is an example: it can be from 111 A to 999 Z
> 90 N is an example: it can be from 10 A to 99 N
> They are not on a specific place in the string.
>
> I know how to check if they are in the string, but I don't now how to
> extract them. So I need 650 N and 90 N stored in a variable or an array
>
> This is what I already have:
> if ($teststring =~ /\d\d\d [a-zA-Z]|\d\d [a-zA-Z]/) {
> print $teststring;
> }
my ($extract) = $teststring =~ /\b(\d{2,3} [a-zA-Z])\b/;
John
--
use Perl;
program
fulfillment
------------------------------
Date: Sun, 23 Feb 2003 16:51:44 +0000
From: Daniel Bird <dan@no-spam.sghms.ac.uk>
Subject: hashes and lists
Message-Id: <3E58FC20.6070105@no-spam.sghms.ac.uk>
Dear all,
I am a perl newbie and am trying to get a hash that looks like this:
Hello 5
World 7
Again 2
Which can have a variable number of rows, in to a list which requires
the format of:
@data = (["Hello","World","Again"],[5,7,2]);
(Which can have a variable number of rows based on the hash)
Now since the hash can be of variable length I'm guessing I need to push
the values in to the array list inside a loop of the hash like so:
foreach $word ( sort keys %index ){
push (@data, ["$word"],[$frequency{$word}]};
}
but this doesn't work as I expect, and I know it's wrong but for the
life of me I cannot figure out how I would do it. Can anyone help me out
with some code to do the above?
For information I am trying to use the GD::Graph::pie module to create a
pretty pie chart for the frequency of words in a file.
TIA
Dan
------------------------------
Date: Sun, 23 Feb 2003 17:15:28 GMT
From: Graham Drabble <graham.drabble@lineone.net>
Subject: Re: hashes and lists
Message-Id: <Xns932BAF8EDE458grahamdrabblelineone@ID-77355.user.dfncis.de>
On 23 Feb 2003 Daniel Bird <dan@no-spam.sghms.ac.uk> wrote in
news:3E58FC20.6070105@no-spam.sghms.ac.uk:
> I am a perl newbie and am trying to get a hash that looks like
> this:
>
> Hello 5
> World 7
> Again 2
>
> Which can have a variable number of rows, in to a list which
> requires the format of:
>
> @data = (["Hello","World","Again"],[5,7,2]);
> (Which can have a variable number of rows based on the hash)
use strict;
use warnings;
use diagnostics;
my %hash = qw(Hello 5 World 7 Again 2);
my @array = ([keys %hash],[values %hash]);
foreach my $element (@array){
print "$element\n";
foreach (@$element){
print "\t$_\n";
}
}
--
Graham Drabble
If you're interested in what goes on in other groups or want to find
an interesting group to read then check news.groups.reviews for what
others have to say or contribute a review for others to read.
------------------------------
Date: Sun, 23 Feb 2003 18:43:53 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: hashes and lists
Message-Id: <3E59165C.549CB1E7@acm.org>
Daniel Bird wrote:
>
> I am a perl newbie and am trying to get a hash that looks like this:
>
> Hello 5
> World 7
> Again 2
>
> Which can have a variable number of rows, in to a list which requires
> the format of:
>
> @data = (["Hello","World","Again"],[5,7,2]);
> (Which can have a variable number of rows based on the hash)
>
> Now since the hash can be of variable length I'm guessing I need to push
> the values in to the array list inside a loop of the hash like so:
>
> foreach $word ( sort keys %index ){
> push (@data, ["$word"],[$frequency{$word}]};
> }
for my $word ( sort keys %index ){
push @{$data[0]}, $word;
push @{$data[1]}, $index{$word};
}
John
--
use Perl;
program
fulfillment
------------------------------
Date: Sun, 23 Feb 2003 18:49:49 +0000
From: Daniel Bird <dan@no-spam.sghms.ac.uk>
Subject: Re: hashes and lists
Message-Id: <3E5917CD.90703@no-spam.sghms.ac.uk>
Graham Drabble wrote:
> On 23 Feb 2003 Daniel Bird <dan@no-spam.sghms.ac.uk> wrote in
> news:3E58FC20.6070105@no-spam.sghms.ac.uk:
>
>
>>I am a perl newbie and am trying to get a hash that looks like
>>this:
>>
>>Hello 5
>>World 7
>>Again 2
>>
>>Which can have a variable number of rows, in to a list which
>>requires the format of:
>>
>>@data = (["Hello","World","Again"],[5,7,2]);
>>(Which can have a variable number of rows based on the hash)
>
>
> use strict;
> use warnings;
> use diagnostics;
>
>
> my %hash = qw(Hello 5 World 7 Again 2);
>
> my @array = ([keys %hash],[values %hash]);
>
> foreach my $element (@array){
> print "$element\n";
> foreach (@$element){
> print "\t$_\n";
> }
> }
>
>
Thank you, works perfectly.
------------------------------
Date: Sun, 23 Feb 2003 18:50:09 +0000
From: Daniel Bird <dan@no-spam.sghms.ac.uk>
Subject: Re: hashes and lists
Message-Id: <3E5917E1.4040801@no-spam.sghms.ac.uk>
John W. Krahn wrote:
> Daniel Bird wrote:
>
>>I am a perl newbie and am trying to get a hash that looks like this:
>>
>>Hello 5
>>World 7
>>Again 2
>>
>>Which can have a variable number of rows, in to a list which requires
>>the format of:
>>
>>@data = (["Hello","World","Again"],[5,7,2]);
>>(Which can have a variable number of rows based on the hash)
>>
>>Now since the hash can be of variable length I'm guessing I need to push
>> the values in to the array list inside a loop of the hash like so:
>>
>>foreach $word ( sort keys %index ){
>> push (@data, ["$word"],[$frequency{$word}]};
>>}
>
>
> for my $word ( sort keys %index ){
> push @{$data[0]}, $word;
> push @{$data[1]}, $index{$word};
> }
>
>
> John
As does this...
Thanks again
Dan
------------------------------
Date: 23 Feb 2003 09:29:00 -0800
From: swillden@hotmail.com (Sherman)
Subject: Re: How do I get path to .java scripts
Message-Id: <aef0a2ff.0302230928.5aef2b84@posting.google.com>
Thanks, Brian;
I have been trying to determine how to do this at work but I don't
really have the time for learning perl at work. I just bought the Perl
CD with the seven books, am now downloading the Perl.com zip file, and
I will work through it.
Sherman
Brian McCauley <nobull@mail.com> wrote in message news:<u9n0kpcwq1.fsf@wcl-l.bham.ac.uk>...
> sherman.willden@hp.com (Sherman Willden) writes:
>
> > Subject: How do I get path to .java scripts
>
> Please put the subject of your post in the Subject of your post. If
> in doubt try this simple test. Imagine you could have been bothered
> to have done a search before you posted. Next imagine you found a
> thread with your subject line. Would you have been able to recognise
> it as the same subject?
>
> You Perl question has nothing to do with Java scripts. Your Perl
> question has to do with finding files with a given suffix. Surely you
> can see that the solution would be identical for finding .zip files!
>
> Your question has nothing to do with getting the paths. You've
> already done that bit. Your question has to do with having got the
> paths putting them into an array.
>
> I think your real problem is in your ability to partition yout
> problem.
>
> > I will use jikes to build the .class files from the .java files and I
> > want to get the path to each .java file. I do the below but I get the
> > list output to stdout:
> >
> > find(sub { /\.java/ && print "$File::Find::name\n" }, $path);
>
> BTW you probably meant /\.java$/ not /\.java/
>
> > If I do:
> >
> > my @files = find(sub { /\.java/ && print "$File::Find::name\n" },
> > $path);
> >
> > I just get the 0 return code.
>
> That is to be expected - see the documentation of find().
>
> > How can I get a hash or array of files with the file path?
>
> That question is pretty much self answering.
>
> The question is how do you get the paths into an array or hash rather
> then printing then to stdout?
>
> The answer therefore is that rather than printing the paths to stdout
> you should put them into an array or hash.
>
> Could you really not have worked that out for yourself?
>
> Almost certainly your problem is that you tried to look at the problem
> as a whole rather than breaking it into parts. If you'd broken your
> problem down you'd have realised your question was really "how do I
> append something to an array?". This is covered in even the most
> basic Perl tutorials so if you really don't know the answer you should
> go and work through a couple of very basic tutorials.
>
> <FISH>
>
> Replace:
>
> print "$File::Find::name\n"
>
> with a statement that puts the contents $File::Find::name into an
> array or hash. Something like:
>
> push @some_array, $File::Find::name;
>
> </FISH>
>
> > Do I want a hash or array?
>
> Dunno, you tell me. You seem to be claiming you do. (Is this a trick question?)
------------------------------
Date: Sun, 23 Feb 2003 21:33:53 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Just wanted to share this technique (and hear some opinions about it)
Message-Id: <3E593E33.8690AB1C@acm.org>
Michele Dondi wrote:
>
> I had some lists of files (pics, actually, FWIM) that I had prepared
> some time ago, but in the meanwhile the files have been moved to
> (numbered) subdirs containing approximately 1000 files each.
>
> The files have absolutely unique names (though a small number of them
> have been deleted), so I wanted to update the lists with the correct
> locations.
>
> Instead of just checking for all the possible subdirs and breaking on
> the first "matching" one, since I *knew* that it was most probable for
> each entry to "match" against the same subdir as the previous one, I
> used the following script as a quick solution:
>
> #!/usr/bin/perl -i.bak -lw
> use strict;
>
> my @pre=map sprintf('../../pics/%02d/', $_), 3..10;
>
> my ($cnt,$f);
> while ($f=<>) {
> next if ++$cnt == @pre;
The value of $cnt starts out at 0, then you increment here to 1, then at
the end of the loop you set it to 0 again so at this point the value of
$cnt will ALWAYS be 1 so you can lose the $cnt variable and write it
like this:
next if 1 == @pre;
> chomp $f;
> $_ = $pre[0] . $f;
> -e and print
> or push(@pre, shift @pre), redo;
Unless print() returns "false" (the current filehandle ARGV has been
closed, etc.) the "push(@pre, shift @pre), redo;" part of this statement
will not execute. Perhaps you meant to write it like this?
if ( -e ) {
print;
}
else {
push @pre, shift @pre;
redo;
}
> }
> continue { $cnt=0 }
> __END__
What it looks like you are trying to do could be written as:
#!/usr/bin/perl -i.bak -lw
use strict;
my @cnt = 3 .. 10;
my @pre = map sprintf( '../../pics/%02d/', $_ ), @cnt;
while ( my $f = <> ) {
chomp $f;
-e and print and last for map "$pre[$_]$f", @cnt;
}
__END__
John
--
use Perl;
program
fulfillment
------------------------------
Date: Sun, 23 Feb 2003 20:26:17 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Just wanted to share this technique (and hear some opinions about it)
Message-Id: <d96i5vsbvu01vhvqs5qa6i22tev11q21i2@4ax.com>
I had some lists of files (pics, actually, FWIM) that I had prepared
some time ago, but in the meanwhile the files have been moved to
(numbered) subdirs containing approximately 1000 files each.
The files have absolutely unique names (though a small number of them
have been deleted), so I wanted to update the lists with the correct
locations.
Instead of just checking for all the possible subdirs and breaking on
the first "matching" one, since I *knew* that it was most probable for
each entry to "match" against the same subdir as the previous one, I
used the following script as a quick solution:
#!/usr/bin/perl -i.bak -lw
use strict;
my @pre=map sprintf('../../pics/%02d/', $_), 3..10;
my ($cnt,$f);
while ($f=<>) {
next if ++$cnt == @pre;
chomp $f;
$_ = $pre[0] . $f;
-e and print
or push(@pre, shift @pre), redo;
}
continue { $cnt=0 }
__END__
In the past, under roughly similar circumstances, I've used a similar
technique to match some entries against a set of REs (a FAQ, IIRC),
but that time the probability that the same RE matched for consecutive
entries was in some cases considerably lower and the overhead
introduced by "rotating" the array (or REs) slowed down the script, so
I had to use a more subtle variation of the same idea. In the end I
judged (rudimentary benchmark by means of with 'time' utility) that
the gain in speed was not worth the time spent devising the code...
However I'd like to hear some opinions about these issues.
Michele
--
>It's because the universe was programmed in C++.
No, no, it was programmed in Forth. See Genesis 1:12:
"And the earth brought Forth ..."
- Robert Israel on sci.math, thread "Why numbers?"
------------------------------
Date: Sun, 23 Feb 2003 22:23:48 +0100
From: =?ISO-8859-1?Q?Johannes_F=FCrnkranz?= <johannes.fuernkranz@t-online.de>
Subject: Re: map two lists
Message-Id: <b3be56$gd3$05$1@news.t-online.com>
This thread has generated a lot more responses than I had expected.
Thanks to all repliers!
Benjamin Goldberg wrote:
>
> It can get a little shorter and more efficient:
>
> @result = map function($list1[$_], $list2[$_]), 0 .. $#list1;
>
> Changing the block to an expression eliminates a scope-enter and
> scope-exit.
Right.
> You can improve the efficiency a bit more at the cost of aesthetics:
>
> my $i = 0; @result = map function($_, $list2[$i++]), @list1;
Interesting. This is so ugly, I would have never considered that this
could actually be efficient. :-) Thanks!
Juffi
------------------------------
Date: Sun, 23 Feb 2003 23:29:52 +0100
From: =?ISO-8859-1?Q?Johannes_F=FCrnkranz?= <johannes.fuernkranz@t-online.de>
Subject: Re: map two lists
Message-Id: <b3bi16$r44$02$1@news.t-online.com>
Benjamin Goldberg wrote:
>
> You can improve the efficiency a bit more at the cost of aesthetics:
>
> my $i = 0; @result = map function($_, $list2[$i++]), @list1;
While looking at this, I realized that I have one of my two lists in @_.
So in this case, I can even get rid of the $i:
@result = map function($_,shift), @list1;
This should be fast *and* pretty. :-)
Thanks again!
Juffi
------------------------------
Date: 23 Feb 2003 20:09:51 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Newbie request for script review
Message-Id: <Xns932B9A3D7245Dasu1cornelledu@132.236.56.8>
Hello:
I am trying to familiarize myself with Perl. To that end, I decided to
concoct a simple cgi script to browse images in a directory on web site.
The script is intended to be called in the following manner:
http://somehost.com/cgi-bin/photobrowser.pl?album/spring
As I have virtually no experience, and no feel for Perl, I would
appreciate your comments about this script before I "improve" it.
BEGIN: photobrowser.pl
#!C:/Perl/bin/perl.exe -w
# photobrowser
# Display links (optionally with thumbnails) to
# images in a directory
use strict;
use HTML::Template;
# Clean up the location specified in the request by
# removing all relative paths
my $location = shift;
if($location =~ s/(\.\.\/)|(\.\.)//g) {
print "Content: text/plain\n\nInvalid location specified in
request.";
} else {
# Configuration Variables
my $wwwroot = '';
my $script_location = '/cgi-bin/photobrowser.pl';
my $htdocs_path = 'C:/Program Files/Apache Group/Apache2/htdocs';
my $template_path =
'C:/Program Files/Apache Group/Apache2/templates';
my $template_file = 'photobrowser.tmpl.html';
my $photo_path = "$htdocs_path/$location";
my $thumb_dir_name = 'thumb';
my $template =
HTML::Template->new(filename => "$template_path/$template_file");
# Provide some information during development
$template->param(HTDOCS => $htdocs_path);
$template->param(LOCATION => $location);
$template->param(PHOTO_PATH => $photo_path);
opendir(PHOTO_DIR, $photo_path);
# For the line below, I get the warning
# [Sun Feb 23 15:03:18 2003] [error] [client 127.0.0.1]
# Use of uninitialized value in concatenation (.) or string at
# C:/Program Files/Apache Group/Apache2/cgi-bin/photobrowser.pl
my @files = grep { !/^\.+/ && /$\.jpg/ } readdir(PHOTO_DIR);
closedir PHOTO_DIR;
my @loop_data = ();
foreach my $file (@files) {
my %iter_data;
$iter_data{IMGFILE} = $file;
$iter_data{IMGURL} = "$wwwroot/$location/$file";
if(-e "$photo_path/$thumb_dir_name/$file") {
$iter_data{THUMBURL} = "$wwwroot/$location/thumb/$file";
} else {
$iter_data{THUMBURL} = "";
}
push(@loop_data, \%iter_data);
}
$template->param(IMGLIST => \@loop_data);
print "Content-Type: text/html\n\n", $template->output;
}
### END
BEGIN: Template file to use with HTML::Template
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<title>Photo Browser - <TMPL_VAR LOCATION></title>
</head>
<body>
<table border="0" bgcolor="#dadada" cellspacing="2" cellpadding="4"
>
<tr>
<td bgcolor="white" align="right">HTDOCS: </td>
<td bgcolor="white"><TMPL_VAR HTDOCS></td>
</tr>
<tr>
<td bgcolor="white" align="right">LOCATION: </td>
<td bgcolor="white"><TMPL_VAR LOCATION></td>
</tr>
<tr>
<td bgcolor="white" align="right">PHOTO_PATH: </td>
<td bgcolor="white"><TMPL_VAR PHOTO_PATH></td>
</tr>
</table>
<TMPL_LOOP IMGLIST>
<a href="<TMPL_VAR IMGURL>"><TMPL_IF THUMBURL><img
src="<TMPL_VAR THUMBURL>"
title="<TMPL_VAR IMGFILE>"><TMPL_ELSE><TMPL_VAR IMGFILE></TMPL_IF>
</a>
</TMPL_LOOP>
</body>
</html>
--
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov
------------------------------
Date: Sun, 23 Feb 2003 22:00:28 +0100
From: "Ivan Vecerina" <ivec@myrealbox.com>
Subject: On Windows: how to drag&drop files onto a perl script file ?
Message-Id: <3e593515$1@news.swissonline.ch>
Many of my perl script take files or folders as parameters, to process
their contents somehow.
For some users, the most convenient way to apply some processing to a
set of chosen file is to drag-and-drop them onto a program file.
Unfortunately, I didn't manage to configure Windows so that it would
allow me to drop files onto a .pl script file icon.
Does anyone know how to do this ?
Any Registry setting that does the trick ?
What I am doing so far is keep a .bat next to each of my .pl script,
with a DOS command such as:
@perl -w "%~dpn0.pl" %*
It just seems silly do double-up each file this way.
Any better option on Windows ?
Thanks in advance for any ideas or comments,
Ivan
--
Ivan Vecerina, Dr. med. <> http://www.post1.com/~ivec
Soft Dev Manger, XiTact <> http://www.xitact.com
------------------------------
Date: Sun, 23 Feb 2003 16:28:56 -0600
From: "Randy Kobes" <randy@theoryx5.uwinnipeg.ca>
Subject: Re: Problem installing Perl dbd::mysql in Windows XP. Please help!
Message-Id: <FWb6a.48600$7_.217200@news1.mts.net>
"CM" <eleos111@hotmail.com> wrote in message
news:3m5h5vgt2s97mkdfd9di2n2a09839mtqh3@4ax.com...
> I have tried to install Perl (ActivePerl 5.8.0 and 5.6.1) in Windows
> XP with IIS and mysql 4. I also added DBI module with the command
> install DBI
> and added dbd-mysql with command:
> install
> ftp://ftp.de.uu.net/pub/CPAN/authors/id/JWIED/DBD-mysql-1.2212.x86.ppd
>
> But when I try to run a specific script I always get the follow error:
> [Sat Feb 22 23:49:01 2003]
> C:\Inetpub\wwwroot\cgi\phpBBusers2nukeusers.pl: install_driver(MySQL)
> failed: Can't load 'C:/Perl/site/lib/auto/DBD/mysql/mysql.dll' for
> module DBD::mysql: load_file:The specified module could not be found
> at C:/Perl/lib/DynaLoader.pm line 206.
For one thing, ActivePerl 6xx and 8xx are binary incompatible,
so this package might be expected to work only with the Perl
version it was compiled with. But also, it might be that this
DBD-mysql package was compiled against mysql-3.xx, rather
than version 4 (I've seen reports that the two aren't binary
compatible in this context). Do you have mysql-3 also installed
that you could try?
best regards,
randy kobes
------------------------------
Date: 23 Feb 2003 10:09:48 -0600
From: Bob <jd142@hotmail.com>
Subject: Re: sorting multidimensional arrays on one subkey
Message-Id: <9bch5vom9bp491kpqf5g4vmq044kap90h1@4ax.com>
Thanks for the replies. For some reason, I thought it would be more
complicated than that and I just hadn't gotten around to trying the
sort to see if it would work.
On Sun, 23 Feb 2003 01:06:52 GMT, "John W. Krahn" <krahnj@acm.org>
wrote:
>> so that if I do this
>>
>> $mylength = @arr;
>> $q = 0;
>> while ($q < $mylength)
>> {
>> print "$arr[$q][0]\n";
>> }
>
>Why would you do that? Since you don't change the value of $q that will
>always print $arr[0][0].
I forgot to put q++; in the code. Without it, it loops forever.
>
>> Eventually what I want to do is keep the top N arrays and throw the
>> rest away, which I can do once I order them.
>
>$N = 10;
>
>@keep = ( sort { ... } @arr )[ 0 .. $N - 1 ];
You can also just do:
$#arr = 10;
to keep the top ten elements. At least, that seems to work for me.
Thanks again,
Bob
------------------------------
Date: Sun, 23 Feb 2003 13:11:18 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Switch order of sprintf conversions
Message-Id: <3E590EC6.10332827@earthlink.net>
Gunnar Hjalmarsson wrote:
>
> After having considered all the valuable suggestions and comments in
> this thread, I added this function to the working copy of my program:
>
> sub sprintfmt {
> my $string = shift;
> return sprintf $string, @_ if $] >= 5.008;
> my $argref = \@_;
> my (%refidx, @args);
> for (0..$#$argref) { $refidx{$_} = \$argref->[$_] }
> while ($string =~ s/(%)(\d+)\$([\w\.])/$1$3/) {
> push @args, ${delete $refidx{$2-1}} if $refidx{$2-1};
> }
> for (0..$#$argref) { push @args, ${$refidx{$_}} if $refidx{$_} }
> return sprintf $string, @args;
> }
> sprintfmt ('There Is %2$s Than %s Way To Do It', 'One', 'More');
>
> The above returns: "There Is More Than One Way To Do It".
>
> The function aims to simulate the parameter reordering ability that
> has been added to the sprintf() function in perl v5.8.0. Your comments
> would be appreciated.
According to the perl5.8.0 documentation for sprintf:
printf '%3$d %d %1$d', 1, 2, 3; # prints "3 1 1"
Your function, given those arguments, produces "3 1 2"... oops.
Perhaps something like the following will do:
sub sprintfmt {
my $fmt = shift;
my ($i, @p) = 0;
$fmt =~ s[%(?:(\d+)\$)?([\d.]*[%a-z])]{
push @p, $1 ? ($1-1) : $i++;
'%' . $2;
}ige;
sprintf $fmt, @_[@p];
}
__END__
This correctly produces "3 1 1" when given ('%3$d %d %1$d', 1, 2, 3).
I'm not saying that you code is "wrong", since afaik, there isn't any
standard specification anywhere describing how '1$' positional
specifiers *should* work, but I think that it would be most convenient
if your function (and hence your data) is compatible with perl5.8.0's
handling of the issue. That way, when you upgrade to 5.8, you can
discard your sprintfmt function and use perl's builtin sprintf without
needing to change your data.
--
$;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
$__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print
------------------------------
Date: Sun, 23 Feb 2003 23:05:52 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Switch order of sprintf conversions
Message-Id: <b3bh53$1knn6o$1@ID-184292.news.dfncis.de>
Benjamin Goldberg wrote:
> Gunnar Hjalmarsson wrote:
>>
>> sub sprintfmt {
>> my $string = shift;
>> return sprintf $string, @_ if $] >= 5.008;
>> my $argref = \@_;
>> my (%refidx, @args);
>> for (0..$#$argref) { $refidx{$_} = \$argref->[$_] }
>> while ($string =~ s/(%)(\d+)\$([\w\.])/$1$3/) {
>> push @args, ${delete $refidx{$2-1}} if $refidx{$2-1};
>> }
>> for (0..$#$argref) { push @args, ${$refidx{$_}} if $refidx{$_} }
>> return sprintf $string, @args;
>> }
>
> According to the perl5.8.0 documentation for sprintf:
>
> printf '%3$d %d %1$d', 1, 2, 3; # prints "3 1 1"
Hmm.. I failed to find the v5.8.0 docs for sprintf on line, but
perldelta talks about parameter *reordering*.
> Your function, given those arguments, produces "3 1 2"... oops.
Yeah, that was intended...
> Perhaps something like the following will do:
>
> sub sprintfmt {
> my $fmt = shift;
> my ($i, @p) = 0;
> $fmt =~ s[%(?:(\d+)\$)?([\d.]*[%a-z])]{
> push @p, $1 ? ($1-1) : $i++;
> '%' . $2;
> }ige;
> sprintf $fmt, @_[@p];
> }
> __END__
>
> This correctly produces "3 1 1" when given ('%3$d %d %1$d', 1, 2, 3).
But why do you do it that simple, when it can be done much more
complicated?? ;-)
> I think that it would be most convenient
> if your function (and hence your data) is compatible with perl5.8.0's
> handling of the issue. That way, when you upgrade to 5.8, you can
> discard your sprintfmt function and use perl's builtin sprintf without
> needing to change your data.
I agree on that, but I'm still hesitating, since I can't help wondering
if the behaviour is intended, or if it is a bug. Do you know how to find
somebody who would be able to tell?
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
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 4612
***************************************