[22504] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4725 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 18 14:05:44 2003

Date: Tue, 18 Mar 2003 11:05:10 -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           Tue, 18 Mar 2003     Volume: 10 Number: 4725

Today's topics:
    Re: 'Wraping' die() <bkennedy@hmsonline.com>
        Adding Perl library to default OS X Server install <sbour@niaid.nih.gov>
    Re: Anyone For Golf? (Resistor Colour Codes) (Jasper)
    Re: Anyone For Golf? (Resistor Colour Codes) (Jasper)
    Re: Anyone For Golf? (Resistor Colour Codes) (Jasper)
        Catching RST when using sysread and sockets (Scott McPheeters)
    Re: Determining String Membership <member26707@dbforums.com>
    Re: disable pattern metacharacters? <chang0@adelphia.net>
    Re: disable pattern metacharacters? <bing-du@tamu.edu>
    Re: Expression with varying number of conditions <dtweed@acm.org>
        how to check file size (very large! > 2GB) using Perl <yongliu@uiuc.edu>
        How to create a file in cgi/perl? <trond@bwsnett.no>
    Re: How to create a file in cgi/perl? <user@someserver123abc.com>
    Re: How to create a file in cgi/perl? <nobody@dev.null>
    Re: How to create a file in cgi/perl? <perl-dvd@darklaser.com>
        Inserting Appoinments in Lotus Notes Calendar <dillon@SpamMinuSaccessdenied.darktech.org>
        more efficent way to foreach ... $x.=$_ <user@someserver123abc.com>
    Re: more efficent way to foreach ... $x.=$_ <me@verizon.invalid>
    Re: more efficent way to foreach ... $x.=$_ <mjcarman@mchsi.com>
    Re: remote control with perl <user@someserver123abc.com>
    Re: Run perl script under Mac OS X <sbour@niaid.nih.gov>
    Re: text filter <REMOVEsdnCAPS@comcast.net>
    Re: text filter <uri@stemsystems.com>
    Re: why can't I last? <user@someserver123abc.com>
    Re: why can't I last? <bart.lateur@pandora.be>
    Re: why can't I last? <nobody@dev.null>
    Re: why can't I last? <stevenm@bogus.blackwater-pacific.com>
    Re: why can't I last? <mjcarman@mchsi.com>
    Re: why can't I last? <REMOVEsdnCAPS@comcast.net>
    Re: why can't I last? <nobody@dev.null>
        win32 command execution (DannyBoy)
    Re: win32 command execution (remove the obvious)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Tue, 18 Mar 2003 12:15:15 -0500
From: "Ben Kennedy" <bkennedy@hmsonline.com>
Subject: Re: 'Wraping' die()
Message-Id: <PIidnfw68M8myeqjXTWcoA@giganews.com>


"James Willmore" <jwillmore@cyberia.com> 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.

 ...

> $SIG{__DIE__} = sub{print "Ouch!!\n";};

 ...

> sub get_a{
>     my $self= shift;
>     my $a = shift;
>     die "No A .....";
> }

As long as you are working within a package, why not implement a "throw"
method that all your code uses for fatal errors?

sub get_a {
    my $self = shift;
    my $a = shift;
    $self->throw("Uh oh, fatal error in get_a!");
}

sub throw {
    my $self = shift;
    my $reason = shift;
    # one thing you can do is build a stack trace with caller()
    print STDERR "Ouch!! $reason\n";
}

Your throw() method can in turn "die" if it wants to.  If your package is
agnostic as to what happens code it calls die()'s, then this should work for
you.  Hope this helps!

--Ben Kennedy




------------------------------

Date: Tue, 18 Mar 2003 12:49:55 -0500
From: Stephan Bour <sbour@niaid.nih.gov>
Subject: Adding Perl library to default OS X Server install
Message-Id: <BA9CC673.6374%sbour@niaid.nih.gov>

> This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

--B_3130836596_21260234
Content-type: text/plain; charset="US-ASCII"
Content-transfer-encoding: 7bit

Under Macintosh OS 10.2.4: I'm trying to install the perl MIME:64 module and
the Makefile complains that it can't find the perl.h library to complete the
install. Is there a reason why some perl modules are absent in the OS X
Server version of Perl? Any reason why I couldn't reinstall Perl from the
standard distribution?
Thanks, 

Stephan. 



--B_3130836596_21260234
Content-type: text/html; charset="US-ASCII"
Content-transfer-encoding: quoted-printable

<HTML>
<HEAD>
<TITLE>Adding Perl library to default OS X Server install</TITLE>
</HEAD>
<BODY>
<FONT SIZE=3D"2"><FONT FACE=3D"Geneva">Under Macintosh OS 10.2.4: I'm trying to=
 install the perl MIME:64 module and the Makefile complains that it can't fi=
nd the perl.h library to complete the install. Is there a reason why some pe=
rl modules are absent in the OS X Server version of Perl? Any reason why I c=
ouldn't reinstall Perl from the standard distribution? <BR>
Thanks, <BR>
<BR>
Stephan. <BR>
<BR>
</FONT></FONT>
</BODY>
</HTML>


--B_3130836596_21260234--



------------------------------

Date: 18 Mar 2003 09:34:26 -0800
From: jasper@mccrea.demon.co.uk (Jasper)
Subject: Re: Anyone For Golf? (Resistor Colour Codes)
Message-Id: <b6891527.0303180934.2e68645f@posting.google.com>

tiltonj@erols.com (Jay Tilton) wrote in message news:<3e764de1.80697313@news.erols.com>...
> Benjamin Goldberg <goldbb2@earthlink.net> wrote:
> : How about:
> :       @c{@c=qw(k wn d ge w en ue t y te)}=0..9;$"='|';
> :       @s=map@c{/(@c)$/i},@ARGV;print@s[0,1],0 x$s[2],$/
> 
> That got me thinking about finding the shortest possible substring of
> each color that would identify it without being anchored.
> 
>     black  => k
>     brown  => br
>     red    => d
>     orange => or
>     yellow => ye
>     green  => ee
>     blue   => u
>     violet => v
>     grey   => ey
>     white  => h
> 
> Then, just for kicks, I added the "use re 'debug';" pragma to watch
> the matching engine's behavior.  Nice surprises.  
> 
>     orange => o
>     yellow => y
> 
> Since the matching engine inspects substrings starting from the left,
> /br/ will match brown earlier than /o/ will,
> /o/ will match orange earlier than it will match yellow or violet,
> /y/ will match yellow earlier than it will match grey.
> 
> IOW, it relies heavily on the matching engine's order of operations.
> I can easily see it going to pieces if any of the engine's internal
> wizardry changes in future, but at least it works in 5.8.0.
> 
> So, a 94-character solution.
> 
>     @c{@c=qw(k br d o y ee u v ey h)}=0..9;$"='|';
>     @s=map@c{/(@c)/i},@ARGV;print@s[0,1],0 x$s[2],$/
> 
> Shaving more from this one would need the color names to change.  I'd
> like "grey" to be called "slate" from now on.  :)

I think this is shorter:

#!perl -l
print map{($a)=/.../g;0|
index("blacbrowred oranyellgreeblueviolgreywhit",$a)/4}@ARGV

I think it's 87 by standard golf counting ('#!perl ' doesn't count)

Not fully tested.

And I'm quite sure there's a load of fat in there.

Jasper


------------------------------

Date: 18 Mar 2003 09:44:53 -0800
From: jasper@mccrea.demon.co.uk (Jasper)
Subject: Re: Anyone For Golf? (Resistor Colour Codes)
Message-Id: <b6891527.0303180944.49de1fb5@posting.google.com>

Further: the characters at the end are more distinctive: only need three of those

#!perl -l
print map{0|index("ackownredngeloweenlueletreyite",/...$/&&$&)/3}@ARGV
(73)

and if we don't use strict

#!perl -l
print map{0|index(ackownredngeloweenlueletreyite,/...$/&&$&)/3}@ARGV
(71)

the quoting isn't necessary.

Jasper


------------------------------

Date: 18 Mar 2003 10:14:05 -0800
From: jasper@mccrea.demon.co.uk (Jasper)
Subject: Re: Anyone For Golf? (Resistor Colour Codes)
Message-Id: <b6891527.0303181014.3d1dd09c@posting.google.com>

#!perl -l
print map{.5*index acowdzanlleeueoleyit,/..(..?)/&&$1}@ARGV

think this is around 62

Jasper


------------------------------

Date: 18 Mar 2003 08:21:38 -0800
From: scottmc94@hotmail.com (Scott McPheeters)
Subject: Catching RST when using sysread and sockets
Message-Id: <13b27267.0303180821.7eb2b4bf@posting.google.com>

I am writing a perl program to send a message to a listener on a
tandem system and get the response.

The response is not CRLF terminated, the first 2 bytes tells me the
length of the message and then the message.

My problem is every once in a while the tandem will send a RST (I see
the RST using a packet sniffer) and I can't seem to catch it.  My
sysread will just sit there looking for data that doesn't come.


Am I doing this the right way?  Should I be using something else?  Is
there a way to catch the RST (or FIN).  Here is some sample code of
what I am doing.


use IO::Socket;

$host = "XXX.XXX.XXX.XXX";
$myport = "XXXX";

$tempmess = "NOT REALLY MY MESSAGE";

$packed_length = pack("n", length($tempmess));
$message = $packed_length.$tempmess;

$remote = IO::Socket::INET->new( Proto     => "tcp",
                                 PeerAddr  => $host,
                                 PeerPort  => $myport,
                                );
if (!$remote) { die "cannot connect to $host" }

$remote->autoflush(1);

print "Sending Message NOW\n";
print $remote $message;
$ans_length = "";
$chk = sysread($remote,$ans_length,2);
$tot = unpack("n", $ans_length);
$chk = sysread($remote, $ans, $tot);
close $remote;

print $ans;
print "\n";


------------------------------

Date: Tue, 18 Mar 2003 15:33:10 +0000
From: rymoore <member26707@dbforums.com>
Subject: Re: Determining String Membership
Message-Id: <2656771.1048001590@dbforums.com>


Thank you all for your help.  I've got my thumb on it now. :)


Ryan

--
Posted via http://dbforums.com


------------------------------

Date: Tue, 18 Mar 2003 16:29:23 GMT
From: ebchang <chang0@adelphia.net>
Subject: Re: disable pattern metacharacters?
Message-Id: <Xns934274E1237A8chang0adelphia.net@24.48.107.54>

Bing Du Test <bing-du@tamu.edu> wrote in news:3E77425E.A70C4933@tamu.edu:

> By the way, I want an exact match.  That is if @bar is changed to "@bar =
> ('a+b+e','c+d')", $foo should not be in @bar.
> 
> From my testing, seems grep(/\Q$foo/i,@bar) says 'foo is in bar' for both
> @bar cases.  But grep(/^\Q$foo$/i,@bar) which is really what I want does
> not.
> 
> So help is still needed.
 
your \Q is also escaping the $. 

From perlop:

   \Q   quote non-word characters till \E

-- 
EBC


------------------------------

Date: Tue, 18 Mar 2003 10:18:22 -0600
From: Bing Du Test <bing-du@tamu.edu>
Subject: Re: disable pattern metacharacters?
Message-Id: <3E7746CE.FB679374@tamu.edu>

Me again.  I've figured out grep(/^\Q$test\E$/i,@a) can do what I want.

Bing

Bing Du Test wrote:

> By the way, I want an exact match.  That is if @bar is changed to "@bar =
> ('a+b+e','c+d')", $foo should not be in @bar.
>
> From my testing, seems grep(/\Q$foo/i,@bar) says 'foo is in bar' for both
> @bar cases.  But grep(/^\Q$foo$/i,@bar) which is really what I want does
> not.
>
> So help is still needed.
>
> Bing
>
> Bing Du Test wrote:
>
> > I think it is because of '+' in $foo that the following script returns
> > 'foo is not in bar' even though foo is really in bar.
> >
> > ===========
> > $foo = 'a+b';
> > @bar = ('a+b','c+d');
> >
> > if (!grep(/^$foo$/i,@bar))
> > {
> >  print "foo is not in bar\n";
> > } else {
> >             print "foo is in bar\n";
> >           }
> > ===========
> >
> > I have some vague memory that \Q may help get around.  But can not
> > remember clearly how and that simple example about \Q in perlre manual
> > does not make much sense to me.  Anybody want to help?
> >
> > Thanks,
> >
> > Bing



------------------------------

Date: Tue, 18 Mar 2003 16:48:33 GMT
From: Dave Tweed <dtweed@acm.org>
Subject: Re: Expression with varying number of conditions
Message-Id: <3E774969.A4A41FB3@acm.org>

Tad McClellan wrote:
> You are using keys from %hash1 to index into the _other_ hashes?
> 
> So all of the hashes are guaranteed to have exactly identical keys?
> 
> If so, your data structure is a very poor choice indeed.

[snip]

> Looks like LoH (list of hashes aka array of references to hashes)
> would be just the ticket. Instead of having N global hashes, have
> a single array containing N references to hashes.

Actually, if the assumption above about the keys is true, it would be
more appropriate to enforce it by using a hash of lists.

Then the sort subroutine looks more like this (untested):

   @keys = sort {
       my $aa = $bighash{$a};
       my $bb = $bighash{$b};
       my $result;
       for my $i (0..$#_) {
           $result = $_[$i] =~ m|string|
              ? $aa->[$i] cmp $bb->[$i]
              : $aa->[$i] <=> $bb->[$i];
           return $result if $result;
       }
       $result;
   } keys %bighash;

-- Dave Tweed


------------------------------

Date: Tue, 18 Mar 2003 11:56:03 -0600
From: Yong Liu <yongliu@uiuc.edu>
Subject: how to check file size (very large! > 2GB) using Perl
Message-Id: <Pine.GSO.4.31.0303181155360.7128-100000@staff3.cso.uiuc.edu>

Hi,

I have got a problem using either -s $filename or stat $filename to get
the correct information about the file size. Here is what I got:

output of -s $filename
File Size: -1522664308 bytes

output of stat $filename:
50331653 629146686 33184 1 22909 10245 0 -1522664308 1048004742 1047655840
1047655840 131072 5414720

The actual file size should be:2772302988 bytes (using ls -al)

So how should I check the file size for this kind of large file using
Perl?

(I am using version 5.004_04 built for irix-n32).

Thanks a lot!

-Yong




------------------------------

Date: Tue, 18 Mar 2003 18:21:14 +0100
From: "Trond Johansen" <trond@bwsnett.no>
Subject: How to create a file in cgi/perl?
Message-Id: <b57kij$25sts3$1@ID-175630.news.dfncis.de>

Hi.

I'm a beginner in perl
I know how to write into a file that allready exist on my server,
but I don't know the script to write a new file.

I wan't to write a file with variables from a form as ex:
$date$year.html
The file should be readable for everyone.
Anyone who can help me with that little script?

Trond Johansen




------------------------------

Date: Tue, 18 Mar 2003 13:09:34 -0500
From: stinkbomb <user@someserver123abc.com>
Subject: Re: How to create a file in cgi/perl?
Message-Id: <3E7760DE.EDD4F6C7@someserver123abc.com>



Trond Johansen wrote:
> 
> Hi.
> 
> I'm a beginner in perl
> I know how to write into a file that allready exist on my server,
> but I don't know the script to write a new file.
> 
> I wan't to write a file with variables from a form as ex:
> $date$year.html
> The file should be readable for everyone.
> Anyone who can help me with that little script?
> 
> Trond Johansen


open CLOBBER, ">$date$year.html" or die "die bitch$!";
print CLOBBER "My New File\nHope it works\n\n";
close CLOBBER;


-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
   http://www.newsfeed.com       The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----


------------------------------

Date: Tue, 18 Mar 2003 18:35:44 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: How to create a file in cgi/perl?
Message-Id: <3E776692.4000609@dev.null>



Trond Johansen wrote:

> Hi.
> 
> I'm a beginner in perl
> I know how to write into a file that allready exist on my server,
> but I don't know the script to write a new file.
> 
> I wan't to write a file with variables from a form as ex:
> $date$year.html
> The file should be readable for everyone.
> Anyone who can help me with that little script?
> 
> Trond Johansen
> 
> 
> 


If you open a filehandle for writing and the underlying file does not 
exist, Perl will attempt to create the file. So something like

open OUT, '>brandnewfile.txt';

should do the trick. A typical source of problems is that the directory 
you are trying to create the file in is not writeable for the user your 
CGI is running as. It's a good idea to do something like

open OUT, '>brandnewfile.txt' or print "I'm afraid this has failed: $!";

and then see what $! says about the reason of the failure.




------------------------------

Date: Tue, 18 Mar 2003 18:35:48 GMT
From: "David" <perl-dvd@darklaser.com>
Subject: Re: How to create a file in cgi/perl?
Message-Id: <8GJda.15$Kz6.10924@news-west.eli.net>

"Trond Johansen" <trond@bwsnett.no> wrote in message
news:b57kij$25sts3$1@ID-175630.news.dfncis.de...
> Hi.
>
> I'm a beginner in perl
> I know how to write into a file that allready exist on my server,
> but I don't know the script to write a new file.
>
> I wan't to write a file with variables from a form as ex:
> $date$year.html
> The file should be readable for everyone.
> Anyone who can help me with that little script?

Write a new file:

open(FILEHANDLE, ">/path/to/file/filename");
print FILEHANDLE "content";
close(FILEHANDLE);

Append to a file:

open(FILEHANDLE, ">>/path/to/file/filename");
print FILEHANDLE "content";
close(FILEHANDLE);

Read from a file:

open(FILEHANDLE, "</path/to/file/filename");
my @contents = <FILEHANDLE>;
close(FILEHANDLE);

Now this should work for you assuming you have the correct permissions
on your system (your allowed to write to the folder/file).  This should
get you stared.

Regards,
David
perl -e'print for map chr$_+1,"111100113107044099117099132"=~/(.{3})/g'




------------------------------

Date: Wed, 19 Mar 2003 00:12:33 +0800
From: AcCeSsDeNiEd <dillon@SpamMinuSaccessdenied.darktech.org>
Subject: Inserting Appoinments in Lotus Notes Calendar
Message-Id: <mhge7v8ih5rgmc4i8cfo0qrkleb77b87g8@4ax.com>

I have managed to  create a perl script that reads lotus notes data.
But I have no idea how to insert data.
Can anyone help?

My 'read' script is below.
Thanks a million.



#!perl -w
use strict;
use Win32::OLE;

#!/usr/bin/perl
use strict;
use warnings;
use diagnostics;
use Win32::OLE;


# Variables
my $notes_database = 'mymail.nsf';
my $viewname = '($Calendar)';



# Start Lotus Notes Session
my $notes = Win32::OLE->new('Notes.NotesSession') or die "Oops, $!";
my $database = $notes->GetDatabase("", $notes_database );	
print "Connected to ", $database->{Title}, " on ", $database->{Server}, 
"\n";

my $Title = $database->{Title};
my $AllDocuments = $database->{AllDocuments};
my $Count = $AllDocuments->{Count};

print "There are $Count documents in the database.\n";


# Select a database view (Notes Calendar);
my $view = $database->GetView($viewname);


# Get first document first and then loop for the rest.
my $ndoc = $view->GetFirstDocument;

while ($ndoc) {
	my $itm = $ndoc->GetFirstItem("Subject");

	printf "$itm->{Text}\n";
	
	$ndoc = $view->GetNextDocument($ndoc);
}








 









To e-mail, remove the obvious


------------------------------

Date: Tue, 18 Mar 2003 11:56:09 -0500
From: stinkbomb <user@someserver123abc.com>
Subject: more efficent way to foreach ... $x.=$_
Message-Id: <3E774FA9.AFEF8659@someserver123abc.com>

is there a more efficent way to:

foreach (@db){
    $db.=$_;
}


-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
   http://www.newsfeed.com       The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----


------------------------------

Date: Tue, 18 Mar 2003 17:23:04 GMT
From: "dw" <me@verizon.invalid>
Subject: Re: more efficent way to foreach ... $x.=$_
Message-Id: <YBIda.50770$68.29267@nwrdny01.gnilink.net>


"stinkbomb" <user@someserver123abc.com> wrote in message
news:3E774FA9.AFEF8659@someserver123abc.com...
> is there a more efficent way to:
>
> foreach (@db){
>     $db.=$_;
> }
>
>

$db = join '', @db;




------------------------------

Date: Tue, 18 Mar 2003 11:10:23 -0600
From: Michael Carman <mjcarman@mchsi.com>
Subject: Re: more efficent way to foreach ... $x.=$_
Message-Id: <b57ju1$i4n1@onews.collins.rockwell.com>

On 3/18/2003 10:56 AM, stinkbomb wrote:
> is there a more efficent way to:
> 
> foreach (@db){
>     $db.=$_;
> }

my $db = join('', @db);

-mjc



------------------------------

Date: Tue, 18 Mar 2003 12:03:12 -0500
From: stinkbomb <user@someserver123abc.com>
Subject: Re: remote control with perl
Message-Id: <3E775150.AD04DA72@someserver123abc.com>



Rod wrote:
> 
> "stinkbomb" <user@someserver123abc.com> wrote in message
> news:3E773B18.C9D5959@someserver123abc.com...
> > anyone tried remote control with perl?
> >
> > I guess someway to make a perl script daemon on a server.
> > and maybe access it with a web browser?
> >
> >
 .....
> 
> Ok Easy Enough.. Whats the real question?
oops, that sounds like CGI
I ment something else.

here's what I'm doing:
I want to run an mp3 jukebox.
this would run on linux box.
lets say I have perl as a daemon.
it would play all mp3s and loop them after the last one.
I want to perhaps have a remote user launch a web browser and send
commands like
raise volume
lower volume
skip file
back a file
 ...
blah...

I'm wondering if anyone has tried such a back end with a perl script.


-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
   http://www.newsfeed.com       The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----


------------------------------

Date: Tue, 18 Mar 2003 12:48:54 -0500
From: Stephan Bour <sbour@niaid.nih.gov>
Subject: Re: Run perl script under Mac OS X
Message-Id: <BA9CC636.6374%sbour@niaid.nih.gov>

in article hgub7vk5m4h1c0vnnbs592riejjgpohnah@4ax.com, Ian.H [dS] at
ian@WINDOZEdigiserv.net wrote on 3/17/03 11:40:

> -----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
> 
The problem was fixed, thanks to all your suggestions. Problem one: The
first line of my script somehow got a commented line BEFORE the
#!usr/bin/perl. Second, apparently OS 10.2 did away with a lot of local env
setting files. The symlink to my script in /usr/local/bin was not helping
until I realized /usr/local/bin was not entered as a search path in the
global file and no local .tcshrc file existed.
Anyway, it works, thanks everybody.



------------------------------

Date: Tue, 18 Mar 2003 11:52:08 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: text filter
Message-Id: <Xns934282E71C423sdn.comcast@216.166.71.239>

stinkbomb <user@someserver123abc.com> wrote in
news:3E773EE3.C0998DDA@someserver123abc.com: 

> 
> and if the string is 300BogoByes long, which is quickest?

tr

-- 
Eric
print scalar reverse sort qw p ekca lre reh 
ts uJ p, $/.r, map $_.$", qw e p h tona e;


------------------------------

Date: Tue, 18 Mar 2003 18:08:11 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: text filter
Message-Id: <x7k7ewy2d1.fsf@mail.sysarch.com>

>>>>> "JM" == Josef Möllers <josef.moellers@fujitsu-siemens.com> writes:

  JM> Helgi Briem wrote:
  >> 
  >> 
  >> $str =~ s/[^\/,a-z0-9]//g;

  JM> TMTOWTDI

  JM> $str =~ tr/\/,a-z0-9//cd;

  JM> It's even one character shorter B-{)
  JM> One can even do it with less:
  JM> $str =~ y|/,a-z\d||;

\d is a regex thing and doesn't expand in tr. only - does any expansions
in tr. and you forgot the /cd there as well.

and tr is generally much faster that s/// when it does the same kind of
work and deleting chars is one of those places.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
Damian Conway Perl Classes - January 2003 -- http://www.stemsystems.com/class


------------------------------

Date: Tue, 18 Mar 2003 11:05:01 -0500
From: stinkbomb <user@someserver123abc.com>
Subject: Re: why can't I last?
Message-Id: <3E7743AD.CC5EE8F0@someserver123abc.com>



ctcgag@hotmail.com wrote:
> 
> stinkbomb <user@someserver123abc.com> wrote:
> > foreach $rec (@db){
> >     @dates_boxes=split /$splitDates_Boxes/, $rec;
> >     $dates_boxes[0]=~ s/[^\/,a-z0-9]//g;
> >     @dates=split /$splitDates/,$dates_boxes[0];
> >     foreach $date (@dates){
> >         if ($date eq $today){
> >             print "$date = $today<br>";
> >             last;
> >         }
> >     }
> >     print "<br>oooooo<br>"; #decoration
> > }
> 
> What makes you think you can't last?
> 
> Xho
> 

actually, I want to exit all nested foreach/if in one shot.
that is at the point "             last;"


-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
   http://www.newsfeed.com       The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----


------------------------------

Date: Tue, 18 Mar 2003 16:07:32 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: why can't I last?
Message-Id: <vvge7vcpkv3kme11qcaigcib5lh7f93mv6@4ax.com>

stinkbomb wrote:

(no explanation)

>foreach $rec (@db){
>    @dates_boxes=split /$splitDates_Boxes/, $rec;
>    $dates_boxes[0]=~ s/[^\/,a-z0-9]//g;
>    @dates=split /$splitDates/,$dates_boxes[0];
>    foreach $date (@dates){
>	if ($date eq $today){
>	    print "$date = $today<br>";
>	    last;
>	}
>    }
>    print "<br>oooooo<br>"; #decoration
>}

You have nested loops. You probably want to jump out of the outer loop.
For that, use a label.

	MAIN:
	foreach $rec (@db){
	...
	   foreach ... {
	       ...
	       last MAIN;
	   }
	}

-- 
	Bart.


------------------------------

Date: Tue, 18 Mar 2003 16:29:50 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: why can't I last?
Message-Id: <3E77490C.3040201@dev.null>



stinkbomb wrote:

> 
> ctcgag@hotmail.com wrote:
> 
>>stinkbomb <user@someserver123abc.com> wrote:
>>
>>>foreach $rec (@db){
>>>    @dates_boxes=split /$splitDates_Boxes/, $rec;
>>>    $dates_boxes[0]=~ s/[^\/,a-z0-9]//g;
>>>    @dates=split /$splitDates/,$dates_boxes[0];
>>>    foreach $date (@dates){
>>>        if ($date eq $today){
>>>            print "$date = $today<br>";
>>>            last;
>>>        }
>>>    }
>>>    print "<br>oooooo<br>"; #decoration
>>>}
>>>
>>What makes you think you can't last?
>>
>>Xho
>>
>>
> 
> actually, I want to exit all nested foreach/if in one shot.
> that is at the point "             last;"


Well, if you have a question, ask it, don't just post a piece of code that produces no output.


I'm sure you have read the part in perlfunc that documents last, so you 
know that last can be used with a label, and that "[i]f the LABEL is 
omitted, the command refers to the innermost enclosing loop." So a 
solution to your problem would be to use a label. Do it like this:




use strict;

my @outer=(4,9,16,25);
my @inner=(3,6,9,12);


LABEL:for my $outer (@outer){
	for my $inner (@inner){
		print "inner=$inner; outer=$outer\n";
		if ($inner==$outer){
			print "$inner=$outer\n";
			last LABEL;
		};
		print "No match this time.\n";
	};
};

print "The show must go on.\n";




------------------------------

Date: Tue, 18 Mar 2003 08:50:49 -0800
From: Steve May <stevenm@bogus.blackwater-pacific.com>
Subject: Re: why can't I last?
Message-Id: <b57i6n$mmh$1@quark.scn.rain.com>

Bart Lateur wrote:
> stinkbomb wrote:
> 
> (no explanation)
> 
> 
>>foreach $rec (@db){
>>   @dates_boxes=split /$splitDates_Boxes/, $rec;
>>   $dates_boxes[0]=~ s/[^\/,a-z0-9]//g;
>>   @dates=split /$splitDates/,$dates_boxes[0];
>>   foreach $date (@dates){
>>	if ($date eq $today){
>>	    print "$date = $today<br>";
>>	    last;
>>	}
>>   }
>>   print "<br>oooooo<br>"; #decoration
>>}
> 
> 
> You have nested loops. You probably want to jump out of the outer loop.
> For that, use a label.
> 
> 	MAIN:
> 	foreach $rec (@db){
> 	...
> 	   foreach ... {
> 	       ...
> 	       last MAIN;
> 	   }
> 	}
> 

Ah.... that appears to be an infinite loop unless I'm mistaken...

Personally, I'd lean towards putting the loop in a sub
or subref and then using return to bail, something like:

my @list = qw( some values to match against );

my $db_loop = sub{
  my @rows = @_;
  foreach my $row( @rows ){
    for( @list ){
       $row =~ /$_/ and return;
    }
  }
};

&$db_loop( @db );

Though I would *not* intentionally force that much work on the
regex engine unless I was feeling lazy.  (Like now).

s.



------------------------------

Date: Tue, 18 Mar 2003 11:06:00 -0600
From: Michael Carman <mjcarman@mchsi.com>
Subject: Re: why can't I last?
Message-Id: <b57jlp$i246@onews.collins.rockwell.com>

On 3/18/2003 10:50 AM, Steve May wrote:
> Bart Lateur wrote:
>> 
>> You have nested loops. You probably want to jump out of the
>> outer loop. For that, use a label.
>> 
>> 	MAIN:
>> 	foreach $rec (@db){
>> 	...
>> 	   foreach ... {
>> 	       ...
>> 	       last MAIN;
>> 	   }
>> 	}
>> 
> 
> Ah.... that appears to be an infinite loop unless I'm mistaken...

You are. It's a nested loop, not an infinite one.

Well, okay, the '...' are arbitrary, so it *could* be infinite, but in
general, it isn't.

> Personally, I'd lean towards putting the loop in a sub
> or subref and then using return to bail, something like:
> 
> my @list = qw( some values to match against );
> 
> my $db_loop = sub{
>   my @rows = @_;
>   foreach my $row( @rows ){
>     for( @list ){
>        $row =~ /$_/ and return;
>     }
>   }
> };
> 
> &$db_loop( @db );

That seems like a hideous and unnecessary obfuscation. How is that
better than using 'last LABEL' ?

-mjc



------------------------------

Date: Tue, 18 Mar 2003 11:55:15 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: why can't I last?
Message-Id: <Xns9342836E73E7Csdn.comcast@216.166.71.239>

stinkbomb <user@someserver123abc.com> wrote in
news:3E7743AD.CC5EE8F0@someserver123abc.com: 

> 
> actually, I want to exit all nested foreach/if in one shot.
> that is at the point "             last;"

Nice of you to say so :-/

You can label your blocks in order to selectively exit them.

-- 
Eric
print scalar reverse sort qw p ekca lre reh 
ts uJ p, $/.r, map $_.$", qw e p h tona e;


------------------------------

Date: Tue, 18 Mar 2003 18:45:49 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: why can't I last?
Message-Id: <3E7768F0.3020308@dev.null>



Michael Carman wrote:

> On 3/18/2003 10:50 AM, Steve May wrote:
> 
>>Bart Lateur wrote:
>>
>>>You have nested loops. You probably want to jump out of the
>>>outer loop. For that, use a label.
>>>
>>>	MAIN:
>>>	foreach $rec (@db){
>>>	...
>>>	   foreach ... {
>>>	       ...
>>>	       last MAIN;
>>>	   }
>>>	}
>>>
>>>
>>Ah.... that appears to be an infinite loop unless I'm mistaken...
>>
> 
> You are. It's a nested loop, not an infinite one.
> 
> Well, okay, the '...' are arbitrary, so it *could* be infinite, but in
> general, it isn't.

I presume -- and I may be wrong here -- that Steve's thinking that since 
  the MAIN: label is before the outer loop, saying last MAIN returns 
control to the point before the outer loop begins, so the program enters 
the outer loop again, the loops are run until the last MAIN is executed 
again, at which point control is returned to the point before the outer 
loop, and things keep getting repeated over and over again. Frankly, 
it's not illogical to think that; it's just not the way Perl works.



------------------------------

Date: 18 Mar 2003 08:17:18 -0800
From: dan4606@hotmail.com (DannyBoy)
Subject: win32 command execution
Message-Id: <6d72f570.0303180817.7cea519f@posting.google.com>

Hey everyone,

I have a script that executes a command in this form: `command`

This script is set to run consistently on a machine that is used for
monitoring servers. The script runs fine but we have found that
evertime the script runs it pops up the window's command prompt window
and after a while it gets anoying and cumbersome to minimize the
window every single time the script runs. Also,  the window pops up at
certain times when we are doing other things on that machine and it
pops up and interrupts our work. What would be an alternative method
of running the command without poping up a new window every time it
runs? Would running it as a service be our answer? or is the problem
tied to the fact that we are using `command` to do the job?

note: `command` is just an example. we are actually running the
command `nbtstat` and generating output for that.

Thanks,

Dan


------------------------------

Date: Tue, 18 Mar 2003 18:13:45 GMT
From: "--Rick" <no_trick@my-de(remove the obvious)ja.com>
Subject: Re: win32 command execution
Message-Id: <tlJda.12284$ja4.846699@bgtnsc05-news.ops.worldnet.att.net>


"DannyBoy" <dan4606@hotmail.com> wrote in message
news:6d72f570.0303180817.7cea519f@posting.google.com...
| Hey everyone,
|
| I have a script that executes a command in this form: `command`
|
| This script is set to run consistently on a machine that is used for
| monitoring servers. The script runs fine but we have found that
| evertime the script runs it pops up the window's command prompt
window
| and after a while it gets anoying and cumbersome to minimize the
| window every single time the script runs.
| <snip>
| Thanks,
|
| Dan

This one is difficult to find in perldoc.

perldoc perlwin32

then search for wperl.

The wperl executable runs mostly like perl without the console.

--Rick




------------------------------

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 4725
***************************************


home help back first fref pref prev next nref lref last post