RE: pattern matching question

2008-09-22 Thread Dave
-Original Message-
From: ANJAN PURKAYASTHA [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, 23 September 2008 11:22 AM
To: beginners@perl.org
Subject: pattern matching question

here is my problem:
i have to check the entries of a column and write them out to a file if they
happen to be DNA sequences ie they are exclusively composed of the letters
A, T, G, C- no spaces or digits.
the column also happens to have other strings that are made of
word/digit/space characters.
i tried
if($x=~ /[ATGC]/ )then .


Hello Anjan,

This will be my first email to beginners@perl.org, so just incase I didn't
follow the correct standards for posting, please forgive me.

Your regular expression will match any column that has one A T G or C. So in
this sense a column with A (which isn't DNA sequence) will return true
for your "if" statement.

What you want is something like this: if ($x =~ /^[ATGC]+$/i){

The ^ represents the start of a line, the $ represents the end of the line
and a + represents a match of 1 or more times. You also might want to add a
/i to ignore character case, so a column with atgc will also return true
(which is common if the DNA is masked).

Hope this helps.

Dave



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: regex count

2008-09-23 Thread Dave
Hello Stephen,

I think the problem might be with your regular expression and not $x.

If your regular expression does not match the current line then every line
will be skipped.

What does the line that is being processed look like?

Dave

-Original Message-
From: Stephen Reese [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, 24 September 2008 3:10 PM
To: beginners@perl.org
Subject: regex count

I'm looking to increase the count $x every time a match is made for
the regex. Though I'm not having any luck nor am I receiving any
errors. I'm missing something, it seems $x++ would increase $x since
it starts at 0 by default?
http://www.doulos.com/knowhow/perl/quick_start/

my ( %srca );
my $x;

while () {
next unless
/Sig:\s*(\d+)\s+Subsig:\s*(\d+)\s+Sev:\s*(\d+)([^\[]+)\[([\d\.]+):(\d+)\s*->
\s*([\d\.]+):(\d+)
/;
$x++;
print $x;
$srca{ $5 } += $x;  
}

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




learning perl

2002-02-20 Thread Dave

   I've installed ActivePerl 5.61 on Win2000, the PATH and associations work
just fine, but the scripts don't seem to be doing anything.  Is there
anything else I need?  My ISP won't let me play around with scripts on their
servers, so I wanted to be able to play with them on my own system.

Thanks.
Dave



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




group

2003-12-25 Thread dave
I've made a group called everyone.  It has its own Sub-directory, 
"/home/everyone".  I have 3 users in the group.  Do I have to do 
anything else so everyone can share that Sub-directory?  Mandrake 9.2. 
Thanks in advance.

--
Dave Pomeroy K7DNP South Eastern Washington


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>



wrong group

2003-12-25 Thread dave
Sorry for my last post I thought I'd sent that to Linux-newbie.

--
Dave Pomeroy K7DNP South Eastern Washington


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>



how to upload image in perl

2003-03-20 Thread Dave

Hai ,

I have a problem uploading images with perl. I have HTML code within perl. When i just 
link the image useing the link tag 



It doesnt work. I tried giving the path ../search.gif. Is there any other way to 
upload the image.

Thanks in advance,




-
With Yahoo! Mail you can get a bigger mailbox -- choose a size that fits your needs


RE: Substitution Problem

2001-06-08 Thread Dave Newton

Mart Marken said:
> I'm taking in a csv file and splitting it. One of the fields(doc) could
> possibly have six spaces which will disrupt the program later on so I need
> to substitute in dummy values. $doc == "  " finds the "empty" fields
> okay but the substitution doesn't work. Clear as Mud?? Any ideas?

Once I fixed an issue like this (because it suited the problem
well) by checking to see how many values I got back from the
split and doing things based on that number; perhaps that
would work for you.

Dave
--
Dave Newton, [EMAIL PROTECTED]




RE: if then else

2001-06-09 Thread Dave Newton

> ok, where did i go wrong now???
> ##
> ##set $previous site var.
> ##
> if ($ENV{'HTTP_REFERER'} = "")
>{$previous = "an unknown site"}
>else
>{$previous = "$ENV{'HTTP_REFERER'}};

= instead of eq (string comparison), and in any case even
using the wrong operator you'd have wanted == (equality
test) instead of = (assignment operator).

Just to start a formatting flamefest ;) I would have written 
this like this:

if ($ENV{'HTTP_REFERER'} eq "") {
  $previous = "an unknown site";
} else {
  $previous = $ENV{'HTTP_REFERER'};
}

Dave

--
Dave Newton, [EMAIL PROTECTED]




RE: Understanding Randal's answer

2001-06-09 Thread Dave Newton

> > So yes, I take newlines in paths seriously.  You can't be an ostrich
> > about them burying your head in the sand.  That's not secure, and you
> > will be hacked.
> 
> Ostriches don't really bury their heads in the sand, you know...

S, that was supposed to be a secret.

I've not been able to come up with any reasonable CGI that would be
creating a path that the user has any control over; why would one want
to do that?

Dave




RE: Understanding Randal's answer

2001-06-10 Thread Dave Newton

> ([EMAIL PROTECTED]) spew-ed forth:
> > I've not been able to come up with any reasonable CGI that would be
> > creating a path that the user has any control over; why would one want
> > to do that?
> What about things like document/filesystem management tools? Or
> (re)configuration tools? Saying there is no need for it (which
> you didn't do :)

No way, I'm far too clever for that :)

I guess in my experience when I've done things that needed actual filesystem
access I've used a "trusted" model because I haven't needed "generic" user
access.

> Another example is web-based email, which allows you to create multiple
folders.

Sure, but when we did that they were based off of a root and we checked
for ..'s to avoid path... uh... backstepping.

Dave




utf8 and uc()

2001-06-10 Thread Dave Neill

I've gotten the following to work (after doing a Linux localedef command for
fi_FI - finnish) and am now trying to achieve some knowledge of how to do
manipulations/matchings using the utf8 pragma.

The locale test reads:

#!/usr/bin/perl -w

use POSIX;
use locale;

$loc = POSIX::setlocale( &POSIX::LC_ALL, "fi_FI" );

$foo = "Söderkulla";

print "locale $loc, foo $foo, FOO ".uc($foo)."\n";


with its output being:

locale fi_FI, foo Söderkulla, FOO SÖDERKULLA



and the utf8 test reads:

#!/usr/bin/perl

use utf8;

$foo = "Söderkulla";
print "foo $foo; FOO ".uc($foo)."\n";

but I get the error messages:

Malformed UTF-8 character (unexpected non-continuation byte 0x64 after start byte 
0xf6) at ./x.x line 5.
Malformed UTF-8 character (unexpected non-continuation byte 0x64 after start byte 
0xf6) in uc at ./x.x line 6.
Malformed UTF-8 character (unexpected non-continuation byte 0x64 after start byte 
0xf6) in uc at ./x.x line 6.
foo Söderkulla; FOO SKULLA

I would imagine it has something to do with the assignment to $foo being made
in a byte orientation and that I need to do some encoding to utf8 on the
string before assignment.  Any pointers?

Thanks,

Dave



Re: extracting substr

2001-06-11 Thread Dave Cross

On Sat, Jun 09, 2001 at 06:33:21PM -0500, Karen Cravens ([EMAIL PROTECTED]) wrote:
> On 9 Jun 2001, at 16:21, William wrote:
> 
> >if (($L) = ($_) =~ m/\b([0-9.0-9.0-9.0-9]+)\b/ ) {
> 
> A valid IP address is going to look like four groups of one to three 
> digits separated by dots.
> 
> So if "one to three digits" is \d{1,3} (\d is the same as [0-9]), the 
> regex is going to want to look something more like
> 
> /\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/
> 
> Notice the quoted-metacharacter dots, otherwise you'll get wacky 
> matches.
> 
> Now, the \b's are probably rendered moot by greediness, so unless 
> you are trying to avoid picking up "x12.34.56.78" you can take 
> those out.  Someone can probably fine-tune which places don't 
> actually need three digits and whatnot, too.

It can be a bit more complex that that tho'. The first diit in a set of
three can only be 1 or 2, if the first digit is 2 then the second one can
only be 1 to 5, if the second digit is 5 then the third can only be 1 to
5.

Of course, trying to cope withthat makes the regex far more complex and
you might think it's too much extra effort for too little gain :)

Dave...




Re: reading the next line from a file

2001-06-13 Thread Dave Cross

On Wed, Jun 13, 2001 at 01:30:07PM -0700, Esrar Chowdhury ([EMAIL PROTECTED]) wrote:
> Hi!
> 
> I just started using perl and have a question. Let say I have an inputfile
> with 100 lines. Each of these lines contain a name...first name and
> last name.
> 
> I need to be able to read the 1st name..the 10th name...20th name..so on 
> i.e. every 10th name from the input file.
> 
> I do :
> 
> $name = ; #for the 1st line 
> 
> # have already opened my input file by
> 
> unless (open(INFILE, "test_input.txt")) {
> die ("Input file test_input.txt cannot be opened.\n");
> }
> 
> my question is...how do I make the read pointer read every 10th line
> from my input file? (After reading one line, does the read pointer stay
> on the same line or automatically go the next line?)

It's probably easiest to read every line, but only process every 10th one.

Something like this should do it:

while () {
  next unless $. % 10; # skip line unless it's a multiple of 10

  # Do whatever processing you want
  # The line is in $_
}

hth,

Dave...




RE: A Term::ReadKey question -- keep cursor put!

2001-06-13 Thread Dave Newton

Bear in mind that without any sort of delay it's unlikely
you'll be able to see any of this occuring.

Ah, the good old days, where a 300-baud modem was fast
and little spinny cursors were still interesting. *sigh*

Dave

--
Dave Newton, [EMAIL PROTECTED]




Re: reading the next line from a file

2001-06-13 Thread Dave Cross

On Wed, Jun 13, 2001 at 02:45:40PM -0400, Brett W. McCoy ([EMAIL PROTECTED]) 
wrote:
> On Wed, 13 Jun 2001, Esrar Chowdhury wrote:
> 
> > my question is...how do I make the read pointer read every 10th line
> > from my input file? (After reading one line, does the read pointer stay
> > on the same line or automatically go the next line?)
> 
> Hmmm... a homework problem?
> 
> Keep a counter that keeps track of the line number you are reading and
> only do stuff to the data read from the line if the line number is
> divisible by 10.

No need to keep a count. Perl does that for you - it's called $.

Dave...

-- 

  Don't dream it... be it




Re: Installed Modules

2001-06-13 Thread Dave Watson

--scott lutz <[EMAIL PROTECTED]> [010613 16:17]:
> Is there a command to list all installed modules?
> _
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
> 

Yes.  There are a few ways.

perldoc perlocal

Using ExtUtils::Installed like;

#!/usr/bin/perl
use ExtUtils::Installed;
my $instmod = ExtUtils::Installed->new();
foreach my $module ($instmod->modules()) {
my $version = $instmod->version($module) || "???";
   print "$module -- $version\n";
}

or pmtools
http://language.perl.com/misc/pmtools-1.00.tar.gz
-- 
Dave Watson



RE: use of split command - concession

2001-06-14 Thread Dave Newton

> OK, I had to try the two ways again to see how much difference it made. I
> created a random contents fixed field file 14500 lines long X 80 columns
> wide, and tried processing the lines (using substr($_,)to
> break lines up into 4 sections, substitute based on a few patterns, and
change a
> couple of columns like I had given in my previous real life example) to
see
> if loading the entire file into an array made as much performance
difference as I had
> thought previously. The difference on a file that size was so small as to
> not be worth mentioning. Either way, it processed the 14,500 line file in
> less than three seconds and wrote the new contents to the new
> file. Granted, I am using a different OS than when I did that test before,
but still, the
> difference was virtually indiscernible. Therefore, I'll concede my point
> about a significant performance difference.

See, the thing is that files are (generally) buffered, so large portions of
the file are being read into memory anyway-your perl program sees it a line
at a time, but the OS doesn't.

Performance will vary depending on how files are implemented in a) that
version
of perl (not having seen the source since... well, waaay too long ago... I
don't
know how abstracted things like that are) and b) the underlying OS.

Dave




RE: A Term::ReadKey question -- keep cursor put!

2001-06-14 Thread Dave Newton

> He'd never seen the spinny cursor and was quite impressed - quite sad
really!

*grin*

I'll admit they're cute :)

Great story though; I'll have to remember that as an easy way to impress
people.

Dave




Re: Beginer...Any free resources for Learning Perl

2001-06-14 Thread Dave Cross

On Wed, Jun 13, 2001 at 07:12:45PM +0200, Evgeny Goldin (aka Genie) 
([EMAIL PROTECTED]) wrote:
> 
> Check up my catalog at :
> [url removed]
> 
> It's only a catalog but I upload titles from it upon request.

He does, indeed, happily distribute pirate copies of Perl (and other) books
to anyone who asks. A few weeks ago I found a complete copy of my book on
his website (thanks to Google now indexing PDF files). Manning asked him to
remove it, which he did, but a few days later he was happy to email me a 
copy when I asked him to.

I'm not the only Perl author on this list. How do the others feel? Am I 
the only one that gets really angry when some idiot from Israel decides
he has the right to give away the fruits of your labour?

To the people that might be interested in Genie's treasure trove - many
Perl authors give a lot of time free to support the Perl community. If
they want to make a little (and it's really not very much) money back by 
writing books then you should support their efforts and not rip them off
by getting pirate copies like these.

Dave...
[this really _is_ a hot topic recently. this is the third place I've
has this dicussion in the last three weeks]

-- 

  Drugs are just bad m'kay




Re: Update: Where to begin??!!??

2001-06-15 Thread Dave Cross

Crystal, 

Some comments interspersed with your code below.

On Fri, Jun 15, 2001 at 01:25:59PM -0700, Crystal Gruetzmacher 
([EMAIL PROTECTED]) wrote:
> I'm trying, really I am, but I can't get this thing to work (yet). Here's
> what I have so far. Am I missing something crucial that doesn't give an
> error message?

You're not using -w
 
> #! usr/bin/perl
> use strict;
> 
> open (FILE_IN, "pslbingocard.dat")|| die "failed to open file\n";

You don't check the result of opening the output file.

> open (FILE_OUT, ">pslbingocard.txt");

No need to set $/ as "\n" is its default value.
 
> $/ = "\n";
> 
> while () {

This is where the _real_ problems are. The pipe character has a special
meaning in regular expressions, so you need to escape it with a 
backslash. Also you're splitting $/ (which only contains "\n") instead
of $_ (which contains a line of data from your file).

Try:

split(/\|/, $_);

or even just

split(/\|/);

as split works on $_ by default.

> my ($date, $time, $name, $street, $city, $state, $zip, $country, $email,
> $phone, $submit, @subscriptions) = split (/|/, $/);
> # split each line on the
> pipe, and throw into matching
> # variable entries - note
> that bingo numbers are all
> # thrown into a single
> array.
> 
> foreach my $subscription (@subscriptions) {  # loop through the
> subscriptions array

Not entirely sure what you mean this next line to do. What it actually does
is add 0 to $subscription and then skip the rest of the loop if 
$subscription is false.

> next unless $subscription +=0; #

This say, skip the rest of the loop unless $subscription contains at least
one whitespace character. Is that what you mean?

> next unless $subscription =~/\s/;
> $subscription =~s/^\s+//;
> $subscription =~s/\s+$//;
>
> $new_data .=
> "$date|$time|$name|$street|$city|$state|$zip|$country|$email|$phone|$subscri
> ption|\n"; # create a new line for each bingo number.
> }
> print FILE_OUT $new_data;
> }

hth,

Dave...




Re: Update: Where to begin??!!??

2001-06-15 Thread Dave Cross

On Fri, Jun 15, 2001 at 01:37:51PM -0700, Crystal Gruetzmacher 
([EMAIL PROTECTED]) wrote:
> what is $_ for?

It's the "default" variable an is used for a great many things in Perl.

In this case, it's where each line of a file ends up when you use the 
construction:

while () {
  # each line of file in turn appears in $_
}

You can find much more info on it in the perlvar manual page.

Dave...

-- 

  Don't dream it... be it




Re: Update: Where to begin??!!??

2001-06-15 Thread Dave Cross

On Fri, Jun 15, 2001 at 01:33:30PM -0700, Greg Meckes ([EMAIL PROTECTED]) wrote:
> First :
> Your assigning a newline to the "$/" scalar: $/ = "\n";
> Why? Get rid of it.
> 
> Second:
> The split: split (/|/, $/);
> Should be : split (/\|/, $_);
> 
> Third:
> You should escape the pipes in the print statement:
> "$date|$time|$name|$street|etc";
> Should be: |$date\|$time\|$name\|$street\|etc";

Greg,

Your first two pieces of advice were spot on, but I can't see any reason why
you'd want to escape pipes in a print statement.

Am I missing something obvious?

Dave...

-- 

  Don't dream it... be it




Re: Update: Where to begin??!!??

2001-06-15 Thread Dave Cross

On Fri, Jun 15, 2001 at 04:43:26PM -0400, Michael Wolfrom ([EMAIL PROTECTED]) wrote:
> 
> Dave Cross wrote:
> 
> >
> > > #! usr/bin/perl
> > > use strict;
> > >
> > > open (FILE_IN, "pslbingocard.dat")|| die "failed to open file\n";
> >
> > You don't check the result of opening the output file.
> 
> I think, in general,  that it is good programming practice that you check 
> the opening of the output file.
> What if your input file inludes a bad path?

Er... exactly. That's what I was saying. Crystal checked the result of 
opening the input file, but not the output file. I was pointing that out,
not saying it was a good idea :)

Dave...

-- 

  Drugs are just bad m'kay




Re: Update: Where to begin??!!??

2001-06-15 Thread Dave Cross

On Fri, Jun 15, 2001 at 01:45:00PM -0700, Peter Cornelius 
([EMAIL PROTECTED]) wrote:
> > 
> > open (FILE_IN, "pslbingocard.dat")|| die "failed to open file\n";
> You really want an 'or' here ---^^ not '||'.  The operator precedence
> can bite you.

Only if you miss out the parenthesis around the parameters to 'open'. In
this case || works just fine.

Dave...

-- 

  .sig missing...




Re: $hash{$_}++

2001-06-18 Thread Dave Cross

On Mon, Jun 18, 2001 at 05:34:29PM -0400, David Gilden ([EMAIL PROTECTED]) 
wrote:
> How about a an example or 2 where you would use this,
> 
> $hash{$_}++

# count the occurences of values in an array
my %hash;

$hash{$_}++ foreach @array;

# and display the results sorted
print map { "$_: $hash{$_}\n" } 
  sort { $hash{$b} <=> $hash{$a} } keys %hash;


hth,

Dave...

-- 

  Don't dream it... be it




Re: Perl/Linnux/unix question

2001-06-19 Thread Dave Young

It all has to do with your shell. modern shells shouldn't kill your
processes on logout. Do  & to run it in the background
(which also "disconnects" it from the current tty.


if all else fails, man  and look for nohup




Hope that helps.



Dave



...On Mon, 4 Jun
2001
[EMAIL PROTECTED] wrote:

> Which linux command i use to run a perl script that will stay running in my server 
>even when i logout via telnet?
> Thanks
>
>






Re: Cannot get a connect to Mysql using DBI !!!!!!!!!!!

2001-06-20 Thread dave hoover


Derrick wrote:

> Cannot get a connect to Mysql using DBI
> [snip]
> The code I'm using to connect is.
> 
> $dbhandle = DBI->connect("dbi:mysql:products", "",
> "") || &error("\nCouldn't
> co
> nect to DB.\n\n ".$?);
> 
> I've modified it Like this
> 
> $dbhandle =
> DBI->connect("dbi:mysql:products\@localhost:3306",
> "thrawn",
> "rootroot") || &error("\nCouldn't co
> nect to DB.\n\n ".$?);
> $dbhandle =
>
DBI->connect("dbi:mysql:products\@192.168.1.170:3306",
> "thrawn",
> "rootroot") || &error("\nCouldn't co
> nect to DB.\n\n ".$?);
> [snip]

I'm not a DBI expert, but whenever I connect to mysql,
the first argument generally goes: 

DBI:mysql:DATABASE_NAME

Is "products\@192.168.1.170:3306" really the name of
your database?  Looks like you should change it back
to simply read "products," but keep your username and
password as is (thrawn, rootroot).

Give it a try (if you haven't already), I'm not sure
if this will make a difference, but hopefully it will!

=
Dave Hoover
"Twice blessed is help unlooked for." --Tolkien
http://www.redsquirreldesign.com/dave

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



Advice for Perl Class

2001-06-21 Thread dave hoover

I began learning Perl in November of 2000.  I've
learned a lot in a short amount of time and I feel
like I've got a good understanding of Perl
fundamentals (I just finished reading "Effective Perl
Programming"...great book).

Anyway, at my job I have the opportunity to use some
training money to learn more about whatever I want.  I
want to learn more about Perl and Networks and CGI.  I
live in the Chicago area and I need some
recommendations about where I could find some
excellent classes nearby.

TIA

=
Dave Hoover
"Twice blessed is help unlooked for." --Tolkien
http://www.redsquirreldesign.com/dave

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



Re: Advice for Perl Class

2001-06-21 Thread dave hoover

If I were to fly out to Portland and take the track
mentioned below, how much would that cost?  I couldn't
find the rates for these on the Stonehenge site.  Feel
free to email me directly at:
[EMAIL PROTECTED]

Thanks,
--Dave Hoover


--- "Randal L. Schwartz" <[EMAIL PROTECTED]>
wrote:
> 
> Yes, we offer a "learning perl" course about every
> two months in
> beautiful Portland Oregon, and either the following
> "packages,
> references, objects, modules", or "CGI" alternately
> in the days
> immediately following, so you can either be a
> large-scale programmer,
> or a CGI programmer, with minimal fuss and travel
> time.
> 
> See perltraining.stonehenge.com for detailed info.
> 
> -- 
> Randal L. Schwartz - Stonehenge Consulting Services,
> Inc. - +1 503 777 0095
> <[EMAIL PROTECTED]>
> http://www.stonehenge.com/merlyn/>
> Perl/Unix/security consulting, Technical writing,
> Comedy, etc. etc.
> See PerlTraining.Stonehenge.com for onsite and
> open-enrollment Perl training!


__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



Re: Online books

2001-06-22 Thread dave hoover

jaya kumaran wrote:

>   Is there any free online books availabe to learn 
>   perl script?

Here's about 50 of them:

http://dmoz.org/Computers/Programming/Languages/Perl/Documentation/Tutorials/

HTH


=
Dave Hoover
"Twice blessed is help unlooked for." --Tolkien
http://www.redsquirreldesign.com/dave

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



RE: Help please (any one)

2001-06-22 Thread Dave Neill

From: Govinderjit Dhinsa <[EMAIL PROTECTED]>



> My question was;

> How do I put a condition on the program, as I only want data from the

> input files, which at 'field 15' has a 'M' and some other fileds that I

> need(as marked on example data)!



If you mean by "field 15" the fifteenth element in your array, try:

> while($line=){

> chomp $line;

> @fields=split "\t",$line;

if ($fields[14] =~ /M/){

> printf sortcode "\n%6.6

> s%8.8s%27.27s%20.20s%5.5s%16.16s%10.10s%8.8s%10.10s",

> $fields[0],$fields[5],

>

> $fields[70],$fields[71],$fields[73],$fields[74],$fields[75],

> $fields[76],$fields[77];

}

> }

>

> close iscd;

> close sortcode;

> exit;

You'll want to read up on regexp matching to make this condition more
restrictive and to find out how to match your other conditions.



Dave





Re: Telnet

2001-06-20 Thread Dave Young

ummm, if you set the display variable correctly and have an Xserver
running on the PC, sure you can. Why anyone would want to is beyond me..

use xterm for shell access and run any gui utils you like by hand.
Running a window manager over the network isn't really a pleasant
experience...



$.02 US (fully refundable)



--Dave


On Wed, 20 Jun 2001, SAWMaster wrote:

> Yes and no.  You cannot do it with telnet, but you can get what you want by
> using an x-term client and setting up the server box to allow x connections.
> One commercial example of an X-Term client for a windows box would be
> X-Win32.  Do a search on the net for "X-Win32" and you'll find plenty of
> information.  I'm not sure if there's any public domain freeware X-Term
> clients.  If anyone knows of one please let me know.
>
>
> > Hi
> >
> > Hey can we run KDE or Xwindows by telneting to Linux servers ???
> >
> > Regards
> >
> > Joel
>

-- 
Dave Young
Systems Administrator
Boldfish, Inc.
http://www.boldfish.com

chown -R us:us yourbase




Re: sort by value?

2001-06-26 Thread dave hoover

Mark Bedish wrote:

[snip]
> am I using the wrong approach entirely?
> 
> my @fields = qw/Text Time/;
> my %ch;
> foreach my $key (sort { $ch{1} cmp $ch{2} }  keys
> %ch ) {
>print OUT "$key: $ch{$key} \n"; # show key and
> value
>  }
[snip]

Mark,

It looks to me that your hash %ch is empty.  Your
foreach will never begin because there is no list to
iterate.  You need to assign keys & values to %ch.

When it is time to sort numerically, use the spaceship
operator <=>.  So it would look like this:

sort { $ch{1} <=> $ch{2} }

HTH

BTW, I got the sort answer from "Effective Perl
Programming" by Joseph Hall, a book I HIGHLY recommend
to beginners (such as myself) once they've worked
through the Llama and given the Camel a few tries.


=
Dave Hoover
"Twice blessed is help unlooked for." --Tolkien
http://www.redsquirreldesign.com/dave

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



Re: sort by value?

2001-06-26 Thread dave hoover

Mark Bedish wrote:
>  Dave,
> 
> >It looks to me that your hash %ch is empty.  Your
> >foreach will never begin because there is no list
> to
> >iterate.  You need to assign keys & values to %ch.
> 
> >When it is time to sort numerically, use the
> spaceship
> >operator <=>.  So it would look like this:
> 
> >sort { $ch{1} <=> $ch{2} }
> 
> No I have got the data, I didnt show the full
> example. My tab delimited
> file is something like this:
> 
> Complete music of Ockeghem380
> Bach Cantatas bwv140 etc 113
> Achirana Marshall Trio 48
> Hello Children 145
[snip]

Mark,

OK, I understand.  Using the data you provided above,
this code worked for me:

--
my (%ch, @fields);

open(FILE, "data");
while () {
chomp;
@fields = split(/\t/);
$ch{$fields[0]} = $fields[1];
}
close FILE;

for (sort { $ch{$a} <=> $ch{$b} } keys %ch) {
print "$_: $ch{$_}\n";
}



=
Dave Hoover
"Twice blessed is help unlooked for." --Tolkien
http://www.redsquirreldesign.com/dave

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



Re: array slice question

2001-06-26 Thread dave hoover

Bradford wrote:

> Hi,
> 
> I have an unnamed array which I created from
> splitting up a colon separated string:
> 
>   $_ = "0th:1st:2nd:3rd:4th:5th:6th:7th:Some
> random text: might have :colons: or might not"
>   print ((split /:/)[1,6,8]);  
> 
> ...but I really need to print everything after the
> 8th element.  If the array were named, I could do
> something like this:
>   
> @arr = split(/:/);
> print @arr[1,6,8..$#arr]);
> 
> ... and this would include everything after the 8th
> array element.  I know that -1 should start from the
> end of the array, but specifying [1,6,8..-1] doesn't
> work.
> 
> I didn't see anything in perldata about it so I'm
> hoping someone has a solution. 
> 
> Thanks.
> -- Brad

Brad,

I can't figure it out either.  Below is a link to a
discussion that mirrors your predicament.  I don't
have time to read it right now, but maybe it will shed
some light on the subject for you.

http://groups.google.com/groups?hl=en&safe=off&th=94cd69e466afd840,11&start=0&ic=1



=
Dave Hoover
"Twice blessed is help unlooked for." --Tolkien
http://www.redsquirreldesign.com/dave

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



Re: arrays

2001-06-28 Thread dave hoover

Tyler wrote:

> Hello everyone,
> 
> I'm just starting perl.  I want to search through
> httpd.conf and get the
> ServerName from each virtual host.
> Ex:
> 
> DocumentRoot /home2/ploo.net/www
> ServerName www.ploo.net
> CustomLog /home2/ploo.net/logs/access_log
> ErrorLog /home2/ploo.net/logs/error_log
> TransferLog
> /home2/ploo.net/logs/transfer_log
> ScriptAlias /cgi-bin/
> /home2/ploo.net/cgi-bin/
> 
> 
> DocumentRoot /home2/test.net/www
> ServerName www.test.net
> CustomLog /home2/test.net/logs/access_log
> ErrorLog /home2/test.net/logs/error_log
> TransferLog
> /home2/test.net/logs/transfer_log
> ScriptAlias /cgi-bin/
> /home2/test.net/cgi-bin/
> 
> 
> Could I get the ServerName values put into an array
> so I can do something
> with each different ServerName?  Thank you everyone.
> 
> Tyler

Try this:

-
open(FILE, "httpd.conf");
while () {
push(@server_names, $1) if /ServerName\s+(.*)/
}
close FILE;
-

Now the array @server_names holds the values you want.

HTH


=
Dave Hoover
"Twice blessed is help unlooked for." --Tolkien
http://www.redsquirreldesign.com/dave

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



Re: arrays

2001-06-28 Thread dave hoover

Tyler wrote:
> One more quick question.  How can I count the values
> in an array
> (@servernames)?
> I want to print my servernames seperately:
[snip]

Tyler,

To get a numeric count of the elements in
@servernames, do this:

$count = @servernames;  # count now equals the number
of elements in @servernames

To print out each of the elements, do this:

foreach $name (@servernames) {
 print "$name\n";
}

Another way to do the above is this:

for (@servernames) {
 print "$_\n";  # when no placeholder variable is
specified, by default the $_ variable is used
}

HTH,


=
Dave Hoover
"Twice blessed is help unlooked for." --Tolkien
http://www.redsquirreldesign.com/dave

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



Taint checking with -T

2001-06-29 Thread dave hoover

When I added -T to an existing Perl script, I got the
error message:

Too late for "-T" option at main.cgi line 1.

Is this a common error message with -T?  What am I
doing wrong?

You can get the source at:
http://www.redsquirreldesign.com/soapbox


=
Dave Hoover
"Twice blessed is help unlooked for." --Tolkien
http://www.redsquirreldesign.com/dave

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



help with running -T

2001-06-29 Thread dave hoover

Here is an ultra-simple script "tst":
---
#!/usr/bin/perl -w

use Blah;
$b = new Blah;
print "foo";
$b->bar();
---

Here is the ultra simple module "Blah.pm":

package Blah;
sub new {
my $pkg = shift;
bless {};
$pkg;
}
sub bar {
print "bar\n";
}
1;
--

Everything works fine:
% perl tst
foobar

But when I add -T to the first line of tst, something
goes wrong:

% perl -T tst
Can't locate Blah.pm in @INC (@INC contains:
/usr/local/lib/perl5/sun4-solaris/5.00401
/usr/local/lib/perl5
/usr/local/lib/perl5/site_perl/sun4-solaris
/usr/local/lib/perl5/site_perl) at tst line 3.
BEGIN failed--compilation aborted at tst line 3.

I can't figure out why this is happening.  Can anyone
help?


=
Dave Hoover
"Twice blessed is help unlooked for." --Tolkien
http://www.redsquirreldesign.com/dave

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



Re: Please remove

2001-06-20 Thread Dave Young

D.J.B. is quite the character..  ;)


> I also have tried removal but I get this great little insulting remark that
> could only have been produced by a 'secret loyal order of Unix programmers'
> bit bombardier!
>
> Hi. This is the qmail-send program at onion.perl.org.
> I'm afraid I wasn't able to deliver your message to the following
> addresses. This is a permanent error; I've given up. Sorry it didn't work
> out.
>
>



Re: creating columns on the fly

2001-07-05 Thread dave hoover

Eric Wang wrote:
[snip]
> First, I decided that I will need to generate the
> SQL statements inside
> the perl script. (i.e. print SQL "insert...
> blah..").  

If you use DBI, this is no problem, in fact, it's
expected.  You will probably call
$sth->execute(SQL_HERE).  You can plug in a previously
generated scalar variable at SQL_HERE.

> But, I need to know
> if this column I insert into has already existed or
> not? if not, create
> it, otherwise just insert it. So, the simple
> question is can I do this?
[snip]

Yes. You can query the database first to see if it's
there, then based on the results, construct your SQL
statement with UPDATE/INSERT accordingly.



=
Dave Hoover
"Twice blessed is help unlooked for." --Tolkien
http://www.redsquirreldesign.com/dave

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



Re: Another Newbie

2001-07-06 Thread dave hoover

Robert wrote:
> Can anyone recommend a
> good book/Website...something that could point me
> into the correct
> direction.

Check out http://learn.perl.org for suggestions and
links to some good books.

Go here for online tutorials (Google-> "perl
tutorial"):
http://www.google.com/search?sourceid=navclient&q=perl+tutorial

> Also I am a old Dos/Windows kid and I have found
> that a lot of Perl people
> use Unix and Linux. Is this a true concept?

Yes.

> is learning Linux also the best thing to do in 
> regards to Perl programs?

I don't think that learning Linux would _necessarily_
make you a better Perl programmer, but I would
definitely encourage you to install Linux on any
computer you have at your disposal...it's a beautiful thing.

=
Dave Hoover
"Twice blessed is help unlooked for." --Tolkien
http://www.redsquirreldesign.com/dave

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



Re: foreach examples/usage

2001-07-07 Thread dave hoover

Evan wrote:
> I am trying to learn the foreach loop. Is there a
> place on the web where there are examples for the
> foreach? 

There's good, quick example on Perl Monks:
http://www.perlmonks.org/index.pl?node=foreach%20loops&lastnode_id=954

> Basically I have an array of X elements and
> I want to go from the first element (is it zero?) to
> the last. I have a variable containing the number of
> elements in the array. If the array has 22 elements
> does it go from 0 to 21 or 1 to 22?

It goes from 0 to 21.

It sounds like you're just starting to learn Perl. 
I'd suggest checking out http://learn.perl.org and
purchasing one of their book suggestions.

=
Dave Hoover
"Twice blessed is help unlooked for." --Tolkien
http://www.redsquirreldesign.com/dave

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



Re: Help with global variable

2001-07-09 Thread dave hoover

Kailash wrote:
[snip]

Start each of your scripts with the following, it will
save you many hours of debugging:

#!/usr/bin/perl -w
use strict;

> $input =  ;

Declaring your variables with 'my' will help you keep
track of their scope:

my $input = ;

> # I process the input here
> # If the output from previous step is a single
> field, then call subroutine
> "test" or call sub routine "test1".

When you call the subroutines, pass in the variable
like this:

my $test_return = test($input);

I'll explain why I used $test_return below...

> sub test {
> # I would like to refer to the $input variable and
> variables declared in the
> main part

Inside the subroutines grab the variable like this:

my $input = shift;

Now do whatever you want to the variable.
If you want to pass something back from the
subroutine, end your subroutine like this:

return $input;

You don't have to use $input, you could pass anything
back. Now $test_return will hold whatever you
returned!

> }

HTH

=
Dave Hoover
"Twice blessed is help unlooked for." --Tolkien
http://www.redsquirreldesign.com/dave

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



Re: "the right way"

2001-07-09 Thread dave hoover

Matija wrote:
> I'm curious which of the two examples is more
> preferred or it depends
> entirely on someone style? 
> 
> $x = 1;
> 
> #1)
> if ($x) { $x = 0 }
> #2)
> $x = 0 if $x;
> 

I think it's a matter of style, but also one should
consider who will be maintaining this code in the
future and whether they will be familiar with Perl or
if they will have a more general CS background.

if ($x) { $x = 0 }
is definitely more traditional and easily recognizable
by non-Perl programmers.

$x = 0 if $x
reads more naturally for some (like me) and has a
nicer look (to me) because there are less brackets.

=
Dave Hoover
"Twice blessed is help unlooked for." --Tolkien
http://www.redsquirreldesign.com/dave

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



Re: "the right way"

2001-07-09 Thread dave hoover

Paul wrote:
> On Mon, Jul 09, 2001 at 09:44:57AM -0700, dave
> hoover wrote:
> 
> > I think it's a matter of style, but also one
> should
> > consider who will be maintaining this code in the
> > future and whether they will be familiar with Perl
> or
> > if they will have a more general CS background.
> 
> You know, I've never liked this argument.  Why
> should I assume that
> someone who will be maintaining my code is less than
> competent to do the
> job?  Why should some parts of the language be off
> limits because they
> are deemed "too difficult" for someone who doesn't
> know the language.
> Maybe by using the language well I can help this
> maintenance programmer
> to master it.
[snip]

I think trying to stretch the audience to facilitate
learning is good practice, but you need to consider
your audience when deciding how _much_ you can stretch
them. A competent Perl developer needs to choose
his/her tools carefully. Although, s/he _could_ use a
chainsaw to solve a given problem easily, there are
times when a handsaw is preferable. For an audience
that is still using a hatchet, a chainsaw would be
overwhelming and sometimes dangerous.

Of course, a developer does not always know who their
audience is...and in those situations, I'd just use
the dang chainsaw!

=
Dave Hoover
"Twice blessed is help unlooked for." --Tolkien
http://www.redsquirreldesign.com/dave

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



Re: How do I set @INC?

2001-07-11 Thread Dave Hoover

Michael wrote:
> I have a couple of PERL installations on my system.  How do I point perl
at
> the correct set of modules?  I tried setting @INC inline in my program,
but
> that did not work.

You can use the path the Perl installation you want to use in your shebang.
Here's an example:

#!/apps/perl/5.6.0/bin/perl

Just remember that if you're trying to test the script from the command
line, rather than typing:

%  perl 

instead you would type

%  /apps/perl/5.6.0/bin/perl 

HTH

=
Dave Hoover
"Twice blessed is help unlooked for." --Tolkien
http://www.redsquirreldesign.com/dave





Re: How do I set @INC?

2001-07-12 Thread Dave Hoover

Jos wrote:
> the whole point to setting a shebang is so you *dont* have to type
> /foo/bar/yada/quux/some/more/blah/perl

There is another imporant reason to set the shebang...CGI.

> you can, if on *nix (DOSneyland will ignore the shebang), say:
> /script

You can do this, but make sure you have set the permissions to allow it to
be executed.

> now, if you're in DOSneyland, like mentioned above, setting the shebang
has
> little effect, other then switches passed to the interpreter, ie:
> #!c:\perl\bin\perl -w
>
> will cause perl to run under -w, but does little for you in terms of
> choosing the correct interpreter for the script.

I'm basically ignorant about perl in windows.  This is good to know.

Thanks for clearing things up.

=
Dave Hoover
"Twice blessed is help unlooked for." --Tolkien
http://www.redsquirreldesign.com/dave





RE: multiple entry/exit points

2001-07-12 Thread Dave Newton

Kurt Edmiston said:
> Coming from C++-land, I've always been taught over and over again
> that all subroutines/functions/blocks/etc should have only a single
> entry point and a single exit point.

Works great in theory ;) Especially if you have exceptions.

It's just not practicle/readable to always code like that in real life,
though. I would tend to reserve such things for block-local catastrophes,
however; if the block ever gets modified an early return might screw
something else up.

> I still adhere strictly to the "one way in, one way out" philosophy,
> mainly for the sake of readability.

Yowzah-I've found that w/o exceptions that having a wad of nested if's/etc.
tend to make things _more_ unreadable.

> Also, I was wondering if exiting prematurely like this from a program has
> any adverse affects on the execution of the program.

It'll stop the program ;)

Dave




Re: IO::Socket:INET and broadcasting

2001-07-12 Thread Dave Watson

--Papo Napolitano <[EMAIL PROTECTED]> [010712 21:37]:
> Hi, this is my first post, so don't blame me (too much) if i'm posting to
> the wrong list.
> I'm working on a very simple client/server program in Perl... A server
> broadcasts udp packets with some info that a couple of clients then
> collect & display.
> Well, could anyone tell me what's the mistake in the following piece of
> code?
> 
> ---
> use strict;
> use IO::Socket;
> my ($sock, $portno, $serverhost);
> $portno = 11666;
> $serverhost = "255.255.255.255";
> $sock = IO::Socket::INET->new(
> Proto => 'udp',
> PeerPort => $portno,
> PeerAddr => $serverhost) or die "IO::Socket::INET -> $!\n";
> ---
> 
> Because it works ok under Cygwin but gives me a "permission denied"
> error in Mandrake 7.2
> Any clue?

If you are trying to open a socket < 1024 you must have root privileges.

-- 
Dave Watson



Re: removing white spaces

2001-07-17 Thread dave hoover

javier wrote:
> It sounds a bit stupid but I don't know the way to
> remove white spaces in a
> string.
> 
> $string = "No sé como quitar los putos spacios";
> and now?

$string =~ s/ //g;

Here's one way to do it.

=
Dave Hoover
"Twice blessed is help unlooked for." --Tolkien
http://www.redsquirreldesign.com/dave

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Removing spaces

2001-07-19 Thread Dave Neill

There's also:

$foo =~ s/^\s*//;

and if you want to strip leading and trailing spaces:

$foo =~ s/^\s*(.*?)\s*$/$1/;

Though some say that the two step:

$foo =~ s/^\s*//;
$foo =~ s/\s*$//;

is faster. There's also a module:

String::Strip

with a function

StripLTSpace()

and it's fore and aft variants that purports to be faster than the regex
substitution.  I haven't done any testing to verify performance on any of these.

Dave

A simple Q
well i want to remove spaces if any in the beginning and end of a string.
how to do this...

..



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Code Review Needed!

2001-06-29 Thread dave hoover

At the suggestion of a few people I've converted the
program into text files to make things easier for
reviewers.  Here are the four files:

http://www.redsquirreldesign.com/soapbox/Soapbox.pm.txt
http://www.redsquirreldesign.com/soapbox/main.txt
http://www.redsquirreldesign.com/soapbox/soap.txt
http://www.redsquirreldesign.com/soapbox/soapbox.conf.txt

I am particularly interested in feedback about: 
  Any common newbie blunders you may find 
  Security issues 
  Specific areas where the code could be more
efficient 
  A critique on my use of object-oriented Perl 

The feedback I have received thus far has been very
helpful. It's been a learning
experience...particularly about taint checking!

Thanks,

--Dave


--- dave hoover <[EMAIL PROTECTED]> wrote:
> I would greatly appreciate ANY feedback anyone could
> provide. The following page will provide details and
> a
> link to download the tarball.
> 
> http://www.redsquirreldesign.com/soapbox
> 
> TIA
> 
> 
> =
> Dave Hoover
> "Twice blessed is help unlooked for." --Tolkien
> http://www.redsquirreldesign.com/dave

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



Code Review Needed!

2001-06-28 Thread dave hoover

I would greatly appreciate ANY feedback anyone could
provide. The following page will provide details and a
link to download the tarball.

http://www.redsquirreldesign.com/soapbox

TIA


=
Dave Hoover
"Twice blessed is help unlooked for." --Tolkien
http://www.redsquirreldesign.com/dave

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



Re: y me

2001-08-03 Thread Dave Hoebe

Hi Peter,

Are you trying to make a CGI script ? in that case try putting:

print "Content-type: text/html\n\n"; before the first print statement.

a good idea when writing scripts would be using the -w flag after
#!/usr/bin/perl, this flag enables a more verbose error output. Could be
handy troubleshooting :)

Good-luck Dave

- Original Message -
From: "Peter" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, August 02, 2001 2:34 AM
Subject: y me


> hi all,
>
>  i have a new script that i put in the same directory as
> other working scripts, however when i try to execute
> i keep getting a "cgiwrap error: execution not permitted
> ...script file not found"
>
> any ideas?
>
> thanks,
> pete
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: a little help here please

2001-08-08 Thread Dave Newton

I'm continually surprised by the information-free subject headers. Most
people
that start a new thread here need help; that's why they're here. Not
flaming,
just hoping that people will take into account the potential usefulness of
subject lines (i.e., "Oooo, I know how to do that!" or "Oooo, I need to know
how to do that too!" etc.)

> I have a script that does a bunch of things, one of which parses a large
> amount of log files every cycle through the script, what would I need todo
> to the script to only parse the logfiles every 5 minutes ; yet not
impacting
> the rest of the script?

Somebody suggested "sleep" which would impact the rest of the script. That
might lead me to think that the logfile portion of the script should be
removed as it is a script of a different color.

Another option would be to store a time somewhere and at every script
iteration check to see if "enough" time has passed to process the logfile
portion of the script again.

I like the first idea better-separate out the oddball and either cron
(*nix),
schedule (etc.), or sleep (any) it.

Dave


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Frustrated installing modules!?!

2001-08-08 Thread Dave Newton

> Still no dice! I keep getting errors:
>
> C:\Perl>ppm
> PPM interactive shell (2.1.5) - type 'help' for available commands.
> PPM> set
> Commands will be confirmed.
> Temporary files will be deleted.
> Download status will be updated every 16384 bytes.
> Case-insensitive searches will be performed.
> Package installations will continue if a dependency cannot be installed.
> Tracing info will not be written.
> Screens will pause after 24 lines.
> Query/search results will be verbose.
> Current PPD repository paths:
> ActiveState Package Repository:
> http://ppm.ActiveState.com/cgibin/PPM/ppmserver.pl?urn:/PPMServer

Hola,

This probably won't be helpful as I don't know how to go about changing it,
but that
isn't what I get when I do the same thing.

--- Here's what I get ---
PPM> set
Commands will be confirmed.
Temporary files will be deleted.
Case-insensitive searches will be performed.
Package installations will continue if a dependency cannot be installed.
Tracing info will not be written.
Screens will not pause.
Query/search results will be verbose.
Current PPD repository paths:
ActiveState Package Repository:
http://www.ActiveState.com/PPMPackages/5.6
Packages will be built under: C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp
PPM>
--- There's what I got ---

Also, some packages have associated C source that has to be compiled. In
order to
do that, you need to have J. Random C Compiler, which generally includes a
make-like
utility, which in uSoft's case is (or at least was) nmake, which is why that
shows up.

Dave


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Reading backwards

2001-09-02 Thread Dave Arnold

In message <000501c13230$50f00210$[EMAIL PROTECTED]>
  "Louis-Philippe Dextraze" <[EMAIL PROTECTED]> wrote:

[snip]
> 
> 
> open FICMSG, "<$logfile" or print "problem opening log file.";
> 
> $i=0;
> while(!(eof FICMSG))
> {
> $msg[$i] = ;
> $_ = $msg[$i];
> if ($i < 40)
> {
> $i++;
> }
> else
> {
> $i=0;
> }
> }
> 
> for($i = 0; $i <= $#msg; $i++)
> {
> print "Error $i:$msg[$i]\n";
> }
> 
> 
> 
I'm not sure this code is doing what you think it is!
If your log is not exactly divisible by 40 then the order
of the lines in the array will not be the same as that in
the file. You should be doing something like:

while (  )
{
  if ( @msg == 40 )
  {
 shift @msg;
  }
  push(@msg,$_);
}

> 
> My question is...can we read the file backwards.
> If I could set the reading pointer to the end
> of the file and then work my way back 40 entries.
> and print...now that would make my day.
> 
> anyone know of a way?

There is a module on CPAN for doing just this sort of thing:

  http://search.cpan.org/search?dist=File-ReadBackwards

Dave.
-- 
No, the fact that it's an infinite loop doesn't mean the program doesn't
work; it just entered a state with which I was previously unfamiliar.
 Calum - Acorna, A.McCaffrey & M.Ball
   http://www.caledvwlch.co.uk/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Passing variables to subroutines

2001-04-28 Thread Dave Watkins

Hi All

I am trying to pass a variable, a hash table and an array into a subroutine 
like so

subroutine($variable, %hash, @array);

and pick it up like so

sub subroutine {
my($variable, %hash, @array) = @_;

but it seems the array isn't being passed, I can print the contents of the 
array before the sub is called but if I try to print it from within the sub 
I get nothing. The other 2 are being passed fine. If it makes any 
difference the sub is in another file, but "require" is being used.

Thanks




Re: Passing variables to subroutines

2001-04-28 Thread Dave Watkins

Works like a charm

Thanks


At 09:57 PM 4/28/01 -0500, you wrote:
>-BEGIN PGP SIGNED MESSAGE-
>Hash: SHA1
>
>On Sun, 29 Apr 2001, Dave Watkins wrote:
>
> > Hi All
> >
> > I am trying to pass a variable, a hash table and an array into a subroutine
> > like so
> >
> > subroutine($variable, %hash, @array);
> >
> > and pick it up like so
> >
> > sub subroutine {
> >   my($variable, %hash, @array) = @_;
> >
> > but it seems the array isn't being passed, I can print the contents of the
> > array before the sub is called but if I try to print it from within the sub
> > I get nothing. The other 2 are being passed fine. If it makes any
> > difference the sub is in another file, but "require" is being used.
> >
> > Thanks
>
>It is being passed, it's just mashed into the hash because Perl doesn't
>know where the hash stops and the array begins.
>
>You have to use references with hashes and arrays, especially if you have
>more than one of either, or a scalar after them...
>
>Try subroutine($variable, \%hash, \@array);
>
>and pick it up as
>sub subroutine {
>   my($variable, $hashref, $arrayref) = @_;
>   my %hash = %$hashref;
>   my @array = @$arrayref;
>
>That should work.
>
>- --
>Curtis Jewell  http://curtis.livejournal.com/
>[EMAIL PROTECTED]  http://web.missouri.edu/~csjc05/
>[EMAIL PROTECTED] http://new-york.utica.mission.net/
>Public Key: http://web.missouri.edu/~csjc05/curtis.key.txt
>
>-BEGIN PGP SIGNATURE-
>Version: GnuPG v1.0.4 (GNU/Linux)
>Comment: For info see http://www.gnupg.org
>
>iD8DBQE664MpNGcErwayIw4RAoaZAJ4q21IgbO4xLGW2PInF/52QYG0gQwCgl6jC
>NX4KGnraZoZRJK/UeMNG/HA=
>=teo/
>-END PGP SIGNATURE-




RE: installing perl

2001-05-30 Thread Dave Runkle

Hi Gil, can you give some more info? Did you get the right file from
www.ActiveState.com? In most cases it should be the one on their website
that says "MSI" in the downloads section. What platform are you using?
Win98? NT? ME? 2000? 

If you did get the right file, how far did you get? It should be as easy
as hitting the file with your mouse and following the instructions.
Select all the options, make sure all the check-boxes are checked. It's
best to put it in the C:\Perl directory so you don't have to fight
spaces in the filenames. Did you have problems with error messages? 

Let us know how it goes, it should be an easy install, so give some more
info so we can help diagnose.
Dave

> -Original Message-
> From: Gil Tucker [ateliermobile] [mailto:[EMAIL PROTECTED]] 
> Sent: Wednesday, May 30, 2001 1:10 AM
> To: [EMAIL PROTECTED]
> Subject: installing perl
> 
> 
>Hi everybody,
> Does anybody knows the fastest and 
> easiest way tzo
> install Perl on
> a Windows system? This might seem trivial but after many 
> trials. It seems to
> be a major
> task for me. I would happy to hear from the community on 
> getting Perl on a
> hard disk.
> Greetings gil
> 
> 




RE: perl ping script using cgi

2001-06-01 Thread Dave Palmer

Hello,
Your working script is *definitely* the way you want to go... its generally
a no-no to ever give user 'nobody' (e.g. web server) access to your shell
(which is what is happening with the system() call).

In fact, I wouldn't be surprised if the sys admin. doesn't allow user
'nobody'
to do much of anything :)

./dave

> -Original Message-
> From: Mohan Kompella [mailto:[EMAIL PROTECTED]]
> Sent: Friday, June 01, 2001 4:42 PM
> To: [EMAIL PROTECTED]
> Subject: perl ping script using cgi
>
>
> Hello all,
>
> I was trying to write a cgi-script that displays the results of a ping
> against a host that is passed to the cgi-script. The first time,
> I used what
> I might term the "brute force approach", which didn't work and
> then, I used
> Net::Ping, which worked. However I am really curious as to why the first
> approach didn't work
>
> For each script below, the URL that would call the script [btw, all
> resemblances of these script structures to a certain CGI scripting example
> from 'Learning Perl' are entirely coincidental :) ] was:
>
> http:///cgi-bin/myping?Node=Atlantis
>
> Working script
> --
>
> #!/usr/local/bin/perl -w
> use CGI qw(param);
> use Net::Ping;
>
> print< Content-type: text/html
>
> 
> 
> Result of "Ping" Operation
> 
> 
> Section1
>
> $pnode = param("Node");
> $p = Net::Ping->new();
> if($p->ping($pnode)) { print "\n\n $pnode is alive\n"; }
> else { print "\n\n$pnode is not reachable \n\n"; }
> $p->close();
> print<
> 
> 
> Section2
>
> --> What I don't like about the above script is that I cannot see the
> results of each individual ping, which was I was hoping to see using the
> (non-working) script, below:
>
> Non-working script
> --
>
> #!/usr/local/bin/perl -w
> use CGI qw(param);
> use Net::Ping;
>
> print< Content-type: text/html
>
> 
> 
> Result of "Ping" Operation
> 
> 
> Section1
>
> $pnode = param("Node");
> system "(/usr/sbin/ping -sRv -I 1 $pnode 64 5)>/tmp/pingresults.$$";
>
> # *** I could never see /tmp/pingresults.$$ created, above, when
> the script
> was called.
> # However when I executed what was within the system call from the shell
> directly, there were no problems, obviously !!!
>
> open(INFILE,"/tmp/pingresults.$$");
> while() {
> print;
> }
> close(INFILE);
> print<
> 
> 
> Section2
> #
>




RE: perl ping script using cgi

2001-06-01 Thread Dave Palmer


Also... -T can be your friend, espcially with CGI

./dave

> 
> Dave Palmer wrote:
> 
> : Your working script is *definitely* the way you want to go... 
> its generally
> : a no-no to ever give user 'nobody' (e.g. web server) access to 
> your shell
> : (which is what is happening with the system() call).
> 
> I wouldn't be so restrictive about it; sometimes it's necessary 
> to launch a
> subprocess.  You just need to know how to do it without opening a 
> shell. The
> given example:
> 
> : > system "(/usr/sbin/ping -sRv -I 1 $pnode 64 5)>/tmp/pingresults.$$";
> 
> is bad bad bad because it opens a shell to run the command. (Hint:
> What does the argument to system() look like if someone enters a $pnode
> of "foo; rm -rf *"?)
> 
> This can be avoided by calling the a) not having any shell
> metacharacters, like () and >, in the command line, and b) passing the
> command and command-line options to system() or exec() as a list
> instead of a string.  Here's a safer example:
> 
> open PINGRESULTS, ">/tmp/pingresults.$$" or die $!;
> open PING, "-|" or exec "/usr/sbin/ping", "-sRv", "-I", "1", 
> $pnode, 64, 5);
> while () { print PINGRESULTS; }
> close PING;
> close PINGRESULTS;
> 
> Wordier, but safer, because the exec() doesn't open a shell to run the
> command. (Yes, I know ">/tmp/pingresults.$$" does open a shell, but the
> only variable in it is the process ID, and that's not coming from
> outside the script, so it would pass a taint check.)
> 
> : In fact, I wouldn't be surprised if the sys admin. doesn't allow user
> : 'nobody'
> : to do much of anything :)
> 
> 'nobody' is usually defined not to have a default shell, valid 
> group id, etc.
> That doesn't mean, though, that it shouldn't be allowed to 
> interact with the
> system when it needs to. You can't write everything in Perl. ;)
> 
> -- tdk



RE: RE: Records put into a hash - Beginner Question

2001-06-04 Thread Dave Newton

>> (Original two choices)
>> : Is it better to :
> > : 
> > : %Fields = %{$Accts{$account}};
> > : foreach $name ( keys %Fields ) {
> > :   print "$name : $Fields{$name}\n";
> > : }
> > : 
> > : or 
> > : 
> > : foreach $name ( keys %{$Accts{$account}} ) {
> > :   print "$name : \n";
> > : }

> I would actually prefere the first way, since each level of indirection 
> in the second call adds an overhead on performance, nothing major, but 
> in a simple case like this, i dont' see any reason why it shouldn't be 
> eliminated.

My impression was that the keys function returned a list, so that
the second option would loop through said list assigning $name to
each key.  

Wouldn't that make the second option "better" using your criteria
of less indirection? Instead of doing any indirection inside the loop
it's handled in the key list generation.

Am I totally hosed on how I thought this worked?

Dave




RE: Anyone know to how use subroutines to add or multiply numbers :How would I modify my file:

2001-10-18 Thread Dave Storrs



On Wed, 17 Oct 2001, AMORE,JUAN (HP-Roseville,ex1) wrote:

> #!/usr/bin/perl -w
> my $function = shift @ARGV; 
> 
> if( $function =~ /add/ ) {
>   $rtn = add( @ARGV ); 
>   print "The sum is :$rtn";
> }
> elsif( $function =~ /multiply/ ) {
>   $rtn = multiply( @ARGV );
>   print "The product is :$rtn";
> }
> 
> sub add {
>   my @list = @_; 
>   my $sum = 0;
>   $sum += $_ foreach (@list); 

}   # <= This was missing

> 
> sub multiply {
>   my @list = @_;
>   my $prod = 1;
>   $prod *= $_ foreach (@list);
> }


Dave Storrs


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: XMLParser and Perl

2001-10-18 Thread Dave Storrs

Go to http://search.cpan.org/ and type "XML" into the search box.  There
are a whole bunch of XML modules that will make your life much easier.

In general, "go to CPAN and look for a module" is the answer to most
problems in Perl...the number of modules is HUGE, and no matter what you
need, there is probably a module that can help.  Always check CPAN before
writing it yourself.

Dave


On Thu, 18 Oct 2001, Trent A Stephens wrote:

> I (a beginner in Perl) am looking for guidance on XML and Perl.  I am
> having to read in an XML file, parse it for specific information (MIME
> type, attributes and values), write the attributes/values to a hash (I am
> assuming) and then use win32::OLE to persist the attribute/vlaues to the
> custom properties of a Word or Excel document.
> Also it would be nice to beable to determine the number of attribute/value
> pairs in the XML file so as to presize the hash table.
> Are there any example out there or code I can use to get a good start to
> speed up my learning curve? There is a slight time constraint I am working
> with.  
> 
> Thanks in advance
> 
> Trent
> 
> 
> 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Unable to display output

2001-10-18 Thread Dave Storrs



On Wed, 17 Oct 2001, nafiseh saberi wrote:

> in perl ,
> if u want see in screen must write :
> print "\n";
> before things you want to to print.
> I mean that you must print one empty line and then
> print things u wants
> __
> Best regards . Nafiseh Saberi


Um, what?  Maybe I'm misunderstanding you, but it simply isn't
true that you must print an empty line before you can print data to the
screen.  Here are two ways to prove this to yourself:

>From the command line:
perl -e 'print "Hello, World!"';

Or, put the following in a file:
#!/usr/bin/perl 
print "Hello, World!";

Make sure execute permissions are set on the file, then run the file.

You will notice that neither of these examples includes a newline
("\n") anywhere, yet they still print to the screen.


Dave


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Very Urgent...

2001-10-19 Thread Dave Newton

> Where can I get more information on How to test(QA) Website 
> or client server application using Perl-win32::GuiTest.

My understanding was that win32::guitest was for testing
windows applications, not websites?

Dave


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Need help with deleting from hash table

2001-10-20 Thread Dave Turner

First off, thanks to all who offered help with my trying to count the 
number of items passed in a CGI script. I finally figured out I had my 
logic wrong and it doesn't matter how many element's I'm passing, but...

My problem now is that I can't get items deleted from a hash table.

My code is as follows:

 for ( $i=0;($i < $FORM{'count'}); $i++)
 {
  my $place="d".$i;
  if ( $FORM{$place} eq 'off' )
{
 # We've matched a check box and a hash so delete it
 delete ( $location{$place} );
}
 }

It's fairly straightforward here. If the value of the CGI passed is off, 
then I match it against the hash table. The keys in the hash table are d0, 
d1, d2, etc... which correspond to the CGI  names passed.

So if (d0 eq 'off') for example I want to delete the hash table value with 
the key of d0.

However it isn't doing it and I am pulling my hair out trying to figure out 
why.

Any help would be really appreciated here!

TIA!



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Need help with CGI module

2001-10-28 Thread Dave Turner

I have scanned the docs and can't seem to find the answer to this anywhere.

I want to change the color of the text and the font size on a web page 
using CGI:pm.

my code looks like:

$q->h2( "Something witty here");

but I'd like to have the flexibility to do 

Can anyone point me to a reference with this info or just post it?

TIA!



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: off topic - javascript question

2001-10-29 Thread Merritt, Dave

I believe the format of the javascript open method should be:



Also, you don't need to put the  tags around the <body> tag

Dave Merritt
[EMAIL PROTECTED]

-Original Message-
From: [EMAIL PROTECTED] [<A  HREF="mailto:[EMAIL PROTECTED]">mailto:[EMAIL PROTECTED]</A>]
Sent: Sunday, October 28, 2001 11:53 AM
To: [EMAIL PROTECTED]
Subject: off topic - javascript question


I want to have a window loaded when someone leaves my website.
does anyone know what is wrong with the following code?
Thanks!

<script>
<BODY onUnload=open("exit.htm",   "scrollbars=yes,width=250, height=400")>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Problem using IF with AND

2001-10-29 Thread Dave Turner

I think ( and there's plenty who will tell you if I'm wrong... lol ) that 
you need to put it as:

if (($client ne $newclient) && ($method ne $newmethod)) {
 // blah blah blah
}

Otherwise I think it doesn't bother to look at the second if the first fails.

Hope that helps.

At 10:28 PM 10/29/01 -0600, you wrote:
>If I were you, I'd try using && instead of "and" in your if loop:
>if ($client ne $newclient && $method ne $newmethod) {
> // blah blah blah
>}
>
>I'm not even sure if that will work in perl.  Who knows.
>
>Good luck,
>Tyler Longren
>
>
>On Mon, 29 Oct 2001 08:33:42 -0700
>"Earthlink" <[EMAIL PROTECTED]> wrote:
>
> > The program I'm writing (my first in Perl) takes a log file and using a
> > regex pulls out all lines that contains certain words and writes them to
> > a
> > file.  Then I read in that file, seperate out the fields I want (IP
> > address
> > and method), and want to eliminate the duplicates, and add a count to
> > show
> > how many there were.  I'm evaluating string variable against each other
> > for
> > instance:
> >
> > if ($client ne $newclient and $method ne $newmethod){
> > print "something\n";#I'll actually
> > be
> > printing this to my report once I get this worked out
> > }
> >
> > Then at the end of each loop I add the values of the strings I pulled
> > out of
> > each line to my $new... variables and loop again.
> >
> > Problem is that this seems to work for only the first set of variables
> > and
> > ignores the ones after the "and".  For instance $method could be either
> > CMD.EXE or ROOT.EXE.  Any ideas?  I added a line of code to show what
> > the
> > strings $newclient and $newmethod contain at each loop and it is
> > correct, so
> > I'm a little confused.
> >
> > Thanks
> > Kurt
> >
> >
> >
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
>
>--
>+--+
>|   Tyler Longren  |
>| Captain Jack Communications  |
>|[EMAIL PROTECTED] |
>| www.captainjack.com  |
>+--+
>
>--
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Access MS SQL using DBI / DBD

2001-11-01 Thread Dave Storrs


Hi Pathi,

There is an excellent book from O'Reilly _Programming the Perl
DBI_.  It has a leopard on the cover, and it should answer every question
you could possibly desire concerning the DBI.

HTH,

Dave


 On Tue, 30 Oct 2001, Erramilli, Pathi (P.) wrote:

> Hi,
>
> I am new to perl...I am trying to use DBI / DBD to access MS SQL database and I 
>cannot find any documentation/help.
>
> What I need to do is to login to the SQL server and get the database space 
>details.(MS SQL 7.0 & 2000)
>
> Can someone help...Thanks in advance.
>
> Pathi
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: merging two hashes together?

2001-11-03 Thread Dave Storrs


In the example you provide, this will work:

-START
%h1 = ("one" => 1, "two" => 2, "three" => 3);
%h2 = ("four" => 4, "five" => 5, "six" => 6);

#  Note that the '&' on function calls is optional, unlike $, @, and %
$ref_h3 = mergehash(_, _);

sub mergehash {
my ($rh_first, $rh_second) = @_;

{ %$rh_first, %$rh_second };  # POINT A
}
-FINISH

The line labelled 'POINT A' does all the work:  it constructs a
new, anonymous hash reference, initializes it, and (since it is the last
value in the function) returns it.  Basically, we dereference the two hash
references back into hashes, unroll them into lists of key/value pairs,
and use them to initialize the new hash we are building.

Note, however, that if %h1 and %h2 share any keys in common will
end up with the value of whichever hash you list LAST in the hashref.
This problem is without solution within the parameters given; no matter
what you do, Perl's builtin hash type cannot have duplicated keys, and no
key may have more than one value.  Now, you can get around it in a LOT of
ways...you can use array references to store your values (meaning that one
key can hold as many values as you want, hidden inside the array ref),
and/or you can use fancy object-oriented magic to make a magical data
structure that pretends to be a hash but can have duplicate keys.

HTH,

Dave

On Sat, 3 Nov 2001, AMORE,JUAN (HP-Roseville,ex1) wrote:

> Hello Perl Gurus,
> I'm trying to write a program that will merge two hashes together onto a
> third hash called %h3. I need to
> return a reference to %h3 to the main program and print each of the values
> of the hash %h3 using the arrow notation.
> Name of the actual function performing the merge mergehash.  Pass %h1 and
> %h2 to mergehash as references.
> The function call in the main program will be something like the following
> where $ref_h3 will be used to print the values in %h3.
>
>   $ref_h3 = &mergehash(_, _);
>
> %h1   = ("one" => 1, "two" => 2, "three" => 3);
> %h2   = ("four" => 4, "five" => 5, "six" => 6);
>
>
>
> Many Thanks!!!:)
> JA
>
>
>
>
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: HOw do I create a package:

2001-11-03 Thread Dave Storrs


With all due respect, this list is here to help beginner perl programmers
deal with programming problems, not to do people's homework for them.
(The 'hp.com' address (which prominently dispalys an ad for "hp's online
university") is a bit of a giveaway.)

Read this:  perldoc perlmod

Dave


On Sat, 3 Nov 2001, AMORE,JUAN (HP-Roseville,ex1) wrote:

> Hello,
> CAn anyone show me how to create a package called StringPrint and place this
> package in a filename called StringPrint.pm using a subroutine, called
> print_str, that prints a string passed to the subroutine defined by the
> module.
>
> Many Thanks!
> JA
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




OT: dB pooling in Perl (was Re: Perl with Java)

2001-11-04 Thread Dave Storrs

On this subject:  I am currently trying to sell Perl in my (highly
Java-biased) shop, and having an uphill battle of it.  One of the things
that the brass wants to see is support for database connection pooling in
a multi threaded environment.  Now, I'm sure that Perl can do this, but it
isn't something I've done before, so I don't have a ready answer on where
to look.  Mason?  I know that version 2 of Apache/mod_perl will provide
this, but that isn't out yet and who knows when it will be.  Any
suggestions on where else to look?

Dave

On Sat, 3 Nov 2001, Greg Meckes wrote:

> We use Perl and Java in our shop. I'm the Perl guy and I haven't encountered any 
>situation where I
> couldn't code up something to do same thing that the Java apps do.
>
> That's not to bring into it any 'preference' of one language over the other as they 
>both have
> their usability goods and bads.
>
> We experience a variety of problems using Java because of it's security lockdown 
>coding style -
> which is a good thing - but makes for longer dev/debug time.
>
> It's easy to code things up in Perl and get them to do the same thing.
>
> These issues came be overcome I'm surebut this is what we have been facing.
>
> greg
>
> --- pc <[EMAIL PROTECTED]> wrote:
> > How widely is Perl Used in Java Shops?
> >
> > Pc
> >
> > _
> > Do You Yahoo!?
> > Get your free @yahoo.com address at http://mail.yahoo.com
> >
> >
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
>
> __
> Do You Yahoo!?
> Find a job, post your resume.
> http://careers.yahoo.com
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: regexp with $ARGV

2001-11-04 Thread Dave Storrs

Martin,

I'm not entirely clear on what you're trying to do here, so if
this doesn't help, let me know and I'll try again.

I think the problem is that you're doing this:

s/$ARGV[0]/\($ARGV[0]\)/g

...when you want to affect $ARGV[0].  But remember that s/// and
m// are, by default, applied to the contents of the $_ variable.  So, when
Perl sees that line of code above, it effectively rewrites it to be:

$_ =~ s/$ARGV[0]/\($ARGV[0]\)/g;

Which, in English, means something like this:

"Go through the string stored in the $_ variable.  Look for a substring
which is identical to the string stored in $ARGV[0].  If you find it,
replace it with that same string with parens around it.  Finally, because
there is a 'g' option on the operation, do not stop after finding the
first match; continue through the contents of $_ and replace any other
matches you find."

I think what you want instead is this:

$ARGV[0] = "($ARGV[0])";


Dave

 On Sun, 4 Nov 2001, Martin Karlsson wrote:

> Could anyone please show me the way to think here?
>
> If I execute a script with an argument, e.g monkey, then monkey will be
> found in $ARGV[0]. If I then want to highlight the word monkey by
> putting it in parentheses, i thought something like
> s/$ARGV[0]/\($ARGV[0]\)/g
> would do the trick; however it won't.
>
> Thanks,
> --
> 
> Martin Karlsson   [EMAIL PROTECTED]
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




(Slightly OT) RE: terminating input

2001-11-04 Thread Dave Storrs



On Sun, 4 Nov 2001, Gary L. Armstrong wrote:

> I am amazed. How does someone figure out that you can do this sort of thing?
>
> chomp($value[++$i] = );
>
> I mean, $value[++$i]?  That really works?  Crazy.  [...]


Well, that's mostly a C-style issue (and yes, it is crazy).  C
programmers, for some bizarre reason, are convinced that there is a
tremendous shortage of whitespace in the world, and so, rather than
contribution to the death of the Old Growth Whitespace forests, they will
go to incredible lengths to jam things onto one line.  Personally, I have
this thing for clarity.  In my not-even-marginally-humble opinion, a line
of code should do one thing and one thing only (ok, sometimes I stretch a
point and do two things, if it is efficient and idiomatic).  In
particular, I have always despised the "increment a variable inside an
array index" idiom in C. Therefore, I would have written it as:

;
chomp;
$i++;
$value[$i] = $_;

Some people say "Oh no! Look at that!  You took up 4 lines where only 1
was needed!  Shame on you!  Gasp, horror, collapse in revulsed
convulsions."  To which I shrug.  They always thank me later, when they
need to maintain my code.

Rant mode off.  We know return you to your regularly scheduled list.

Dave



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Off-Topic (200%) - Where are you from?

2001-11-10 Thread Dave Turner

At 06:48 PM 11/10/01 +0100, you wrote:
>Hi,
>Smauel Molina Vidal
>Industrial Engineer student @ University of Seville, Seville, Spain
>(quite far from the west coast :-)

San Mateo, CA --Very west coast... :-)



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: regexp with $ARGV

2001-11-08 Thread Dave Storrs




On Mon, 5 Nov 2001, Martin Karlsson wrote:

> Thanks a lot for your help and your time! I think I've got it solved
> now.

You're welcome. :>


> Could any of you recommend a good book for (learning) Perl? There seems
> to be quite a few to choose from...

Oddly enough, that's what it's called:  _Learning Perl_
http://www.oreilly.com/catalog/lperl3/

It's by Randal Schwartz & Tom Phoenix.  The target audience is
people who already have basic programming knowledge and just need to learn
Perl.  However, I've heard people say that it also served as a good
introduction to programming in general.

Dave


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: vars as key/value in a hash

2001-11-09 Thread Dave Storrs



FYI, Tyler, the reason that this will do what you want is because you're
original program wasn't doing what you thought.

 %stations = (  $names[0] => $names[1] );

This creates a list of two elements and assigns it to the hash named
%stations.  Therefore, $names[0] becomes the one and only key in %stations
and $names[1] becomes the one and only value.  If %stations did not exist
before, it does exist now; if it _did_ exist, then its former values are
wiped out.  That's the key point...every time you went through the loop,
you were wiping out all the previous data you had read in, so the table
only ever contained one key and one value.  Therefore, since (I assume)
'alta_guard' was not the last entry in the file you were reading from, it
did not appear in the table when you were finished.  Notice that Brett's
version saves the values from one iteration of the loop to the other,
because you aren't reinitializing the hash.

HTH,

Dave


On Thu, 8 Nov 2001, Brett W. McCoy wrote:

> On Thu, 8 Nov 2001, Tyler Cruickshank wrote:
>
> > open(NAMES, "d://perl/avalanche/names.txt") || die "Cant open names.txt\n";
> >
> > while(){
> >   chomp;
> > @names = split(/-/);
> >
> > %stations = (  $names[0] => $names[1] );
> > @names = ();
> >
> >   } # End while.
> >
> > $table = 'alta_guard';
> > print "Text: $stations{$table}\n";
>
> I would do it like this:
>
> %stations = ();
> open(NAMES, "d://perl/avalanche/names.txt") || die "Cant open names.txt\n";
>
> while(){
>  chomp;
>  @names = split(/-/);
>  $stations{$names[0]} = $names[1];
>} # End while.
>
> $table = 'alta_guard';
> print "Text: $stations{$table}\n";
>
> -- Brett
>   http://www.chapelperilous.net/
> 
> To give happiness is to deserve happiness.
>
>



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: SecureCRT + Perl

2001-11-09 Thread Dave Storrs


Um...not sure what you're asking for here.  I use SecureCRT all the time
(using it right now, in fact), and I do in fact write Perl while securely
telnetted into various machines.  What do you want to do?

Dave


 On Thu, 8 Nov 2001, A. Rivera wrote:

> Has anyone tried to use SecureCRT with Perl?  If so, any examples scripts
> that interact with a shell, etc.?
>
> Much appreciated,
> A.Rivera
>
>
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: installing modules

2001-11-09 Thread Dave Storrs



Since I suspect your next question would be "Ok, then how do I install the
CPAN module?" let me head this one off.

The CPAN module (CPAN.pm) comes with the basic distro of Perl, so you
should already have it.  Say you want to install the "CGI.pm" module from
CPAN.  At your command line, you type:
perl -MCPAN -e 'install CGI'
The -MCPAN means "use a module (-M), specifically, CPAN.pm".  The -e means
"the script will be specified on the command line."

If this is the first time you've ever used CPAN, it will need to ask you a
LONG set of questions...don't be intimidated, it provides default answers
to pretty much everything, and the defaults are generally correct.


However, your question seems to have been about how to install your OWN
modules.  Do this:
perl -e 'print join "\n", @INC, "\n";'
This will dump out a list of directories.  On my system, the list is this:
/usr/local/lib/perl5/5.6.1/alpha-dec_osf
/usr/local/lib/perl5/5.6.1
/usr/local/lib/perl5/site_perl/5.6.1/alpha-dec_osf
/usr/local/lib/perl5/site_perl/5.6.1
/usr/local/lib/perl5/site_perl/5.6.0/alpha-dec_osf
/usr/local/lib/perl5/site_perl/5.6.0
/usr/local/lib/perl5/site_perl
.
Now, if I put a file named "Foo.pm" in  /usr/local/lib/perl5/site_perl, I
could then tell Perl to use that file as a module in one of my scripts by
putting the following line at the top of the script:
use Foo;

If I created a directory in /usr/local/lib/perl5/site_perl   named
'Foo/' and in that directory I put a file named 'Bar.pm', then I could use
that module by doing:
use Foo::Bar;

Hope this helps.

Dave


On Fri, 9 Nov 2001, Martin Pfeffer wrote:

> Install the CPAN Module
> Then type install Modulname
>
> Hope it helps
> martin
>
> Rahul Garg wrote:
>
> > well,
> >
> > i want to install modules on my system(linux) that i have made.
> > what i know is they are to be installed at @INC.
> > but exactly how.any suggestions
> > any sources for reading...
> >
> > Bye,
> > Rahul
> >
> >
>
>
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: SecureCRT + Perl

2001-11-09 Thread Dave Storrs


Ah.  Ok, now I understand.

Sorry, no experience with such things.

Dave


On Fri, 9 Nov 2001, A. Rivera wrote:

> I'm talking about using scripts in the tradition of clients like Telemate,
> Telix, ZOC.  Where the script rests on the client side, and it is used to
> interact with the remote session.
>
> Here is an example Perl script from SecureCRT's website..
[snip]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Off-Topic (200%) - Where are you from?

2001-11-12 Thread Dave Rankin

Providence, in the tiny state of Rhode Island

-Dave




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Off-Topic (200%) - Where are you from?

2001-11-13 Thread Dave Storrs


At the moment, New York, a.k.a. "Terrorist Target Number #1"

:/

Dave


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: installing modules

2001-11-13 Thread Dave Storrs



On Tue, 13 Nov 2001, Rahul Garg wrote:

> i have actually got the solution.
> if i have the module Bar.pm in  directory  '/usr/home/rahul/myMod'
> then in the perl script that uses this module i have to include the
> statement
>
> use lib '/usr/home/rahul/myMod' ;
> use Bar ;
>
> Thanks,
> Rahul


Yep, that will certainly do it, and is often the best way.  Another way to
do it described here (ref PERL5LIB and PERLLIB vars):
http://www.perldoc.com/perl5.6/pod/perlrun.html#ENVIRONMENT


Dave


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: What was your first PERL script (was Off-Topic (200%) - Where are you from?)

2001-11-13 Thread Dave Turner

Mine just got completed after about 6 months of on and off work. It is a 
CGI app to allow a merchant to update items for sale via a web page. Adds 
them on one side, and check boxes allow you to choose which to get rid of 
on the other side. It writes items to a small file -- it's too small a 
number to use any kind of real database, but then when it's called up from 
their site, it dynamically builds the html for the user from that file.

And I'm still learning... :-)

( I want to be able to add pics to this app next... lol )

At 03:54 PM 11/11/01 -0500, you wrote:
>Mine was only about 4 months ago and it was an online shopping catalog
>browser. Good thing I only had to link into shopping cart and credit card
>verification code!
>
>-Original Message-
>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
>Sent: Sunday, November 11, 2001 8:43 AM
>To: [EMAIL PROTECTED]
>Subject: Re: What was your first Perl script (was Off-Topic (200%) -
>Where are you from?)
>
>
> > "Brett" == Brett W McCoy <[EMAIL PROTECTED]> writes:
>
>Brett> My first Perl script, from 1998 or 1999
>
>My first Perl script was from a decade earlier than that.
>
>You young'uns. :)
>
>
>
>--
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: What was your first PERL script (was Off-Topic (200%) - Whereare you from?)

2001-11-14 Thread Dave Storrs


Mine was to write a document-management system for Paine Webber.

Of course, I had the advantage of working with two or three other Perl
programmers, all of whom were substantially skilled.  Still, that was how
I first got exposed to the language.  (AFAIK, PW is still using that
system; they hired the original team, including me, back a year later to
expand it.  It was pretty cool too...it could manage 100,000s of docs,
could do fax, email, etc.  And this was all back in 1996 or so.)

Dave

 On Tue, 13 Nov 2001, Dave Turner wrote:

> Mine just got completed after about 6 months of on and off work. It is a
> CGI app to allow a merchant to update items for sale via a web page. Adds
> them on one side, and check boxes allow you to choose which to get rid of
> on the other side. It writes items to a small file -- it's too small a
> number to use any kind of real database, but then when it's called up from
> their site, it dynamically builds the html for the user from that file.
>
> And I'm still learning... :-)
>
> ( I want to be able to add pics to this app next... lol )
>
> At 03:54 PM 11/11/01 -0500, you wrote:
> >Mine was only about 4 months ago and it was an online shopping catalog
> >browser. Good thing I only had to link into shopping cart and credit card
> >verification code!
> >
> >-Original Message-
> >From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> >Sent: Sunday, November 11, 2001 8:43 AM
> >To: [EMAIL PROTECTED]
> >Subject: Re: What was your first Perl script (was Off-Topic (200%) -
> >Where are you from?)
> >
> >
> > >>>>> "Brett" == Brett W McCoy <[EMAIL PROTECTED]> writes:
> >
> >Brett> My first Perl script, from 1998 or 1999
> >
> >My first Perl script was from a decade earlier than that.
> >
> >You young'uns. :)
> >
> >
> >
> >--
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Updating a hash using a refernece?

2001-11-14 Thread Dave Storrs



On Tue, 13 Nov 2001, AMORE,JUAN (HP-Roseville,ex1) wrote:

> How do I update the value pointed to by key "PAGER" from more to pg.
> when using a reference only to the hash element for key "PAGER".
>
>
> %Unix= ("SHELL" => "/bin/csh",
>"PAGER" => "more",
>"DB" => "mysql");
>
>  print "Value: ", $unix{PAGER};
>
>


Are you saying that you have a reference to the hash itself, or a
reference to the scalar element stored in the hash?  See below:

my %hash = ( SHELL => '/bin/csh' );
my $rh_hash = \%hash;
my $rs_element = \($hash{SHELL});

print $hash{SHELL}, "\n";

$rh_hash->{SHELL} = 'blog';
print $hash{SHELL}, "\n";

$$rs_element = 'wurzle';
print $hash{SHELL}, "\n";


Outputs:

/bin/csh
blog
wurzle




Dave



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: What is "bubble sort"?

2001-11-16 Thread Dave Storrs



On Fri, 16 Nov 2001, Pete Emerson wrote:

> I got this from http://www.wikipedia.com/wiki/Radix_sort:
>
> QUOTE
> Radix sort is a sort algorithm that operates in O(n) time. This algorithm was
> orignally
> used to sort punched cards in several passes. It has resurfaced as an
> alternative to
> other high performance sorting algorithms (like quicksort, heapsort and merge
> sort)
> which run in O(n lg n)) time. Its greatest disadvantages are that it usually
> cannot be
> made to run in place, so O(n) additional memory space is needed, and that it
> requires
> one pass for each symbol of the key, so it is very slow for potentially-long
> keys.
> /QUOTE

Hmmm...this is interesting.  A friend of mine who is in the
process of getting her graduate degree in CS/information theory stuff
recently told me that it has been mathematically proven that no sort can
run faster than O(n log n) unless you know something about the incoming
data.  I guess that radix sort _only_ works on strings (or stringified
things), then?


> It seems to me if you have some knowledge that the data is unsorted or
> random,
> it might be to your advantage to run the radix algorithm instead.

In general, two principles hold:
- if you know nothing about your data, there are certain
"standard" algorithms/solutions that you pick, because they work well
under most conditions and not too badly even under degenerate cases
(quicksort is an example)

- the more you know about your data
((un)sorted/string/number/limited range), the better you can do at
choosing algorithms that are closer to optimal *for your data*

> Thoughts? Anyone done some testing on actual data? What's that timing module
> again?

perldoc Benchmark.pm


Dave


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Populating a referenced hash

2001-11-16 Thread Dave Storrs


This may or may not solve your problem, but

Name your sub something other than 'ref'.  Ref is a reserved word in Perl.

(perldoc -f ref  for details on what it does)

Dave

> > > --arg.pl---
> > > #/usr/plx/bin/perl -w
> > >
> > > use strict;
> > >
> > > sub ref
> > > {
> > >   my  ($href, $aref) =@_;
> > >   my  (@leftovers);
> > >
> > >   foreach (@$aref) {
> > >   chomp;
> > >   if (/^UserID\s+:\s+(\d+)/) {
> > >   ${$href}{'UserID'} = $1;
> > >   } elsif (/^SupportGroup\s+:\s+(\d+)/) {
> > >   ${$href}{'SupportGroup'} = $1;
> > >   } elsif (/^Assigned To\s+:\s+(\d+)/) {
> > >   ${$href}{'AssignTo'} = $1;
> > >   } elsif (/^DateOpened\s+:\s+(\d+)/) {
> > >   ${$href}{'DateOpened'} = $1;
> > >   } else {
> > >   push(@leftovers, "$_\n");
> > >   }
> > >   }
> > >   return(@leftovers);
> > > }
> > >
> > > my @array;
> > > my @remains;
> > > my (%hash);
> > >
> > > open(F_TMP, "/tmp/tfile") || die("Cannot open text file");
> > > @array = ;
> > > close(F_TMP);
> > >
> > > @remains = &ref(\%hash, \@array);
> > > print "User ID = $hash{'$UserID'}\n";
> > > print "Remains = " . @remains . "\n";
> > > ---output
> > > User ID =
> > > Remains = 2
> > >
> > > --
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> > > --
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> >
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Modules

2001-11-16 Thread Dave Storrs

> > In practical daily use, use(); is preferred as since it compiles the
> > module as soon as it sees 'use Foo::Bar;' before moving on, this will
> > catch errors and scope conflicts far sooner than if you use require();
> > There aren't many good reasons to use require, at least I
> > can't think of
> > any. When in doubt, use use(); :)
> >
> > If you see a lot of 'requires' in subroutines, I suspect someone just
> > didn't get scope or wrote a quick hack so performance is the
> > least of the
> > codes worries.
>
> require() is handy inside an eval { } block to trap whether a module
> is installed or not. Many CPAN modules use this technique.

Very occasionally I will also do something like this:

my $needed_file = deduce_where_necessary_code_is();
require "$needed_file";



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Populating a referenced hash

2001-11-16 Thread Dave Storrs



On Fri, 16 Nov 2001, Tomasi, Chuck wrote:

> Good point.  I should be a little more imaginative.  Sometimes making up
> meaningful variable and function names is the hardest part of writing code.

It is indeed!

> Another thing I found about the references, the order of the parameters
> matter.  If I pass the array ref first and the hash ref second, the
> foreach(@$aref) loop walks right over the hash ref and I get information at
> the end of @leftovers "main::hash".

I'm not surprised...look, the first line in your subroutine is:

my ($href, $aref) = @_;

Ok, so if you pass the array reference first, it will go into the
variable named $href.  Just like, if you did this in C:

int ref(void *href, void *aref);
ref( &hash_struct, &array_struct );
ref( &array_struct, &hash_struct );

...you would expect to get different results from the two calls,
right?

Dave


>
> --Chuck
>
> > > > > --arg.pl---
> > > > > #/usr/plx/bin/perl -w
> > > > >
> > > > > use strict;
> > > > >
> > > > > sub ref
> > > > > {
> > > > >   my  ($href, $aref) =@_;
> > > > >   my  (@leftovers);
> > > > >
> > > > >   foreach (@$aref) {
> > > > >   chomp;
> > > > >   if (/^UserID\s+:\s+(\d+)/) {
> > > > >   ${$href}{'UserID'} = $1;
> > > > >   } elsif (/^SupportGroup\s+:\s+(\d+)/) {
> > > > >   ${$href}{'SupportGroup'} = $1;
> > > > >   } elsif (/^Assigned To\s+:\s+(\d+)/) {
> > > > >   ${$href}{'AssignTo'} = $1;
> > > > >   } elsif (/^DateOpened\s+:\s+(\d+)/) {
> > > > >   ${$href}{'DateOpened'} = $1;
> > > > >   } else {
> > > > >   push(@leftovers, "$_\n");
> > > > >   }
> > > > >   }
> > > > >   return(@leftovers);
> > > > > }
>
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Time Related

2001-11-16 Thread Dave Storrs


Here are two approaches:
1) Make sure that every record in the log file includes a
timestamp.  Parse all lines, locate the first timestamp that is
>= (CT - 1 hour), using everything after that line.

2) Rename the log file every hour so that you start 24 separate
logs each day, and you know that each log contains information only from a
specific hour of the day.

The first approch is more flexible, the second may be easier.

Dave



On Fri, 16 Nov 2001, Najamuddin, Junaid wrote:

> Hi,
>
> How can I pull data from a log file for last hour or so
> I wrote a script but i am unable develop a logic for last one hour
> My script is reading the data fine line by line or last 10 or 20 lines
> But it is not what I want
> I want whatever is current time minus one hour or so
>
> If some one can help me please
>
> thanks
> junaid
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: capture song title

2001-11-16 Thread Dave Storrs



On Fri, 16 Nov 2001, KeN ClarK wrote:

> I want to capture the title of the current song I have running on my box
> through mpg123 and redirect it to a file. In this process, I don't want
> the /long/path/to/song but just the song.mp3. Is it possible to capture
> the song title this way?
>
> Ken

$filepath = reverse filepath;
my ($title, undef) = split /\//, $filepath, 2;
$title = reverse $title;


Or, if your supply of whitespace is running low:

$title=reverse shift @{[split(/\//,reverse($filepath),2)]};

But you probably don't want to do that if you'll ever need to look at
this code again. :>

Dave


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Pattern matching

2001-11-21 Thread Dave Rankin

Hello,

When reading from  like that, you're going to want to use chomp to 
remove the \n line character at the end of what the user inputs.  Right now, 
you're actually doing a match for "$build\n".

So, you could change "$build=;" to "chomp($build=);" or even 
"chomp($build=<>);".

HTH.

-Dave

On Wednesday 21 November 2001 09:32 am, Prasanthi Tenneti wrote:
> Hi,
> Iam unable to debug this code.
> pls help me.
> here is the code :
>
> open(FILE,"build.txt") ||die "cannot open \n";
> print "select which build you want to enter\n";
> $build=;
> while()
> {
>   if(/$build/)
>   {
>   print "you selected $build\n";
>   #here it should print next 3 0r 4 lines until space comes
>   }
>   else
>   {
>   print "$build is not found\n";
>   }
> }
>
> If build1 is found it should print next 3 lines (or till space comes)
>
> for ex build.txt file :
> build1
> rpm_1;
> rpm_2;
> qwe_3;
>
> build2
> qwe-1;
> asd_2;
> asd_3;
>
> if I selected build1 ,it should print rpm_1 to qwe_3
> cheers,
> prasanthi.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: directories

2001-11-21 Thread Dave Rankin

You can use the -d operator to test for a directory.  

print "Found directory!\n" if (-d "/path/to/directory");

(Just make sure you use the c:\\path\\to\\directory format on Windows.)

HTH.

-Dave

On Wednesday 21 November 2001 10:41 am, [EMAIL PROTECTED] wrote:
> what is the best way to check for the existence of a directory?
> (windows/Linux)


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: retrieving array/data from a pdf file and putting everything in a excel file

2001-11-21 Thread Dave Rankin

Hi,

You might want to check out the PDF modules at cpan, particularly PDF::Core 
and PDF::Parse.  Also, here's an article that should help with the excel part:
http://www-106.ibm.com/developerworks/library/l-pexcel/

These should be a starting point anyway.

HTH.

-Dave


On Wednesday 21 November 2001 10:43 am, Moulas, Lionel wrote:
> Hi.
>
> I am receiving some pdf files everyday ( 7 to 8 a day, full of arrays
> containing stock exchange datas). Anytime one of the arrays contains some
> keywords, I have to copy the whole on a Excel spreadhseet.
>
> This is taking time.
>
> Do you know a way to do it more efficiently with Perl ?
> (extracting array from a pdf file, creating excel file with it)
> Is there any website with example of how this can be done ?
>
> Thanks//
>
>
> *
> The information in this internet E-mail is confidential and is intended
> solely for the addressee. Access, copying or re-use of information in it
> by anyone else is unauthorized. Any views or opinions presented are
> solely those of the author and do not necessarily represent those of
> Credit Lyonnais or any of its affiliates. The information contained herein
> is recorded for business purposes and use of services is monitored to
> protect both the company and its individual users. If you are not the
> intended recipient please contact [EMAIL PROTECTED]
> *


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: directories

2001-11-21 Thread Dave Storrs


Any of the following should work for you:

if ( -e $dirpath && -d $dirpath ) { ...stuff...}
if ( -e $dirpath && -d _ ) { ...stuff...}
if ( -d $dirpath ) { ...stuff...}

You can always substitute $dirpath for a literal string path in the above
as well...e.g.:

if ( -d '/usr/bin/home' ) { ... stuff ... }

The -e test checks to see that $dirpath exists, -d checks that it is a
directory.  The underscore means "whatever the last filetest operated on,
operate on that same thing".  Read more about it here:

http://www.perldoc.com/perl5.6/pod/func/X.html

Dave S


On Wed, 21 Nov 2001 [EMAIL PROTECTED] wrote:

> what is the best way to check for the existence of a directory?
> (windows/Linux)
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




  1   2   3   4   5   6   >