[22499] in Perl-Users-Digest
Perl-Users Digest, Issue: 4720 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 17 14:06:32 2003
Date: Mon, 17 Mar 2003 11:05:08 -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 Mon, 17 Mar 2003 Volume: 10 Number: 4720
Today's topics:
Re: 'Wraping' die() <please@no.spam>
Re: 'Wraping' die() (Nataku)
Re: Can I use session Variables in Perl <perl-dvd@darklaser.com>
Re: Can I use session Variables in Perl <Juha.Laiho@iki.fi>
Re: Counter64 values returned by the Net::SNMP module (John Ramsden)
delete a cookie without needing the user to close windo <nospam@nospam.org>
Re: delete a cookie without needing the user to close w <noreply@gunnar.cc>
Re: file parse into hash and writing output with certai (david)
Generic way to work with mysql tables...? <yossi_shani@yahoo.com>
Re: Generic way to work with mysql tables...? <nobull@mail.com>
Re: How to execute find -exec in perl? <bernd.fischer@xignal.de>
Re: How to execute find -exec in perl? <abigail@abigail.nl>
Mail::Sender <ben.i.glaser@boeing.com>
Re: Mail::Sender <noreply@gunnar.cc>
Re: reading every other byte <please@no.spam>
Re: reading every other byte <krahnj@acm.org>
Re: regexp and grouping <abigail@abigail.nl>
Re: Run perl script under Mac OS X <sbour@niaid.nih.gov>
Re: Run perl script under Mac OS X <ian@WINDOZEdigiserv.net>
splitting an array into two arrays <usenet@dwall.fastmail.fm>
Re: splitting an array into two arrays <krahnj@acm.org>
Re: splitting an array into two arrays <grazz@nyc.rr.com>
Win32 Perl newsgroup? <aknntp@yahoo.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 17 Mar 2003 17:42:29 +0000
From: Chris Lowth <please@no.spam>
Subject: Re: 'Wraping' die()
Message-Id: <rQnda.17420$EA6.2428016@newsfep2-win.server.ntli.net>
James Willmore wrote:
> I am tring to 'wrap' die (ie $SIG{__DIE__}) from within a package.
> Huh? I want to issue my own error message from the package when it
> encounters an error, but allow the caller to have his own mechanism to
> issue an error message.
>
> So, for example and the sake of argument (hopfully this doesn't start
> some feud):
>
> ##'main' - in different script
> #!/usr/bin/perl -w
>
> $SIG{__DIE__} = sub{print "Ouch!!\n";};
>
> use strict;
> use Some::Package;
>
> ...
>
> $some_package->get_a();
> die "Alas, I have died\n";
>
> ##'Some::Package'
>
> $SIG{__DIE__} = sub{print "Not going well, is it?\n";};
>
> ...
>
> sub get_a{
> my $self= shift;
> my $a = shift;
> die "No A .....";
> }
>
> I realize this example is lame, but the basic idea of what I'm trying
> to is there (I hope). I started searching the groups for some
> answers, but ended up with a lot of people who don't know how to
> redirect STDERR to the browser.
>
> So, if you could shed some light on this ....
>
> Thanks,
>
> Jim
use subs qw(die);
sub die {
my $msg = join(" ",@_);
print STDERR "DEATH! $msg\n";
exit 2;
}
die "Ahhhhh!";
This isnt the whole story - 'fraid it breaks the interaction with "eval".
It all depends how far you want to go with this. Franky, I'd write a "mydie"
rather than replacing the standard system one. Sup2u.
Chris
--
My real address is: chris at lowth dot sea oh em
Author of "protector" (http://protector.sourceforge.net)
-- OpenSource (free) e-mail virus protection
------------------------------
Date: 17 Mar 2003 10:09:42 -0800
From: Crapnut566@yahoo.com (Nataku)
Subject: Re: 'Wraping' die()
Message-Id: <7e48fc99.0303171009.52f2fd5f@posting.google.com>
It sounds like you want to print an error message, and then die again,
or am I mistaken?
Your form is at least correct to override the sig handler.
jwillmore@cyberia.com (James Willmore) wrote in message news:<e0160815.0303170041.29c00a0d@posting.google.com>...
> I am tring to 'wrap' die (ie $SIG{__DIE__}) from within a package.
> Huh? I want to issue my own error message from the package when it
> encounters an error, but allow the caller to have his own mechanism to
> issue an error message.
>
> So, for example and the sake of argument (hopfully this doesn't start
> some feud):
>
> ##'main' - in different script
> #!/usr/bin/perl -w
>
> $SIG{__DIE__} = sub{print "Ouch!!\n";};
>
> use strict;
> use Some::Package;
>
> ...
>
> $some_package->get_a();
> die "Alas, I have died\n";
>
> ##'Some::Package'
>
> $SIG{__DIE__} = sub{print "Not going well, is it?\n";};
>
> ...
>
> sub get_a{
> my $self= shift;
> my $a = shift;
> die "No A .....";
> }
>
> I realize this example is lame, but the basic idea of what I'm trying
> to is there (I hope). I started searching the groups for some
> answers, but ended up with a lot of people who don't know how to
> redirect STDERR to the browser.
>
> So, if you could shed some light on this ....
>
> Thanks,
>
> Jim
------------------------------
Date: Mon, 17 Mar 2003 16:11:45 GMT
From: "David" <perl-dvd@darklaser.com>
Subject: Re: Can I use session Variables in Perl
Message-Id: <5tmda.1$Kz6.6109@news-west.eli.net>
"Yurij Nykon" <ynykon@lvivmedia.lviv.net> wrote in message
news:3E75F03F.3080805@lvivmedia.lviv.net...
> Hi,
>
> what I need is to use some Session variables on my web-Project. I have
> to initialize a session-Variable on one web-page and check it on
another.
> is it possible?
Yes
> If yes, how?
Cookies
> Please send me some code example,
There are several cookie libs on cpan (search.cpan.org). Other than
that, you could use mod_perl, but I think that's a little more extreme
than you intend to go with this.
Regards,
David
perl -e'print for map chr$_+1,"111100113107044099117099132"=~/(.{3})/g'
------------------------------
Date: Mon, 17 Mar 2003 17:22:01 GMT
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: Can I use session Variables in Perl
Message-Id: <b54vui$idc$1@ichaos.ichaos-int>
Yurij Nykon <ynykon@lvivmedia.lviv.net> said:
>what I need is to use some Session variables on my web-Project. I have
>to initialize a session-Variable on one web-page and check it on another.
>is it possible?
>If yes, how?
As HTTP as such is stateless, you must implement the sessions in some
way where the client provides part of the functionality. So, in each
request the client must present, along with the rest of the request,
some identification of the session. The two ways to do this are either
to have the session id stored to the client in a cookie or by embedding
the session id into the URL for the request. Both of these techniques
have their own benefits and drawbacks, which might better suit for
discussion in comp.infosystems.www.authoring.cgi (whether or not you're
planning to write your code as CGI modules).
Then, when you have implemented your session mechanism, just provide
some data storage on your server end that is accessible by all the
"pages". Use the session id as the search/store key for the data, and
organise the data in a way that makes sense in your application. If
you're using regular files (or one of the dbm implementations) as your
storage, take care of locking so that concurrent updates don't mess up
your data. If your data store is some "real" database, then the database
will handle much of the concurrency issues for you.
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)
------------------------------
Date: 17 Mar 2003 09:51:45 -0800
From: john_ramsden@sagitta-ps.com (John Ramsden)
Subject: Re: Counter64 values returned by the Net::SNMP module
Message-Id: <d27434e.0303170951.66e63c88@posting.google.com>
"Cox NNTP" <dgay@init0.org> wrote in message news:<u7d9a.114499$P1.7082807@news1.east.cox.net>...
> >
> > I am using the Net::SNMP module v4.0.3 (with ActiveState Perl 5.6.1)
> > to return, among other things, Counter64 values. But every such value
> > is returned as either 0 or 9223372036854775808.
> >
> > (This is data defined by the Fiber Channel Management MIB, being
> > returned by a McDATA SNMP Agent.)
> >
> > Obviously not all statistics counts will have exactly the same
> > large value; so it looks like something is wrong here! Any ideas?
> >
> > I'm pulling the values straight out of the $session->var_bind_list
> > hash.
> >
>
> Can you retrieve the values you would expect by using snmpget/walk
> (without using the perl module)?
Apologies for the delay in replying - I've been busy in other areas.
Yes, when I ran 'snmpwalk' it returned exactly the same set of values
as described above, and using the 5000-digit Windows calculator at:
http://www.home52365.fsnet.co.uk/bcalc.htm
I've since found out that the large integer starting with 9.. is
actually 2^63. So I'm wondering if this value indicates 'undefined'
or 'void' (?).
Cheers
John Ramsden (john_ramsden@sagitta-ps.com)
------------------------------
Date: Mon, 17 Mar 2003 11:15:09 -0500
From: "Christian Caron" <nospam@nospam.org>
Subject: delete a cookie without needing the user to close window
Message-Id: <b54sad$oan7@nrn2.NRCan.gc.ca>
Hi all,
I create a cookie like this:
$cookie_dnt = new CGI::Cookie(
-name => 'cookie_name',
-value => '["$username","$password","$language"]',
-path => '/netman/domains',
-secure => 'no'
);
print "Set-Cookie: $cookie_dnt\n";
This cookie will be deleted when the user closes his browser. Now, I'm
wondering if there is a possibility to delete the cookie without the need
for the user to close his browser.
After googling for a while, the only solution I found was to put an expire
date of -something (but that's the same as what I'm doing now: it will
delete the cookie only when the browser is closed).
Thanks for any information!
Christian
------------------------------
Date: Mon, 17 Mar 2003 17:41:06 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: delete a cookie without needing the user to close window
Message-Id: <b54u0k$25e0oa$1@ID-184292.news.dfncis.de>
Christian Caron wrote:
> I'm wondering if there is a possibility to delete the cookie without
> the need for the user to close his browser.
http://www.cookiecentral.com/faq/#4.4
(not exactly a Perl question, is it? ;-) )
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 17 Mar 2003 10:28:26 -0800
From: dwlepage@yahoo.com (david)
Subject: Re: file parse into hash and writing output with certain format to new file
Message-Id: <b09a22ae.0303171028.16efd19@posting.google.com>
"John W. Krahn" <krahnj@acm.org> wrote in message news:<3E751399.A27912D7@acm.org>...
> david wrote:
> >
> > Thank you for the explanation - that does make sense. Everything is
> > working great. One last question, in my "print OUT" statement, every
> > line after the 1st one has a space in front of it (i.e.):
> >
> > 00000000,$$U23567$$,$$HMJ0002$$
> > 00000000,$$U23571$$,$$HMJ0003$$
> > 00000000,$$U23572$$,$$HMJ0004$$
> >
> > Am I missing a chomp somewhere? Any idea where this extra space is
> > coming from?
>
>
> perldoc -q "Why do I get weird spaces when I print an array of lines"
>
>
> John
Got it- thanks!
------------------------------
Date: Mon, 17 Mar 2003 19:49:49 +0200
From: "Yossi Shani" <yossi_shani@yahoo.com>
Subject: Generic way to work with mysql tables...?
Message-Id: <1047923326.205041@sj-nntpcache-3>
Greetings,
I have a perl/cgi script which works on a single mysql table and extracts
the data into html table.
So far everything works well, the problem started when I needed to work on
multiple tables.
I want to eliminate the hardcoded headers and use a generic way to work.
This is what I do at the moment:
-----------------------------
while (($platform, $ip, $gid, $owner, $console, $console_ip, $pccs,
$version, $gsr, $history) = $sth->fetchrow_array) {
push(@row,th({-bgcolor=>"color"},$platform).$divider.td({$tc},$ip).$divider.
td({-align=>'center',$tc},$gid).$divider.td({$tc},$owner).$divider.td({$tc},
$console).$divider.
td({$tc},$console_ip).$divider.td({$tc},$pccs).$divider.td({$tc},$version).$
divider.td({$tc},$gsr).$divider.td({$tc},$history));
-----------------------------
Let's say I have the headers of two different tables in the following lists
@header = qw / platform ip gid .../
@header1 = qw /one two three .../
Could I do something like
while (@header) = $sth->fetchrow_array) { ---> instead of while (
$platform, $ip, $gid ... )
I would like the header names to become the actual variables which holds the
params.
Just like the example above but without typing the actual variables.
platform becomes $platforms which holds the first data of the row....
ip becomes $ip which holds the second data of the row ...
etc..
maybe with the assistant of eval and references ...?
absolutely lost it ....
Hope I made it clear....
Many thanks,
Yossi.
------------------------------
Date: 17 Mar 2003 18:02:12 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Generic way to work with mysql tables...?
Message-Id: <u9u1e150t7.fsf@wcl-l.bham.ac.uk>
"Yossi Shani" <yossi_shani@yahoo.com> writes:
[ FAQ: "How can I use a variable as a variable name?" ]
or
[ I want to use symbolic referecnces ]
Best advice - stop wanting that.
Alternative - learn about symbolic references.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Mon, 17 Mar 2003 17:45:29 +0100
From: Bernd Fischer <bernd.fischer@xignal.de>
Subject: Re: How to execute find -exec in perl?
Message-Id: <3E75FBA9.BD7FE24B@xignal.de>
Thank's to all,
I did it already with 'FILE::FIND'
use File::Find;
foreach( @dir_list ){
find( \&wanted, $dir."/".$_ );
}
sub wanted {
my(
$file,
$mode,
);
$file = $File::Find::name;
if( -f $file ) {
$mode = 0464;
chmod( $mode, $file );
} elsif( -d $file ) {
$mode = 0575;
chmod( $mode, $file );
}
}
Bernd
------------------------------
Date: 17 Mar 2003 17:35:40 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: How to execute find -exec in perl?
Message-Id: <slrnb7c1rc.ug8.abigail@alexandra.abigail.nl>
Bernd Fischer (bernd.fischer@xignal.de) wrote on MMMCDLXXXV September
MCMXCIII in <URL:news:3E7595B2.EA0790EC@xignal.de>:
// Hi,
//
// I want to recursively change the permissions mode
// of a directory and files of that selected directory.
//
// In UNIX I can do a
// find . -type f -exec chmod 664 {} \;
// and a
// find . -type d -exec chmod 775 {} \;
//
//
// If I want to implement that in Perl
I would do:
system chmod => '-R', 'a-x,ug=rwX,o=rX' and die "system() failed\n";
Assuming you don't have sockets, devices, doors or other exotic file
types in the directory tree.
Abigail
--
#!/opt/perl/bin/perl -w
$\ = $"; $SIG {TERM} = sub {print and exit};
kill 15 => fork for qw /Just another Perl Hacker/;
------------------------------
Date: Mon, 17 Mar 2003 16:45:39 GMT
From: "Ben" <ben.i.glaser@boeing.com>
Subject: Mail::Sender
Message-Id: <HBwJw2.JDK@news.boeing.com>
Using Mail::Sender. Can send file as attachement but would like to do one
of two things. Either:
1. set up the msg => as STDOUT so the body of the message is the ouput of
the script.
or
2. instead of attachement have the contents of the file become the body of
a message (msg => read from STDIN filehandle?
New at perl.
------------------------------
Date: Mon, 17 Mar 2003 18:57:19 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Mail::Sender
Message-Id: <b552ge$267reb$1@ID-184292.news.dfncis.de>
Ben wrote:
> Using Mail::Sender. Can send file as attachement but would like to do one
> of two things. Either:
>
> 1. set up the msg => as STDOUT so the body of the message is the ouput of
> the script.
If you can use Mail::Sender for sending attachments, it cannot be that
hard to pick one of the examples in the module docs for sending a simple
message.
What have you tried? Please post relevant code fragments.
Which error messages did you receive?
> 2. instead of attachement have the contents of the file become the body of
> a message (msg => read from STDIN filehandle?
You find an example of that at
http://groups.google.com/groups?dq=&hl=en&lr=&ie=UTF-8&threadm=b527p9%2424qc0e%241%40ID-184292.news.dfncis.de&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%26group%3Dcomp.infosystems.www.authoring.cgi
The original poster didn't show how he set the smtp parameter, but
besides that, the example should work.
> New at perl.
You are obviously also new at posting to Usenet groups, since you posted
exactly the same question to comp.lang.perl.modules a couple of days
ago. Don't do so!
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Mon, 17 Mar 2003 17:30:26 +0000
From: Chris Lowth <please@no.spam>
Subject: Re: reading every other byte
Message-Id: <wFnda.17387$EA6.2446399@newsfep2-win.server.ntli.net>
Zach Jones wrote:
> I have a problem. I need every other byte out of this binary file
> that I have, and this file is huge. The only way I can think of to do
> it is as follows:
>
> open DATAFILE, "thing.data";
> for $z (0 .. $bin_file_size)
> {
> read(DATAFILE,$data,1);
> if($z%2 == 0)
> {
> $data_out = $data_out . $data;
> }
> }
>
> return $data_out;
>
> This is the slow dirty way to do it and I want a fast way because time
> in processing is an issue. Can anyone think of a faster way to do
> this?
>
> Thanks in advance.
You'll have to a comparative timing, but this might be worth a try ..
open DATAFILE, "thing.data";
$to_read = $bin_file_size;
while ( $to_read > 0 ) {
read(DATAFILE, $data, 8192);
$to_read -= length($data);
$data =~ s/(.)./$1/g;
$data_out .= $data;
}
return $data_out;
But -- reading an arbitrarily large file into memory isnt such a good idea -
you are openning up the possibility of crashes due to "out of memory"
conditions (etc). You should probably try to think of a less demanding
solution.
Chris
--
My real address is: chris at lowth dot sea oh em
Author of "protector" (http://protector.sourceforge.net)
-- OpenSource (free) e-mail virus protection
------------------------------
Date: Mon, 17 Mar 2003 17:55:28 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: reading every other byte
Message-Id: <3E760BFD.17B82283@acm.org>
Zach Jones wrote:
>
> I have a problem. I need every other byte out of this binary file
> that I have, and this file is huge. The only way I can think of to do
> it is as follows:
>
> open DATAFILE, "thing.data";
> for $z (0 .. $bin_file_size)
> {
> read(DATAFILE,$data,1);
> if($z%2 == 0)
> {
> $data_out = $data_out . $data;
> }
> }
>
> return $data_out;
>
> This is the slow dirty way to do it and I want a fast way because time
> in processing is an issue. Can anyone think of a faster way to do
> this?
This _should_ be faster (untested).
open DATAFILE, 'thing.data' or die "Cannot open thing.data: $!";
$/ = \16384;
my $data_out;
while ( <DATAFILE> ) {
$data_out .= join '', unpack 'xa' x (length() / 2), $_;
}
return $data_out;
__END__
John
--
use Perl;
program
fulfillment
------------------------------
Date: 17 Mar 2003 17:48:21 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: regexp and grouping
Message-Id: <slrnb7c2j5.ug8.abigail@alexandra.abigail.nl>
Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMMCDLXXXV
September MCMXCIII in <URL:news:b547i5$1hs$2@mamenchi.zrz.TU-Berlin.DE>:
[] Bjørnar Libæk <bjoernal@ifi.uio.no> wrote in comp.lang.perl.misc:
[] > Given the string "what is wrong with my brain", I want to get every
[] > two-letter composition that starts with an 'r' into the grouping-variables,
[] > that is, $1='ro' and $2='ra' in this example. How do I do this?
[]
[] my @hits = 'what is wrong with my brain' =~ /(r.)/g;
That doesn't set $2, and doesn't set $1 to 'ro'. It only sets $1,
and sets it to 'ra'.
The following will set $1 to 'ro', and $2 = 'ra':
$_ = 'what is wrong with my brain';
/@{[".*(r.)" x (() = m(r.)g)]}/;
print "<$1> <$2>\n";
__END__
<ro> <ra>
How to deal with 'mirror' is left as a excercise for the reader.
Abigail
--
perl -we 'print q{print q{print q{print q{print q{print q{print q{print q{print
qq{Just Another Perl Hacker\n}}}}}}}}}' |\
perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w
------------------------------
Date: Mon, 17 Mar 2003 11:31:53 -0500
From: Stephan Bour <sbour@niaid.nih.gov>
Subject: Re: Run perl script under Mac OS X
Message-Id: <BA9B62A9.629C%sbour@niaid.nih.gov>
in article h3sb7vo0hkcef1g9pnf1vie887nm1jij8t@4ax.com, Ian.H [dS] at
ian@WINDOZEdigiserv.net wrote on 3/17/03 10:59:
> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
>
> In a fit of excitement on Mon, 17 Mar 2003 10:53:15 -0500, Stephan
> Bour <sbour@niaid.nih.gov> managed to scribble:
>
>> in article 73e19f332cb551d1a96caaa4ffb3fa6e@news.teranews.com,
>> Randal L. Schwartz at merlyn@stonehenge.com wrote on 3/17/03 10:39:
>>
>>>>>>>> "Stephan" == Stephan Bour <sbour@niaid.nih.gov> writes:
>>> Stephan> I need to setup a cron job to run a perl script at
>>> regular intervals. Stephan> However, on my OS X system the
>>> command somescript.pl does not run the Stephan> somescript.pl
>>> script.
>>>>>
>>> It does if you make it executable (chmod +x script)
>>> and ensure that the first line of the script is exactly
>>>
>>> #!/usr/bin/perl
>>>
>>> print "Just another Perl hacker,"
>>
>> All the execute bits are turned on for the script and the script
>> does start with the #!/usr/bin/perl -w line. However, it does not
>> execute without the perl command. This is unlikely to be a problem
>> with the script since even the lesson scripts from my Perl book
>> behave like that when downloaded strait from the O'Reilly web site
>> and chmod 755.
>
>
> Are you 100% sure the shebang line points to the correct path on your
> box?
>
> What did your "strict" and "warnings" code throw out?
>
>
>
> Regards,
>
> Ian
>
[db4109:~] steph% whereis perl
/usr/bin/perl
The script doesn't use strict (it's pretty small). The warnings return
nothing because the script is never initialized. The script works fine from
the command line: perl somescript.pl. The problem is that the command:
somescript.pl returns "somescript.pl: Command not found". The pwd is the
directory where the script lives when I invoke it.
Cheers,
Stephan.
------------------------------
Date: Mon, 17 Mar 2003 16:40:49 GMT
From: "Ian.H [dS]" <ian@WINDOZEdigiserv.net>
Subject: Re: Run perl script under Mac OS X
Message-Id: <hgub7vk5m4h1c0vnnbs592riejjgpohnah@4ax.com>
Keywords: Remove WINDOZE to reply
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
In a fit of excitement on Mon, 17 Mar 2003 11:31:53 -0500, Stephan
Bour <sbour@niaid.nih.gov> managed to scribble:
> > Are you 100% sure the shebang line points to the correct path on
> > your box?
> >
> > What did your "strict" and "warnings" code throw out?
> >
> >
> >
> > Regards,
> >
> > Ian
> >
> [db4109:~] steph% whereis perl
> /usr/bin/perl
> The script doesn't use strict (it's pretty small). The warnings
> return nothing because the script is never initialized. The script
> works fine from the command line: perl somescript.pl. The problem
> is that the command: somescript.pl returns "somescript.pl: Command
> not found". The pwd is the directory where the script lives when I
> invoke it.
> Cheers,
> Stephan.
Ahh, 'command not found', we didn't know this before =)
Try executing it as:
./somescript.pl
UNIX doesn't assume that you're executing from the current dir like
windoze does. If you want to be able to access the file from any dir,
either copy the somescript.pl into your PATH, or create a symlink:
cd /usr/local/bin
ln -s /path/to/your/somescript.pl somescript.pl
This would then call your somescript.pl from anywhere on the system
without requiring the ./ (current dir).
Worth a try =)
Regards,
Ian
-----BEGIN xxx SIGNATURE-----
Version: PGP 8.0
iQA/AwUBPnX6kGfqtj251CDhEQIqugCg5oW+ec4j1Z5aiBcAvDXQRPeLoaYAnR3Q
xC9lAbp+ypUQ+ZqCDnlbynC8
=piSN
-----END PGP SIGNATURE-----
--
Ian.H [Design & Development]
digiServ Network - Web solutions
www.digiserv.net | irc.digiserv.net | forum.digiserv.net
Scripting, Web design, development & hosting.
------------------------------
Date: Mon, 17 Mar 2003 17:01:20 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: splitting an array into two arrays
Message-Id: <Xns93417A4BC8BE4dkwwashere@216.168.3.30>
The purpose of this snippet of code is to split an array into halves. If
there are an odd number of elements, the first array should be the
largest, e.g.; an array with 9 elements should be split into arrays with 5
and 4 elements.
my @full_array = 1..9;
my @second = @full_array;
my @first = splice @second, 0, int(scalar(@second)/2 + 0.8);
This was part of a quick-and-dirty program I wrote this morning, so I took
what seemed to be the easiest way. Just out of curiousity, is there a
better way?
--
David K. Wall - usenet@dwall.fastmail.fm
WWJD? JWRTFM.
------------------------------
Date: Mon, 17 Mar 2003 18:15:10 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: splitting an array into two arrays
Message-Id: <3E76109A.1826545B@acm.org>
"David K. Wall" wrote:
>
> The purpose of this snippet of code is to split an array into halves. If
> there are an odd number of elements, the first array should be the
> largest, e.g.; an array with 9 elements should be split into arrays with 5
> and 4 elements.
>
> my @full_array = 1..9;
> my @second = @full_array;
> my @first = splice @second, 0, int(scalar(@second)/2 + 0.8);
>
> This was part of a quick-and-dirty program I wrote this morning, so I took
> what seemed to be the easiest way. Just out of curiousity, is there a
> better way?
I don't know if this is "better" but it does what you want.
my @first = @full_array[ 0 .. ( $#full_array / 2 ) ];
my @second = @full_array[ ( $#full_array / 2 + 1 ) .. $#full_array ];
John
--
use Perl;
program
fulfillment
------------------------------
Date: Mon, 17 Mar 2003 18:46:44 GMT
From: Steve Grazzini <grazz@nyc.rr.com>
Subject: Re: splitting an array into two arrays
Message-Id: <oKoda.10289$5I6.1960393@twister.nyc.rr.com>
John W. Krahn <krahnj@acm.org> wrote:
> "David K. Wall" wrote:
>>
>> The purpose of this snippet of code is to split an array into halves. If
>> there are an odd number of elements, the first array should be the
>> largest, e.g.; an array with 9 elements should be split into arrays with 5
>> and 4 elements.
>>
>> my @full_array = 1..9;
>> my @second = @full_array;
>> my @first = splice @second, 0, int(scalar(@second)/2 + 0.8);
>>
>> This was part of a quick-and-dirty program I wrote this morning, so I took
>> what seemed to be the easiest way. Just out of curiousity, is there a
>> better way?
>
>
> I don't know if this is "better" but it does what you want.
>
> my @first = @full_array[ 0 .. ( $#full_array / 2 ) ];
> my @second = @full_array[ ( $#full_array / 2 + 1 ) .. $#full_array ];
>
Maybe put the slice on the left?
my (@first, @second);
(@first[0 .. $#full_array/2], @second) = @full_array;
--
Steve
perldoc -qa.j | perl -lpe '($_)=m("(.*)")'
------------------------------
Date: Mon, 17 Mar 2003 12:39:59 -0500
From: AK <aknntp@yahoo.com>
Subject: Win32 Perl newsgroup?
Message-Id: <lp1c7vkt56s6r2hjue8qvoe5jeksb2akfl@4ax.com>
Is there a newsgroup dedicated to Perl on Win32?
In any case, can I get some recommended sites where online discussion about Perl
on Win32?
At the moment, my main issue is trying to send out email through an
authenticated SMTP server (eg: smtp.mail.yahoo.com) on Windows 2000.
- Aamir
------------------------------
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 4720
***************************************