Re: Download problem

2002-12-06 Thread zentara
On 06 Dec 2002 08:22:19 +0200, [EMAIL PROTECTED] (Stelian Iancu)
wrote:

Hello!

I try to download a file from a CGI script. Here is the code:

$self-header_props(-type='application/x-octet-stream',
-attachment=$file);
   
   open(FILE, $file);
   binmode(FILE);
   $/ = undef;
   my($data) = FILE;
   close(FILE);
   binmode(STDOUT);
   print $data;

I am using CGI::App, but the problem is not there. Anyway, the file is
written directly in the browser, I don't get a Save to disk dialog.

I'm guessing that the CGI::App module isn't doing the headers right.
Try this.

##3
#!/usr/bin/perl

$file = 'test.tgz';

printEOH; 
Content-type: application/octet-stream 
Content-Disposition: attachment\; filename=$file 

EOH

binmode STDOUT;
open (FH, $file) or die Can't open $file: $!;
binmode FH;
while(FH){print}
close (FH);

exit 0;




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




While (FileHandler) only reads the first line

2002-12-06 Thread Hanming Tu
Hi, All,

It is very strange. I have an Perl application developed on Unix box and
want to port to Windows environment. All my file handlers only read the
first line in the applications developed in Unix although they were working
fine in Unix environment. Any clue?

Thanks.

sub readTaskHelp {

my($fn,$rest) = @_;

# print FN: $fnbr\n;

open HLPF, $fn or

echoErrs(*STDOUT,open:$fn,__FILE__,__LINE__,$!);

# read content into a hash array %U

my($hlpf,$vfn,$t1,$t2,$tag,$i,$j,%U,$itms,$itm,$v,$var,@a);

$itm= ; # item from $tt

$itms = ; # a list of items

$i = ; # next item

$j = 0; # count within an item

$v=$var=; $t1=$t2=;

%U=();

while (HLPF) {

print $_br\n;

next if ($_ =~ /^#/); # skip comment lines

if ($_ =~ /^\.(\w+)\s*(.*)/) {

if ($itm ne lc($1)  $t1) {

$U{$itm}[0][1]=$t1; # record item content

$t1 = ;

}

$itm = lc($1);

if ($itms) { $itms .= ,$itm; } else { $itms=$itm; }

$j=0; $t1=$2; # reset counter and record content

$U{$itm}[0][0]=ucfirst($itm); next;

}

if ($_ =~ /^\~\s*(.*)/) { # append contents

$t1 .=  $1; next;

}

if ($_ =~ /^\-\s*([\w ]*):(.*)/) { # - Get Info:

if ($v ne $1  $t2) {

$U{$itm}[$j][1]=$t2; # record item content

$t2 = ; $v=$1;

}

$t2 = ; ++$j; $var=$1; # reset content holder and counter

$U{$itm}[$j][0]=$1; $t2 = $2;

} elsif ($_ =~ /^-\s*(-\w)\s*(.*)/) { # - -t 

if ($v ne $1  $t2) {

$U{$itm}[$j][1]=$t2; # record item content

$t2 = ; $v=$1;

}

$t2 = ; ++$j; $var=$1;

$U{$itm}[$j][0]=$1; $t2 = $2;

}

if ($_ =~ /^ \s*(.*)/) { #   two blank spaces

$t2 .=  $1; $v = $var; next;

}

if ($_ =~ /^\s*$/) {

if ($t1) {

$U{$itm}[0][1]=$t1; # record item content

$t1 = ; $i=$itm;

}

if ($t2) {

$U{$itm}[$j][1]=$t2; # record item content

$t2 = ; $v=$var;

}

next;

}

}

close(HLPF);

$U{'items'}=$itms; $itms=;

return %U;

}






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




Upload (probably a stupid question)

2002-12-06 Thread Scot Robnett
How do I make my script only send the filename rather than the full path
when I use the CGI.pm upload function?

For example, when I upload the document

test.xls

On the remote server, it's being named with the full path of where I sent it
from, like this

C:\Documents and Settings\SRobnet\Desktop\test.xls

How can I get it to just leave the filename as test.xls on the remote
server without appending my entire local path to it?

-
Scot Robnett
inSite Internet Solutions
[EMAIL PROTECTED]



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




Re: Upload (probably a stupid question)

2002-12-06 Thread Mystik Gotan
$var =~ tr/^\\\w+$//; # replace slashes and words with none, so this
   # kinda leaves you with nothing that the filename.
   # UNTESTED!

I also recommend:
$var =~ s/[^\w.-]/_/g; # which translate's some signs to underscores (_)



--
Bob Erinkveld (Webmaster Insane Hosts)
www.insane-hosts.net
MSN: [EMAIL PROTECTED]






From: Scot Robnett [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: Upload (probably a stupid question)
Date: Fri, 6 Dec 2002 10:37:11 -0600

How do I make my script only send the filename rather than the full path
when I use the CGI.pm upload function?

For example, when I upload the document

	test.xls

On the remote server, it's being named with the full path of where I sent 
it
from, like this

	C:\Documents and Settings\SRobnet\Desktop\test.xls

How can I get it to just leave the filename as test.xls on the remote
server without appending my entire local path to it?

-
Scot Robnett
inSite Internet Solutions
[EMAIL PROTECTED]



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


_
MSN Zoeken, voor duidelijke zoekresultaten! 
http://search.msn.nl/worldwide.asp


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



Re: Download problem

2002-12-06 Thread zentara
On Fri, 06 Dec 2002 08:22:19 +0200, Stelian Iancu wrote:

 I try to download a file from a CGI script. Here is the code:
 
 $self-header_props(-type='application/x-octet-stream',
 -attachment=$file);
   
   open(FILE, $file);
   binmode(FILE);
   $/ = undef;
   my($data) = FILE;
   close(FILE);
   binmode(STDOUT);
   print $data;
 
 I am using CGI::App, but the problem is not there. Anyway, the file is
 written directly in the browser, I don't get a Save to disk dialog.

I'm guessing something is wrong in the way you setup the header.

Here is a method that works for me.
#
#!/usr/bin/perl
$file = 'test.tgz';

printEOH;
Content-type: application/octet-stream
Content-Disposition: attachment\; filename=$file

EOH

binmode STDOUT;
open (FH, $file) or die Can't open $file: $!;
binmode FH;
while(FH){print}
close (FH);

exit 0;



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




Re: Snagging the last page of a report

2002-12-06 Thread zentara
On Thu, 5 Dec 2002 14:24:03 -0500, [EMAIL PROTECTED] (Paul Kraus)
wrote:

snip How to seek last 2k?

Here's a start for you, getting the last 2k of the file.
Looping and checking for last page break is left up to you. :-)

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

my $filename = shift or die Usage: $0 file \n;

# Open the file in read mode 
open FILE, $filename or die Couldn't open $filename: $!;

# Rewind from the end of the file until -2k 
seek FILE,0, 2;  #go to EOF 
seek FILE,-2048,2; #get last 2k bytes 

$/=undef;
my $tail = FILE;
print $tail\n;
exit;



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




Re: what is this?

2002-12-06 Thread Tom Allison
simran wrote:

From the docs... 


 -S   makes perl use the PATH environment variable to  search
  for  the  script  (unless the name of the script starts
  with a slash).  Typically this is used  to  emulate  #!
  startup  on machines that don't support #!, in the fol-
  lowing manner:

   #!/usr/bin/perl
   eval exec /usr/bin/perl -S $0 $*
if $running_under_some_shell;



If I read this correctly the above code just surpasses the 
#!/usr/bin/perl line in case it fails to find /usr/bin/perl and 
conducts a $PATH search?



--
You mean you didn't *know* she was off making lots of little phone 
companies?


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



Re: what is this?

2002-12-06 Thread simran
perldoc perlrun

On Fri, 2002-12-06 at 22:39, Tom Allison wrote:
 simran wrote:
 From the docs... 
  
  
   -S   makes perl use the PATH environment variable to  search
  
  
  
  
  On Fri, 2002-12-06 at 12:49, Tom Allison wrote:
  
 eval 'exec /usr/bin/perl  -S $0 ${1+$@}'
  if 0; # not running under some shell
 
 
 -
 What does this do and why?
 
 -- 
 mummy, n.:
 An Egyptian who was pressed for time.
  
  
  
 
 Which docs?


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




Hash Question

2002-12-06 Thread Sean Rowe
I need to keep track of a user, all the web pages a user has visited, and
the number of times the user visited each page.  I get my information from a
log file.  Here's how I would like to say it programmatically:

$Hash{$User}{$Page}{$NumTimesVisited} = $ANumber;

Is this possible?  If so, how would I traverse this, as I will not know
before hand the values in the hash; I will need to use something like sort.
Thank you.

Sean Rowe


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




Re: Hash Question

2002-12-06 Thread Mystik Gotan
I'm not very sure if it works.
I'd rather concentate the whole thing.

$Hash{User} = $ANumber;
$Hash{Page} .= $ANumber;
$Hash{NumTimesVisited} .= $ANumber;

Also note that you should be using $ in your HashKey calls!

--
Bob Erinkveld (Webmaster Insane Hosts)
www.insane-hosts.net
MSN: [EMAIL PROTECTED]






From: Sean Rowe [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
To: Beginners@perl. org \(E-mail\) [EMAIL PROTECTED]
Subject: Hash Question
Date: Fri, 6 Dec 2002 08:29:37 -0600

I need to keep track of a user, all the web pages a user has visited, and
the number of times the user visited each page.  I get my information from 
a
log file.  Here's how I would like to say it programmatically:

	$Hash{$User}{$Page}{$NumTimesVisited} = $ANumber;

Is this possible?  If so, how would I traverse this, as I will not know
before hand the values in the hash; I will need to use something like sort.
Thank you.

Sean Rowe


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


_
Chatten met je online vrienden via MSN Messenger. http://messenger.msn.nl/


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




RE: Hash Question

2002-12-06 Thread Bob Showalter
 -Original Message-
 From: Sean Rowe [mailto:[EMAIL PROTECTED]]
 Sent: Friday, December 06, 2002 9:30 AM
 To: Beginners@perl. org (E-mail)
 Subject: Hash Question
 
 
 I need to keep track of a user, all the web pages a user has 
 visited, and
 the number of times the user visited each page.  I get my 
 information from a
 log file.  Here's how I would like to say it programmatically:
 
   $Hash{$User}{$Page}{$NumTimesVisited} = $ANumber;

No, it should probably look like this instead:

   $Hash{$User}{$Page}++;   # increment number of visits

Putting a single variable inside double quotes is useless. Also, you don't
need a third level in this hash. There are only two levels needed: user and
page.

 
 Is this possible?  If so, how would I traverse this, as I 
 will not know
 before hand the values in the hash; I will need to use 
 something like sort.

To print a table of users and the pages they have visited, you can do
something like:

   for my $u (sort keys %Hash) {
  for my $p (sort keys %{$Hash{$u}}) {
 print User $u visited page $p $Hash{$u}{$p} times\n;
  }
   }

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




RE: Hash Question

2002-12-06 Thread simran
To interate over something like:

  $abc{'a1'}{'b1'} = $number1
  $abc{'a2'}{'b2'} = $number2
  $abc{'a3'}{'b3'} = $number3
  $abc{'a4'}{'b4'} = $number4
  ...

You can use:

  foreach my $key1 (keys %abc) {
foreach my $key2 (keys %{$abc{$key1}}) {
  my $value = $abc{$key1}{$key2}
  print Key1=$key1 Key2=$key2 Value=$value\n;
}
  }


On Sat, 2002-12-07 at 02:46, Sean Rowe wrote:
 That sounds more like what I want to do.  I have a question, though: Since
 I'm not going to know before hand what my hash values are (as I create them
 on the fly), how can I iterate through each hash to get each value?  
 
 -Original Message-
 From: Igor Sutton Lopes [mailto:[EMAIL PROTECTED]]
 Sent: Friday, December 06, 2002 10:12 AM
 To: [EMAIL PROTECTED]; Beginners@perl. org (E-mail)
 Subject: RES: Hash Question
 
 
 You can do something like this:
 
 %url_options_hash = (times_visited=0);
 %url_hash = (this_url=\%url_options_hash);
 %usr_hash = (igor=\%url_hash);
 
 print $usr_hash{igor}-{this_url}-{times_visited}, \n;
 $usr_hash{igor}-{this_url}-{times_visited} = 1;
 print $usr_hash{igor}-{this_url}-{times_visited}, \n;
 
 That worked for me, you use in this case the reference for the 'inner'
 hashes.
 
 Igor.
 
 
  - Mensagem original -
  De: Sean Rowe [SMTP:[EMAIL PROTECTED]]
  Enviada em: sexta-feira, 6 de dezembro de 2002 11:30
  Para:   Beginners@perl. org (E-mail)
  Assunto:Hash Question
  
  I need to keep track of a user, all the web pages a user has visited, and
  the number of times the user visited each page.  I get my information from
 a
  log file.  Here's how I would like to say it programmatically:
  
  $Hash{$User}{$Page}{$NumTimesVisited} = $ANumber;
  
  Is this possible?  If so, how would I traverse this, as I will not know
  before hand the values in the hash; I will need to use something like
 sort.
  Thank you.
  
  Sean Rowe
  
  
  -- 
  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: Difference between $count++ and ++$count

2002-12-06 Thread stelid-6
Yes it is a differense.

code:
#!/usr/bin/perl -w

use strict;

my $hepp = 3;
my $hopp;

$hopp =++$hepp;

print hopp: $hopp\n;

$hepp = 3;
$hopp = $hepp++;


print hopp: $hopp\n;


Mystik Gotan wrote:
 
 Hiya,
 
 is there any difference between $count++ and ++$count?
 Just wondering.
 
 Thanks.
 
 _
 Ontvang je Hotmail  Messenger berichten op je mobiele telefoon met Hotmail
 SMS http://www.msn.nl/jumppage/
 
 --
 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: Difference between $count++ and ++$count

2002-12-06 Thread Wagner, David --- Senior Programmer Analyst --- WGO
$count++ - will display value then add
++$count - will add then display

as in where $count = 5;
  printf %5d\n, $count++ ;
would display 5 and $count would be 6
  printf %5d\n, ++$count ;
would add then display 6

Or if incrementing a loop within an array, then $array[$count++] = x
would set $array[5] = x and then icrement $count to 6. For $array[++$count]
= x then $count would be 6 and $array[6] = 6.

Wags ;)


-Original Message-
From: Mystik Gotan [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 06, 2002 08:54
To: [EMAIL PROTECTED]
Subject: Difference between $count++ and ++$count


Hiya,

is there any difference between $count++ and ++$count?
Just wondering.

Thanks.





_
Ontvang je Hotmail  Messenger berichten op je mobiele telefoon met Hotmail 
SMS http://www.msn.nl/jumppage/


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


**
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.



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




Re: cgi session

2002-12-06 Thread LRMK
 dont usehtml file for http://www.mydomain.com/welcome.html
use a cgi
like  http://www.mydomain.com/welcome.pl
when u passing user to the page don't just redirect
load that page using automated form submit so you can pass the password and
username to that page too and validate there
if it is wrong redirect back to the login page

i hope somebody has a better idear becouse this needs lots of programming

I used this method once u have to do this in all the pages
so its too complex
- Original Message -
From: Admin-Stress [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, December 06, 2002 12:39 AM
Subject: cgi session


 Hi,

 How can I check cgi session? mmm .. maybe better I explain like this:

 I just want to make a 'secure site' that need username and password. So,
the first page of my site
 would be fill in you username and password, for example, it will be
placed here :

http://www.mydomain.com/login.html

 After that, I will call /cgi-bin/checkpasswd.pl, if OK then user will be
transfered to another
 page, e.g.:

http://www.mydomain.com/welcome.html

 My question, how can I make sure that ONLY ppl passed checkpasswd.pl can
see that welcome.html
 (and the rest of page). It should be about checking 'session' or some
other trick ...

 Anyone can give me pointer/clues how to do this? .. in a simplest way ..

 Thanks,

 kapot

 __
 Do you Yahoo!?
 Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
 http://mailplus.yahoo.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: cgi session

2002-12-06 Thread LRMK
dont usehtml file for http://www.mydomain.com/welcome.html
use a cgi
like  http://www.mydomain.com/welcome.pl
when u passing user to the page don't just redirect
load that page using automated form submit so you can pass the password and
username to that page too and validate there
if it is wrong redirect back to the login page

i hope somebody has a better idear becouse this needs lots of programming

I used this method once u have to do this in all the pages
so its too complex
- Original Message -
From: Admin-Stress [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, December 06, 2002 12:39 AM
Subject: cgi session


 Hi,

 How can I check cgi session? mmm .. maybe better I explain like this:

 I just want to make a 'secure site' that need username and password. So,
the first page of my site
 would be fill in you username and password, for example, it will be
placed here :

http://www.mydomain.com/login.html

 After that, I will call /cgi-bin/checkpasswd.pl, if OK then user will be
transfered to another
 page, e.g.:

http://www.mydomain.com/welcome.html

 My question, how can I make sure that ONLY ppl passed checkpasswd.pl can
see that welcome.html
 (and the rest of page). It should be about checking 'session' or some
other trick ...

 Anyone can give me pointer/clues how to do this? .. in a simplest way ..

 Thanks,

 kapot

 __
 Do you Yahoo!?
 Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
 http://mailplus.yahoo.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: Difference between $count++ and ++$count

2002-12-06 Thread Dr. Poo
On Friday 06 December 2002 11:09 am, simran wrote:
 Yup...

 In program 1 you will get $i to be 1 and then $count will be set to 2
 In program 2 you will get $count to be set to 2 and then assigned to $i
   so now $i will also be 2.

 Its just a prcedence thing...

 Program 1
 --
 my $count = 1;
 my $i = $count++;
 print $i\n;

 Program 2
 --
 my $count = 1;

Don't you mean ++$count?? 

 my $i = $++count;   
 print $i\n;

 On Sat, 2002-12-07 at 03:54, Mystik Gotan wrote:
  Hiya,
 
  is there any difference between $count++ and ++$count?
  Just wondering.
 
  Thanks.
 
 
 
 
 
  _
  Ontvang je Hotmail  Messenger berichten op je mobiele telefoon met
  Hotmail SMS http://www.msn.nl/jumppage/

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




Re: Difference between $count++ and ++$count

2002-12-06 Thread Dr. Poo
Yes sir there is! And it's quite a goober if you ask me, but very useful.

I'll show the difference by example.

my $SOME_CONSTANT = 2;  # NO MAGIC NUMBERS! (hehe)

my $pre_increment = 0;
my $post_increment = 0;

my $pre_result = ++$pre_increment + $SOME_CONSTANT;

my $post_result = $post_increment++ + $SOME_CONSTANT;

# Notice the the ++ either before or after does incremement the variable by
# one, but ++$pre_increment does the incremental operation FIRST before then
# adding $pre_increment to $SOME_CONSTANT
# $post_increment++ does the opposite, it addes $SOME_CONSTANT to the
# pre-existing value in $post_increment, then it incremements by one.
# So, again, both as an end result are incremented by ONE, but their
# precedence is different within an EXPRESSION
print $pre_increment;   # will print '1'
print $post_increment;  # will print '1'

print $pre_result;  # will print '3'
print $post_result; # will print '2'

To Confusing?? I've been told i am not the best teacherso maybe someone
else on the list could help you more if this doesn't..

-Chris

On Friday 06 December 2002 10:54 am, you wrote:
 Hiya,

 is there any difference between $count++ and ++$count?
 Just wondering.

 Thanks.





 _
 Ontvang je Hotmail  Messenger berichten op je mobiele telefoon met Hotmail
 SMS http://www.msn.nl/jumppage/

---

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




RE: Compare script fails (Solved!)

2002-12-06 Thread Michael Weber
It was a trailing space in $_  that was getting me.  I changed a chomp
to a chop and it now finds the string.

Thanx for the tip, and the code!

-Michael

 Patel, SamirX K [EMAIL PROTECTED] 12/05/02 05:08PM 
Could there be extra, non-visible characters attached to the subject
coming
back?  You might want to try using a regular expression to do the
comparison.  It'll give you more control to pass or ignore stuff.

Something the following will ignore extra leading or trailing
characters,
and ignore case changes from the original:

if ($_ =~ /$LOOKFOR/i ) {
  $FOUND = 1;
}

Hope this helps!

Samir


-Original Message-
From: Michael Weber [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, December 05, 2002 12:03 PM
To: [EMAIL PROTECTED] 
Subject: Compare script fails

I am writing a script to check email functionality by sending a test
message to an account that forwards it back to a pop account.  I
cannot
seem to get the script to match the expected subject lines with what
was
received.  No matter what I do, it never shows a match.

Any ideas?

Here's the subroutine, output is below.

sub check_expected {
# This subroutine expects an array, @subjects, to contain zero or more
# subject lines from the messages retrieved from the bounced email pop
# account, and a file in /usr/local/netchecker/database/expected_mail
# that contains the unique subjects that were sent.
# The fourth piece of the subject is the account # that is being
tested.
# If the expected subject is not found in the returned emails, we save
# the failed account #s in /usr/local/netchecker/database/failed_mail
# which, when this script ends, is used by the calling shell script
# to run /usr/local/netchecker/account#/scripts/email_failure
scripts.

# Debug lines


open (FAILURES, 
/usr/local/netchecker/database/failed_mail);
open (EXPECTED,
/usr/local/netchecker/database/expected_mail);
print LOGFILE check_expected  Entering while loop. \n;

while ( EXPECTED ) {
chomp;
chomp;

print LOGFILE Time is $hour:$min \n;
print LOGFILE In while loop, expecting $_. \n;

$FOUND = 0 ;
chomp;
$LOOKFOR = $_;

foreach (@subjects) {

print LOGFILE Looking for $LOOKFOR in $_ \n;
print LOGFILE Index is , index( $_, $LOOKFOR ), \n;

$NEWLOOKFOR = substr( $LOOKFOR, -8);
print LOGFILE New Looking for $NEWLOOKFOR in $_ \n;


$FOUND = index( $_, $LOOKFOR );

# This didn't work either.
#   if ( index( $_, $LOOKFOR ) = 0 ) {
#   $FOUND = 1;
#   }

print LOGFILE In foreach loop. Subject = $_  Found = $FOUND \n;

}

}

close EXPECTED;
close FAILURES;
close LOGFILE;
}



Here's the log file output:

check_expected  Entering while loop.
Time is 19:55
In while loop, expecting 5_13_45_10001_7947 .
Looking for 5_13_45_10001_7947  in Subject: 5_13_45_10001_7947
Index is -1
New Looking for 01_7947  in Subject: 5_13_45_10001_7947
In foreach loop. Subject = Subject: 5_13_45_10001_7947  Found = -1


Thanx!

-Michael


-- 
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: Difference between $count++ and ++$count

2002-12-06 Thread LRMK


++$count will increment $count before it is used
 $count++ will increment $count after it is used



- Original Message -
From: Yacketta, Ronald [EMAIL PROTECTED]
To: 'Mystik Gotan' [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Friday, December 06, 2002 11:02 PM
Subject: RE: Difference between $count++ and ++$count


 Yes

 If I recall correctly:

 ++$count will increment $count after it is used
 $count++ will increment $count before it is used

 -Ron

 -Original Message-
 From: Mystik Gotan [mailto:[EMAIL PROTECTED]]
 Sent: Friday, December 06, 2002 11:54
 To: [EMAIL PROTECTED]
 Subject: Difference between $count++ and ++$count


 Hiya,

 is there any difference between $count++ and ++$count?
 Just wondering.

 Thanks.





 _
 Ontvang je Hotmail  Messenger berichten op je mobiele telefoon met
Hotmail
 SMS http://www.msn.nl/jumppage/


 --
 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]




Total Newbie

2002-12-06 Thread ComplexedOne
Ok I am a total newbie when it comes to perl.  Could anyone please direct to 
a site or something that will help me learn and start programing.  Any help 
would be great.  Thanks.



RE: Difference between $count++ and ++$count

2002-12-06 Thread Yacketta, Ronald
Gah!

bassackwards again :(

-Original Message-
From: LRMK [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 06, 2002 12:11
To: Yacketta, Ronald
Cc: [EMAIL PROTECTED]
Subject: Re: Difference between $count++ and ++$count




++$count will increment $count before it is used
 $count++ will increment $count after it is used



- Original Message -
From: Yacketta, Ronald [EMAIL PROTECTED]
To: 'Mystik Gotan' [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Friday, December 06, 2002 11:02 PM
Subject: RE: Difference between $count++ and ++$count


 Yes

 If I recall correctly:

 ++$count will increment $count after it is used
 $count++ will increment $count before it is used

 -Ron

 -Original Message-
 From: Mystik Gotan [mailto:[EMAIL PROTECTED]]
 Sent: Friday, December 06, 2002 11:54
 To: [EMAIL PROTECTED]
 Subject: Difference between $count++ and ++$count


 Hiya,

 is there any difference between $count++ and ++$count?
 Just wondering.

 Thanks.





 _
 Ontvang je Hotmail  Messenger berichten op je mobiele telefoon met
Hotmail
 SMS http://www.msn.nl/jumppage/


 --
 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: Total Newbie

2002-12-06 Thread Beau E. Cox
Welcome!

http://www.perl.org
http://learn.perl.org

and the many, many links posted there.

Aloha = Beau.

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 06, 2002 7:50 AM
To: [EMAIL PROTECTED]
Subject: Total Newbie


Ok I am a total newbie when it comes to perl.  Could anyone please direct to
a site or something that will help me learn and start programing.  Any help
would be great.  Thanks.



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




Problem compiling SNMP::Util

2002-12-06 Thread Anthony . Kernan
I'm having problems compiling perl mod SNMP::Uitl, I get the following error
when I do a make test.  Any help would be greatly appreciated.

gotgraphs# make test
PERL_DL_NONLAZY=1 /usr/bin/perl -Iblib/arch -Iblib/lib
-I/usr/libdata/perl/5.00503/mach -I/usr/libdata/perl/5.00503 -e 'use
Test::Harness qw(runtests $verbose); $verbose=0; runtests @ARGV;' t/*.t
t/libtestNOK 1STORE(SNMP::MIB=HASH(0x8102378) sysContact
HASH(0x81ecee8)) : write access to the MIB not implemented
t/libtestNOK 2Can't use an undefined value as an ARRAY reference at
blib/lib/SNMP/Util.pm line 1481, GEN0 chunk 2.
t/libtestdubious

Test returned status 255 (wstat 65280, 0xff00)
DIED. FAILED tests 1-8
Failed 8/8 tests, 0.00% okay
Failed Test Stat Wstat Total Fail  Failed  List of Failed

---
t/libtest.t  255 65280 88 100.00%  1-8
Failed 1/1 test scripts, 0.00% okay. 8/8 subtests failed, 0.00% okay.
*** Error code 2

Stop in /usr/home/download/SNMP-Util-1.8.

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




Re: Difference between $count++ and ++$count

2002-12-06 Thread simran
Yup... good catch... i should run my code rather than just type it in a
mail window i guess :-) 


 Don't you mean ++$count?? 
 
  my $i = $++count;   
  print $i\n;
 
  On Sat, 2002-12-07 at 03:54, Mystik Gotan wrote:
   Hiya,
  
   is there any difference between $count++ and ++$count?
   Just wondering.
  
   Thanks.
  
  
  
  
  
   _
   Ontvang je Hotmail  Messenger berichten op je mobiele telefoon met
   Hotmail SMS http://www.msn.nl/jumppage/


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




Regex

2002-12-06 Thread Steve Main

Hello list,

I am trying to code a regex to pull out the number part of ORA-600 or 600.
 
I have started with   if ($line =~ m/^(ORA-)(\-[0-9]*)$/) { but this
is obviously wrong.  

Anyone out there willing to get me on the right track?

thanks

Steve

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




RE: Regex

2002-12-06 Thread Paul Kraus
Since I am not familiar with your data I will assume that it occurs
anywhere is $line you want to still match.
m/\s*ORA-(\d+)\s+/

Any spaces characters followed by ORA- followed by any digits 0-9
followed by any space characters. Using the () you have placed that
portion of the match into variable $1. Let me know if I am
misunderstanding what you are trying for.

 -Original Message-
 From: Steve Main [mailto:[EMAIL PROTECTED]] 
 Sent: Friday, December 06, 2002 1:37 PM
 To: Help on PERL
 Subject: Regex
 
 
 
 Hello list,
 
 I am trying to code a regex to pull out the number part of 
 ORA-600 or 600.
  
 I have started with   if ($line =~ m/^(ORA-)(\-[0-9]*)$/) { but this
 is obviously wrong.  
 
 Anyone out there willing to get me on the right track?
 
 thanks
 
 Steve
 
 -- 
 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: Regex

2002-12-06 Thread John W. Krahn
Steve Main wrote:
 
 Hello list,

Hello,

 I am trying to code a regex to pull out the number part of ORA-600 or 600.
 
 I have started with   if ($line =~ m/^(ORA-)(\-[0-9]*)$/) { but this
 is obviously wrong.

Yes, it is trying to match ORA--600 (two hyphens.)


 Anyone out there willing to get me on the right track?

if ( $line =~ /^ORA-(\d+)$/ ) {




John
-- 
use Perl;
program
fulfillment

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




RE: Regex

2002-12-06 Thread bengleto
 m/\s*ORA-(\d+)\s+/

Correct me if I'm wrong, but wont this match fail if there are no 
spaces after
ORA-600

I would think this is better
if ($line =~ m/ORA-(\d+)/){$number = $1;}

  Hello list,
  
  I am trying to code a regex to pull out the number part of 
  ORA-600 or 600.
   
  I have started with   if ($line =~ m/^(ORA-)(\-[0-9]*)$/) 
 { but this
  is obviously wrong.  
  
  Anyone out there willing to get me on the right track?
  
  thanks
  
  Steve
  
  -- 
  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: Compare script fails (Solved!)

2002-12-06 Thread John W. Krahn
Michael Weber wrote:
 
 It was a trailing space in $_  that was getting me.  I changed a chomp
 to a chop and it now finds the string.

It would be better to use s/\s+$// to remove trailing whitespace as it
removes _only_ whitespace whereas chop will remove _any_ character from
the end of the string.



John
-- 
use Perl;
program
fulfillment

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




RE: Regex

2002-12-06 Thread Paul Kraus
Ummm no your are correct. I assumed it was imbedded in other text so do
this instead.
m/\bORA-(\d+)\b/

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] 
 Sent: Friday, December 06, 2002 2:03 PM
 To: [EMAIL PROTECTED]
 Subject: RE: Regex
 
 
  m/\s*ORA-(\d+)\s+/
 
 Correct me if I'm wrong, but wont this match fail if there are no 
 spaces after
 ORA-600
 
 I would think this is better
 if ($line =~ m/ORA-(\d+)/){$number = $1;}
 
   Hello list,
   
   I am trying to code a regex to pull out the number part of
   ORA-600 or 600.

   I have started with   if ($line =~ m/^(ORA-)(\-[0-9]*)$/) 
  { but this
   is obviously wrong.
   
   Anyone out there willing to get me on the right track?
   
   thanks
   
   Steve
   
   --
   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: Total Newbie

2002-12-06 Thread Dylan Boudreau
I bought the O'Reilly book Learning Perl as well as the O'Reilly Perl
pocket reference. I found the learning perl book to be a great starting
point and the pocket reference is invaluable for looking things up
quickly.

Dylan

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] 
Sent: December 6, 2002 1:50 PM
To: [EMAIL PROTECTED]
Subject: Total Newbie


Ok I am a total newbie when it comes to perl.  Could anyone please
direct to 
a site or something that will help me learn and start programing.  Any
help 
would be great.  Thanks.



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




RE: Snagging the last page of a report

2002-12-06 Thread Paul Kraus
What is $/ Is this a made up variable or a Perl special variable? I
don't recall coming across it in the learning Perl book. But I have just
started the programming Perl book.

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On 
 Behalf Of zentara
 Sent: Friday, December 06, 2002 6:36 AM
 To: [EMAIL PROTECTED]
 Subject: Re: Snagging the last page of a report
 
 
 On Thu, 5 Dec 2002 14:24:03 -0500, [EMAIL PROTECTED] (Paul Kraus)
 wrote:
 
 snip How to seek last 2k?
 
 Here's a start for you, getting the last 2k of the file. 
 Looping and checking for last page break is left up to you. :-)
 
 #!/usr/bin/perl -w
 use strict;
 
 my $filename = shift or die Usage: $0 file \n;
 
 # Open the file in read mode 
 open FILE, $filename or die Couldn't open $filename: $!;
 
 # Rewind from the end of the file until -2k 
 seek FILE,0, 2;  #go to EOF 
 seek FILE,-2048,2; #get last 2k bytes 
 
 $/=undef;
 my $tail = FILE;
 print $tail\n;
 exit;
 
 
 
 -- 
 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: Snagging the last page of a report

2002-12-06 Thread wiggins
Perl special variable it is the input separator.  From the camel (the real one):

Entirely undefining $/ makes the next line input operation slurp in the remainder of 
the file as one scalar value.

Which is how it was used in the first post. See $\ for the output separator.

It is a good idea to 'local' this beast before changing it.

http://danconia.org



On Fri, 6 Dec 2002 14:20:01 -0500, Paul Kraus [EMAIL PROTECTED] wrote:

 What is $/ Is this a made up variable or a Perl special variable? I
 don't recall coming across it in the learning Perl book. But I have just
 started the programming Perl book.
 
  -Original Message-
  From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On 
  Behalf Of zentara
  Sent: Friday, December 06, 2002 6:36 AM
  To: [EMAIL PROTECTED]
  Subject: Re: Snagging the last page of a report
  
  
  On Thu, 5 Dec 2002 14:24:03 -0500, [EMAIL PROTECTED] (Paul Kraus)
  wrote:
  
  snip How to seek last 2k?
  
  Here's a start for you, getting the last 2k of the file. 
  Looping and checking for last page break is left up to you. :-)
  
  #!/usr/bin/perl -w
  use strict;
  
  my $filename = shift or die Usage: $0 file \n;
  
  # Open the file in read mode 
  open FILE, $filename or die Couldn't open $filename: $!;
  
  # Rewind from the end of the file until -2k 
  seek FILE,0, 2;  #go to EOF 
  seek FILE,-2048,2; #get last 2k bytes 
  
  $/=undef;
  my $tail = FILE;
  print $tail\n;
  exit;
  
  
  
  -- 
  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: Snagging the last page of a report

2002-12-06 Thread wiggins
p.s.  see perldoc perlvar and search for INPUT_RECORD_SEPARATOR

http://danconia.org


On Fri, 6 Dec 2002 13:31:48 -0600, [EMAIL PROTECTED] wrote:

 Perl special variable it is the input separator.  From the camel (the real one):
 
 Entirely undefining $/ makes the next line input operation slurp in the remainder 
of the file as one scalar value.
 
 Which is how it was used in the first post. See $\ for the output separator.
 
 It is a good idea to 'local' this beast before changing it.
 
 http://danconia.org
 
 
 
 On Fri, 6 Dec 2002 14:20:01 -0500, Paul Kraus [EMAIL PROTECTED] wrote:
 
  What is $/ Is this a made up variable or a Perl special variable? I
  don't recall coming across it in the learning Perl book. But I have just
  started the programming Perl book.
  
   -Original Message-
   From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On 
   Behalf Of zentara
   Sent: Friday, December 06, 2002 6:36 AM
   To: [EMAIL PROTECTED]
   Subject: Re: Snagging the last page of a report
   
   
   On Thu, 5 Dec 2002 14:24:03 -0500, [EMAIL PROTECTED] (Paul Kraus)
   wrote:
   
   snip How to seek last 2k?
   
   Here's a start for you, getting the last 2k of the file. 
   Looping and checking for last page break is left up to you. :-)
   
   #!/usr/bin/perl -w
   use strict;
   
   my $filename = shift or die Usage: $0 file \n;
   
   # Open the file in read mode 
   open FILE, $filename or die Couldn't open $filename: $!;
   
   # Rewind from the end of the file until -2k 
   seek FILE,0, 2;  #go to EOF 
   seek FILE,-2048,2; #get last 2k bytes 
   
   $/=undef;
   my $tail = FILE;
   print $tail\n;
   exit;
   
   
   
   -- 
   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: Snagging the last page of a report

2002-12-06 Thread Paul Kraus
My reports seem to perform a form feed with ^L this doesn't seem to
all me to find it with regexpr. Do I have to search for the ASCII
equivalent? What does this translate to and where did you look to find
out?

Paul

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] 
 Sent: Friday, December 06, 2002 2:38 PM
 To: Paul Kraus
 Cc: [EMAIL PROTECTED]
 Subject: RE: Snagging the last page of a report
 
 
 p.s.  see perldoc perlvar and search for INPUT_RECORD_SEPARATOR
 
 http://danconia.org
 
 
 On Fri, 6 Dec 2002 13:31:48 -0600, [EMAIL PROTECTED] wrote:
 
  Perl special variable it is the input separator.  From the camel 
  (the real one):
  
  Entirely undefining $/ makes the next line input operation 
 slurp in 
  the remainder of the file as one scalar value.
  
  Which is how it was used in the first post. See $\ for the output 
  separator.
  
  It is a good idea to 'local' this beast before changing it.
  
  http://danconia.org
  
  
  
  On Fri, 6 Dec 2002 14:20:01 -0500, Paul Kraus 
 [EMAIL PROTECTED] 
  wrote:
  
   What is $/ Is this a made up variable or a Perl special 
   variable? I don't recall coming across it in the learning 
 Perl book. 
   But I have just started the programming Perl book.
   
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On
Behalf Of zentara
Sent: Friday, December 06, 2002 6:36 AM
To: [EMAIL PROTECTED]
Subject: Re: Snagging the last page of a report


On Thu, 5 Dec 2002 14:24:03 -0500, [EMAIL PROTECTED] (Paul 
Kraus)
wrote:

snip How to seek last 2k?

Here's a start for you, getting the last 2k of the file.
Looping and checking for last page break is left up to you. :-)

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

my $filename = shift or die Usage: $0 file \n;

# Open the file in read mode
open FILE, $filename or die Couldn't open $filename: $!;

# Rewind from the end of the file until -2k
seek FILE,0, 2;  #go to EOF 
seek FILE,-2048,2; #get last 2k bytes 

$/=undef;
my $tail = FILE;
print $tail\n;
exit;



--
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]
 


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




references in perl...

2002-12-06 Thread christopher j bottaro
hello,
i'm a c/c++ programmer trying to learn perl.  there are just some things that 
are much more easily done in a language like perl than in c/c++ i've found 
out...=)  anyways, i'm reading a short tutorial about references.  am i wrong 
in thinking they are like pointers in c/c++?

-- christopher

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




RE: references in perl...

2002-12-06 Thread Timothy Johnson

Yes and no.  I think that if you understand the concept of pointers, then
you will be able to understand references more easily, but from what keep
hearing from c/c++ people, there are differences.  Perhaps someone else on
the list can clarify more.

One thing that Perl can do with references that I don't _think_ you can do
in C is the concept of anonymous data structures.  Take this as an example.

my @arrayOfHashes = ();
push(@arrayOfHashes, {first = 'foo', second = 'bar', third =
'nuts'});

I've now added an element to @arrayOfHashes which is a pointer to an
anonymous hash containing three keys.  I can then access the hash like this:

foreach(@arrayOfHashes){
  print The first is $-{first}\n;
  print The second is ${$_}{second}\n;
  }

The first example accesses the key indirectly, and the second one
dereferences the $_ variable first.  In the second example, we could refer
to the hash as %{$_}.

-Original Message-
From: christopher j bottaro [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 06, 2002 11:58 AM
To: [EMAIL PROTECTED]
Subject: references in perl...


hello,
i'm a c/c++ programmer trying to learn perl.  there are just some things
that 
are much more easily done in a language like perl than in c/c++ i've found 
out...=)  anyways, i'm reading a short tutorial about references.  am i
wrong 
in thinking they are like pointers in c/c++?

-- christopher

-- 
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: references in perl...

2002-12-06 Thread wiggins


On Fri, 6 Dec 2002 13:57:33 -0600, christopher j bottaro [EMAIL PROTECTED] wrote:

 hello,
 i'm a c/c++ programmer trying to learn perl.  there are just some things that 
 are much more easily done in a language like perl than in c/c++ i've found 
 out...=)  

Definitely...

anyways, i'm reading a short tutorial about references.  am i wrong 
 in thinking they are like pointers in c/c++?
 

You are correct they are similar.  I hope your tutorial includes:

perldoc perlref
perldoc perlreftut

http://danconia.org

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




Re: references in perl...

2002-12-06 Thread christopher j bottaro
cool thanks.  and yes i'm reading perlreftut but not perlref.  perlref looks a 
bit too exhaustive for my purposes now.  perhaps in the future when i become 
more advanced in the ways of perl.

and Timothy, yeah i'm sure there are difference of course, but i guess i was 
asking very generally if it is a gross mistake to think of them as pointers.  
thanks for the example...=)

-- christopher

On Friday 06 December 2002 02:17 pm, [EMAIL PROTECTED] wrote:
 You are correct they are similar.  I hope your tutorial includes:

 perldoc perlref
 perldoc perlreftut

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




Re: Newest Version

2002-12-06 Thread Christopher D . Lewis
http://www.cpan.org/src/
links from that page get you where you want.  Install directions linked 
from perl.org are at 
http://dev.perl.org/perl5/news/2002/07/18/580ann/INSTALL

Best regards,
	Chris


On Thursday, December 5, 2002, at 01:40  PM, Paul Kraus wrote:

I see that the newest version of Perl 5.8.0 is out. But when I follow
the links to get it for my sco open server box it takes me to 5.0005.


Where can I get version 5.8 for sco?

Paul Kraus
Network Administrator
PEL Supply Company
216.267.5775 Voice
216-267-6176 Fax
www.pelsupply.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: Question: How do i start a program and get is pid ?

2002-12-06 Thread Hannes Krueger
I want to start a program in perl but i need to keep
the pid to be able to kill it in the future.

For exmple:

system(top );

this would start top, but then i wouldn't be able to
identify the process in order to kill it. Is there a
way to do this (other than using fork) ?



Have you tried to use open?

$PID_OF_TOP = open (FILEHANDLE, top |);

if you open a pipe to (or from) a process, open returns its PID. 
And you're able to get its output. (or write some data to its STDIN).

perldoc -f open


Hannes

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




default C compiler

2002-12-06 Thread Tony Yi
sun solaris  have come with perl, But it is use cc as default c
compiler. I don't have license Sun C compiler, Can I change to C
compiler to gcc.

Thanks in advance


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


RES: Hash Question

2002-12-06 Thread Igor Sutton Lopes
You can do something like this:

%url_options_hash = (times_visited=0);
%url_hash = (this_url=\%url_options_hash);
%usr_hash = (igor=\%url_hash);

print $usr_hash{igor}-{this_url}-{times_visited}, \n;
$usr_hash{igor}-{this_url}-{times_visited} = 1;
print $usr_hash{igor}-{this_url}-{times_visited}, \n;

That worked for me, you use in this case the reference for the 'inner' hashes.

Igor.


 - Mensagem original -
 De:   Sean Rowe [SMTP:[EMAIL PROTECTED]]
 Enviada em:   sexta-feira, 6 de dezembro de 2002 11:30
 Para: Beginners@perl. org (E-mail)
 Assunto:  Hash Question
 
 I need to keep track of a user, all the web pages a user has visited, and
 the number of times the user visited each page.  I get my information from a
 log file.  Here's how I would like to say it programmatically:
 
   $Hash{$User}{$Page}{$NumTimesVisited} = $ANumber;
 
 Is this possible?  If so, how would I traverse this, as I will not know
 before hand the values in the hash; I will need to use something like sort.
 Thank you.
 
 Sean Rowe
 
 
 -- 
 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: Hash Question

2002-12-06 Thread Jan Gruber
Hi, Sean  List

$Hash{$User}{$Page}{$NumTimesVisited} = $ANumber;
 Is this possible?  

Sure, this will work.

I would decrease the hash depth a bit: 
$Hash{$User}{$Page} = $NumTimesVisited;

 If so, how would I traverse this, as I will not know
 before hand the values in the hash; I will need to use something like sort.
 Thank you.

As you can see, you dont have to quote the hash keys, although this is rather 
a religious issue ;o) I prefer the nonquoted version, since imho its more 
readable.

Getting the elements is no too hard:

for (sort keys %Hash) {

  @pages = keys %{ $Hash{$_} }
  do sumfink with @pages .

}

HTH,
Jan
-- 
cat /dev/world | perl -e while () {(/(^.*? \?) 42 \!/)  (print $1)}
errors-(c)
- 

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




RE: Difference between $count++ and ++$count

2002-12-06 Thread Danny Miller
Well, it depends how you use them.

Strictly speaking, ++$count is faster than $count++.

say $count = 5

$num1 = $count++; #$num1 would = 5 and $count would = 6
$num2 = ++$count; #$num2 and $count would equal 6

Regards,

Danny

-Original Message-
From: Mystik Gotan [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 06, 2002 11:54 AM
To: [EMAIL PROTECTED]
Subject: Difference between $count++ and ++$count


Hiya,

is there any difference between $count++ and ++$count?
Just wondering.

Thanks.





_
Ontvang je Hotmail  Messenger berichten op je mobiele telefoon met Hotmail 
SMS http://www.msn.nl/jumppage/


-- 
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: default C compiler

2002-12-06 Thread Yacketta, Ronald
Yes,

You can dl and install a Solaris compatible version of gcc and use it to
install perl
I do not have the url handy, but their is a sun page for third party (GNU
type) software.

-Ron

-Original Message-
From: Tony Yi [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, December 04, 2002 15:30
To: [EMAIL PROTECTED]
Subject: default C compiler


sun solaris  have come with perl, But it is use cc as default c
compiler. I don't have license Sun C compiler, Can I change to C
compiler to gcc.

Thanks in advance


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




Re: Difference between $count++ and ++$count

2002-12-06 Thread Paul Johnson
On Fri, Dec 06, 2002 at 11:58:37AM -0500, Danny Miller wrote:

 Strictly speaking, ++$count is faster than $count++.

Strictly speaking, perl will convert $count++ to ++$count if it can.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

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




Re: Difference between $count++ and ++$count

2002-12-06 Thread Jeff 'japhy' Pinyan
On Dec 6, Paul Johnson said:

On Fri, Dec 06, 2002 at 11:58:37AM -0500, Danny Miller wrote:

 Strictly speaking, ++$count is faster than $count++.

Strictly speaking, perl will convert $count++ to ++$count if it can.

Strictly speaking, there is another major difference no one has mentioned
yet (and that many people might have trouble understanding).  Using
$count++ returns a NUMBER OR STRING, and then increments $count's value.
++$count increments $count's value, and returns THE SCALAR ITSELF.

How does this matter?  Well, watch:

  $i = 2;
  $j = ++$i / ++$i;

What do you think $j will be?  3/4?  Nope.  4/4, or 1.  The reason is
because the ++$i form is a footnote type of thing.  Basically it means
increment $i, but leave $i here whereas $i++ means return $i's value,
and then increment it.

Want to have your mind hurt?

  $i = 2;
  @j = (++$i, ++$i, ++$i);

What do you think @j will be?  (5,5,5)?  Yes, it will.  The elements of
the list ARE $i themselves, and each element's expression increments $i
once; so $i becomes 5, and then the list is ($i, $i, $i), and all those
are 5.  (Contrast this with ($i++, $i++, $i++), where the list is (2,3,4),
NOT ($i,$i,$i).)

Here's the brain-hurting:

  $i = 2;
  $j = ++$i + ++$i + ++$i;

What do you think $j will be?  3 + 4 + 5 = 12?  No.  5 + 5 + 5 = 15?  No.
(NO!?)  It will be 13.  4 + 4 + 5.  HOW does Perl manage that?  It's
because ++$i isn't executed until it's reached, and the THIRD one isn't
reached until the first two have been evaluated:

  $j = (++$i + ++$i) + ++$i;
  # ++$i sets $i to 3
  # ++$i sets $i to 4
  # ($i + $i) returns 8
  # ++$i sets $i to 5
  # 8 + $i returns 15

CRAZY.  Or logical.  Both, really.

Oops.  This is [EMAIL PROTECTED]  Sorry. ;)

-- 
Jeff japhy Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
stu what does y/// stand for?  tenderpuss why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


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




SetReadMode doc

2002-12-06 Thread Rob Das
Hi All:

I'm trying to find documentation on SetReadMode. It's in CPAN module
Term::ReadKey, which I can't persuade to work with Perl2exe (for NT AND
Solaris AND HP-UX), so I'd like to pick out the bits of code I need and put
them in my own script. First, I'd like to understand what SetReadMode is all
about. Please point me in the right direction if possible.

Thanks

Rob


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




Please help Simple Perl programm

2002-12-06 Thread Alfa rOMEO

Hi,

I have a problem and search for a simple perl solution:

Here are the task:

Source File:  Domainname TAB Username TAB Field TAB Fieldname

Example: Test TAB Peter TAB FAX TAB 0112345678


I want search in the source file after a special entry in the Fieldname . 
Want to read the Username and write then all lines with this username in a 
new file.






_
STOP MORE SPAM with the new MSN 8 and get 2 months FREE* 
http://join.msn.com/?page=features/junkmail


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



Re: references in perl...

2002-12-06 Thread Jeff 'japhy' Pinyan
On Dec 6, christopher j bottaro said:

i'm a c/c++ programmer trying to learn perl.  there are just some things that
are much more easily done in a language like perl than in c/c++ i've found
out...=)  anyways, i'm reading a short tutorial about references.  am i wrong
in thinking they are like pointers in c/c++?

They are similar in purpose, different in implementation.  As a C
programm, you hopefully know that pointers can be manipulated:

  int num[5] = { 2, 4, 8, 16, 32 };
  int *n = num;

  printf(%d + %d = %d\n, *n, *(n+1), *n + *(n+1));  # 2 + 4 = 6

You can add and subtract from pointers and C will do the right thing.
Specifically, (n + 1) becomes (n + 1 * sizeof(*n)).

In fact, we don't even NEED n here, because arrays are implicitly
pointers.  nums[0] is really *(nums + 0), and nums[1] is really *(nums +
1), which is really *(nums + 1 * sizeof(*nums)).

So, now that I've spilled the beans on pointers, how are Perl's references
not the same as pointers?  Well, Perl doesn't appreciate you mucking
around with the internals of its data storage.  You can't go:

  @nums = (1 .. 5);
  $nref = \@nums;
  print $$nref, $($nref + 1);

It doesn't work that way in Perl at ALL.  First of all, $$nref treats
$nref as a SCALAR reference, not an ARRAY reference.  Second, $(...) isn't
valid Perl syntax.  ${$nref + 1} is valid, but doesn't do anything like
you'd expect.

You can't do the equivalent of pointer arithmetic in Perl.  You merely
use the data the reference refers to:

  print $nref-[0], $nref-[1];  # like $nums[0], $nums[1]

Someone COULD write a Pointer class in Perl:

  use Pointer;
  my $p = Pointer-new([1 .. 5]);
  print $$p, ${$p + 1};

but I'd really question the usefulness of such a thing.  I'd write it, but
I'm afraid it would fall into the wrong hands and cause the sudden heat
death of the Universe.  Or would make a C or C++ programmer treat Perl
like C (no offense).

And Pointer.pm would need to do a whole lot overloading operators.  And
that's too much work for me right now. ;)

-- 
Jeff japhy Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
stu what does y/// stand for?  tenderpuss why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


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




simple Perl prog

2002-12-06 Thread Alfa rOMEO
Hi,

I have a problem and search after a simple perl solution:

I want to search in a file after a Username and write all lines with this 
username in a new file.

Example:

TestTABUSERTABPeterTABFAXTAB011234567
TestTABUSERTABPeterTABPHONETAB456789

and so on

Thank u for answer.

Best regards

Captain Mike





_
The new MSN 8: advanced junk mail protection and 2 months FREE* 
http://join.msn.com/?page=features/junkmail


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



Seek tell

2002-12-06 Thread Paul Kraus
I am reading through a file.
I am testing it for a regexrp. If expr is true then I save the pos of
the file to a variable using tell.

But it always the eof position an not the position directly before the
match. Any thoughts?

Paul Kraus
Network Administrator
PEL Supply Company
216.267.5775 Voice
216-267-6176 Fax
www.pelsupply.com


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


RE: Seek tell

2002-12-06 Thread Bob Showalter
 -Original Message-
 From: Paul Kraus [mailto:[EMAIL PROTECTED]]
 Sent: Friday, December 06, 2002 4:42 PM
 To: Perl
 Subject: Seek tell
 
 
 I am reading through a file.
 I am testing it for a regexrp. If expr is true then I save the pos of
 the file to a variable using tell.
 
 But it always the eof position an not the position directly before the
 match. Any thoughts?

Time to post your code :~)

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




RE: simple Perl prog

2002-12-06 Thread Kipp, James
what have you tried ?  

-Original Message-
From: Alfa rOMEO [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 06, 2002 4:36 PM
To: [EMAIL PROTECTED]
Subject: simple Perl prog


Hi,

I have a problem and search after a simple perl solution:

I want to search in a file after a Username and write all lines with this 
username in a new file.

Example:

TestTABUSERTABPeterTABFAXTAB011234567
TestTABUSERTABPeterTABPHONETAB456789

and so on

Thank u for answer.

Best regards

Captain Mike





_
The new MSN 8: advanced junk mail protection and 2 months FREE* 
http://join.msn.com/?page=features/junkmail


-- 
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: Seek tell

2002-12-06 Thread Paul Kraus
open FILE, $filename or die Couldn't open $filename : $!\n; 
seek (FILE,0,2); 
for($i=-2048;1;$i-=2048){
seek (FILE,$i,1);
$/=undef;
$data=FILE;
if ($data=~m/\f([0-9][0-9]\/[0-9][0-9]\/[0-9][0-9])/){
$pos=tell (FILE);
print $pos --pos\n;
last;
}
}
seek (FILE,$pos,0);
$/=undef;
$end=FILE;
print $end\n;

 -Original Message-
 From: Bob Showalter [mailto:[EMAIL PROTECTED]] 
 Sent: Friday, December 06, 2002 4:44 PM
 To: 'Paul Kraus'; Perl
 Subject: RE: Seek tell
 
 
  -Original Message-
  From: Paul Kraus [mailto:[EMAIL PROTECTED]]
  Sent: Friday, December 06, 2002 4:42 PM
  To: Perl
  Subject: Seek tell
  
  
  I am reading through a file.
  I am testing it for a regexrp. If expr is true then I save 
 the pos of 
  the file to a variable using tell.
  
  But it always the eof position an not the position directly 
 before the 
  match. Any thoughts?
 
 Time to post your code :~)
 


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




Re: Difference between $count++ and ++$count

2002-12-06 Thread wiggins
He forgot to mention the:

use Advil;

$pills = new Advil(2);
unless($pills-take(orally)) {
  sleep 40;
}

http://danconia.org



On Fri, 6 Dec 2002 16:22:19 -0500 (EST), Jeff 'japhy' Pinyan [EMAIL PROTECTED] 
wrote:

 On Dec 6, Paul Johnson said:
 
 On Fri, Dec 06, 2002 at 11:58:37AM -0500, Danny Miller wrote:
 
  Strictly speaking, ++$count is faster than $count++.
 
 Strictly speaking, perl will convert $count++ to ++$count if it can.
 
 Strictly speaking, there is another major difference no one has mentioned
 yet (and that many people might have trouble understanding).  Using
 $count++ returns a NUMBER OR STRING, and then increments $count's value.
 ++$count increments $count's value, and returns THE SCALAR ITSELF.
 
 How does this matter?  Well, watch:
 
   $i = 2;
   $j = ++$i / ++$i;
 
 What do you think $j will be?  3/4?  Nope.  4/4, or 1.  The reason is
 because the ++$i form is a footnote type of thing.  Basically it means
 increment $i, but leave $i here whereas $i++ means return $i's value,
 and then increment it.
 
 Want to have your mind hurt?
 
   $i = 2;
   @j = (++$i, ++$i, ++$i);
 
 What do you think @j will be?  (5,5,5)?  Yes, it will.  The elements of
 the list ARE $i themselves, and each element's expression increments $i
 once; so $i becomes 5, and then the list is ($i, $i, $i), and all those
 are 5.  (Contrast this with ($i++, $i++, $i++), where the list is (2,3,4),
 NOT ($i,$i,$i).)
 
 Here's the brain-hurting:
 
   $i = 2;
   $j = ++$i + ++$i + ++$i;
 
 What do you think $j will be?  3 + 4 + 5 = 12?  No.  5 + 5 + 5 = 15?  No.
 (NO!?)  It will be 13.  4 + 4 + 5.  HOW does Perl manage that?  It's
 because ++$i isn't executed until it's reached, and the THIRD one isn't
 reached until the first two have been evaluated:
 
   $j = (++$i + ++$i) + ++$i;
   # ++$i sets $i to 3
   # ++$i sets $i to 4
   # ($i + $i) returns 8
   # ++$i sets $i to 5
   # 8 + $i returns 15
 
 CRAZY.  Or logical.  Both, really.
 
 Oops.  This is [EMAIL PROTECTED]  Sorry. ;)
 
 -- 
 Jeff japhy Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
 RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
 stu what does y/// stand for?  tenderpuss why, yansliterate of course.
 [  I'm looking for programming work.  If you like my work, let me know.  ]
 
 
 -- 
 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: simple Perl prog

2002-12-06 Thread Wagner, David --- Senior Programmer Analyst --- WGO
So do you want to bring together all the data related to Peter,
James, etc, so you can write another file with all the data together or you
are searching for Peter and ONLY want to write out the data of Peter?

Wags ;)

-Original Message-
From: Alfa rOMEO [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 06, 2002 13:36
To: [EMAIL PROTECTED]
Subject: simple Perl prog


Hi,

I have a problem and search after a simple perl solution:

I want to search in a file after a Username and write all lines with this 
username in a new file.

Example:

TestTABUSERTABPeterTABFAXTAB011234567
TestTABUSERTABPeterTABPHONETAB456789

and so on

Thank u for answer.

Best regards

Captain Mike





_
The new MSN 8: advanced junk mail protection and 2 months FREE* 
http://join.msn.com/?page=features/junkmail


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


**
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.



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




RE: Seek tell

2002-12-06 Thread Bob Showalter
 -Original Message-
 From: Paul Kraus [mailto:[EMAIL PROTECTED]]
 Sent: Friday, December 06, 2002 4:50 PM
 To: 'Bob Showalter'; 'Perl'
 Subject: RE: Seek tell
 
 

suggest you add:

   use Fcntl qw(:seek);

then you can use the SEEK_* constants to make your code more readable.

 open FILE, $filename or die Couldn't open $filename : $!\n; 
 seek (FILE,0,2); 
 for($i=-2048;1;$i-=2048){
 seek (FILE,$i,1);
 $/=undef;
 $data=FILE;

Reading the file moves the pointer. Since you undef'ed $/, the pointer will
be at EOF after this statement.

 if ($data=~m/\f([0-9][0-9]\/[0-9][0-9]\/[0-9][0-9])/){
   $pos=tell (FILE);

This is always at EOF. You need to call tell() before you read from the file
(i.e. right after the seek above).

   print $pos --pos\n;
   last;
 }
 }
 seek (FILE,$pos,0);
 $/=undef;
 $end=FILE;
 print $end\n;
 
  -Original Message-
  From: Bob Showalter [mailto:[EMAIL PROTECTED]] 
  Sent: Friday, December 06, 2002 4:44 PM
  To: 'Paul Kraus'; Perl
  Subject: RE: Seek tell
  
  
   -Original Message-
   From: Paul Kraus [mailto:[EMAIL PROTECTED]]
   Sent: Friday, December 06, 2002 4:42 PM
   To: Perl
   Subject: Seek tell
   
   
   I am reading through a file.
   I am testing it for a regexrp. If expr is true then I save 
  the pos of 
   the file to a variable using tell.
   
   But it always the eof position an not the position directly 
  before the 
   match. Any thoughts?
  
  Time to post your code :~)
  
 

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




RE: Seek tell

2002-12-06 Thread Jeff 'japhy' Pinyan
On Dec 6, Paul Kraus said:

if ($data=~m/\f([0-9][0-9]\/[0-9][0-9]\/[0-9][0-9])/){
   $pos=tell (FILE);
   print $pos --pos\n;
   last;
}

You don't want tell(FILE).  You want to know WHERE in $data the pattern
matched.  For that, use the @- array (if you've got Perl 5.6 or better).

  if ($data =~ m[\f\d{2}/\d{2}/\d{2}]) {
$p = $-[0];
last;
  }

If you don't have Perl 5.6, you'll need to be a bit more creative:

  if ($data =~ m[(\f\d{2}/\d{2}/\d{2})]g) {
$p = pos($data) - length $1;
last;
  }

-- 
Jeff japhy Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
stu what does y/// stand for?  tenderpuss why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


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




Re: Difference between $count++ and ++$count

2002-12-06 Thread Paul Johnson
On Fri, Dec 06, 2002 at 04:22:19PM -0500, Jeff 'japhy' Pinyan wrote:
 On Dec 6, Paul Johnson said:
 
 On Fri, Dec 06, 2002 at 11:58:37AM -0500, Danny Miller wrote:
 
  Strictly speaking, ++$count is faster than $count++.
 
 Strictly speaking, perl will convert $count++ to ++$count if it can.
 
 Strictly speaking, there is another major difference no one has mentioned
 yet (and that many people might have trouble understanding).  Using
 $count++ returns a NUMBER OR STRING, and then increments $count's value.
 ++$count increments $count's value, and returns THE SCALAR ITSELF.
 
 How does this matter?  Well, watch:

[ fun and games with ++ ]

 CRAZY.  Or logical.  Both, really.

Documented.  And guaranteed not to change.  Neither, really.

( At least, I don't think so. )

I'm reminded of the man page for csh:

  Although robust enough for general use, adventures into the esoteric
  periphery of the C shell may reveal unexpected quirks.

Fortunately, Perl's esoteria is less pronounced than that of the C shell.

 Oops.  This is [EMAIL PROTECTED]  Sorry. ;)

Perl internals for beginners :-)

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

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




Re: Difference between $count++ and ++$count

2002-12-06 Thread david
Jeff 'Japhy' Pinyan wrote:

 
 Strictly speaking, there is another major difference no one has mentioned
 yet (and that many people might have trouble understanding).  Using
 $count++ returns a NUMBER OR STRING, and then increments $count's value.
 ++$count increments $count's value, and returns THE SCALAR ITSELF.
 
 How does this matter?  Well, watch:
 
   $i = 2;
   $j = ++$i / ++$i;
 
 What do you think $j will be?  3/4?  Nope.  4/4, or 1.  The reason is
 because the ++$i form is a footnote type of thing.  Basically it means
 increment $i, but leave $i here whereas $i++ means return $i's value,
 and then increment it.
 

I don't know what you mean by returns THE SCALAR ITSELF? You mean the 
actual scalar, it's lvalue? Not the case.

$i = 1;
++$i = 2;
$i++ = 2;

are both invalid for the same reason as they only return the value of $i, 
not the scalar itself. The same reason why the following statment can 
almost never be valid in most programming languages:

++$i++;

why? because both the pre and the post increment only returns the value 
(which is a constant) of $i and thus can never be assigned to anything. No 
matter which one executes first, the next increment will always fail. 

david

btw, the ++$i / ++$i gives you a 1 thing behaves differently in other 
programming languages. For example, try the following in C++:

#includeiostream.h
void main{
int i=2;
int j=++i/++i;
coutjendl;
}

won't give you a 1.

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




Re: Difference between $count++ and ++$count

2002-12-06 Thread Paul Johnson
On Fri, Dec 06, 2002 at 02:46:13PM -0800, david wrote:

 btw, the ++$i / ++$i gives you a 1 thing behaves differently in other 
 programming languages. For example, try the following in C++:
 
 #includeiostream.h
 void main{
 int i=2;
 int j=++i/++i;
 coutjendl;
 }
 
 won't give you a 1.

But it might.  The behaviour is undefined.  The compiler may do as it
will.  Google for sequence point if you want to find out more.

The behaviour in Perl is undefined too, but more in the sense that the
behaviour has not been defined rather than that the behaviour has been
defined as undsefined.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

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




CRLF UNIX-windows windows -unix

2002-12-06 Thread Mark Goland
Hi guys, I am trying to write a client/server app. The problem I am having,
has to do with line terminators. my questions is when I connect from unix to
windows do I need to set $\= CRLF and form windows to unix $\=LF ?? also is
there a method to deturnime which machine is connecting to which ??. I am
using standard Socket library.

Thanx in advance,
Mark


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




Re: Snagging the last page of a report

2002-12-06 Thread John W. Krahn
Paul Kraus wrote:
 
 My reports seem to perform a form feed with ^L this doesn't seem to
 all me to find it with regexpr. Do I have to search for the ASCII
 equivalent? What does this translate to and where did you look to find
 out?

The form feed character is reresented by \f (or \cL or \014 or \xC) in
double quoted strings.  These special characters are described in the
Quote and Quote-like Operators section of the perlop manpage.

perldoc perlop



John
-- 
use Perl;
program
fulfillment

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




Re: Difference between $count++ and ++$count

2002-12-06 Thread david
Paul Johnson wrote:

 But it might.  The behaviour is undefined.  The compiler may do as it
 will.  Google for sequence point if you want to find out more.
 
 The behaviour in Perl is undefined too, but more in the sense that the
 behaviour has not been defined rather than that the behaviour has been
 defined as undsefined.


True, maybe.

But I don't know what you mean by the behaviour in Perl is undefined.
To me, the behaviour is well defined (ie, you won't find an exception where 
the above bahaviour will behaves differently). it's simply $i / $i which 
always gives you a 1 in Perl except where $i = 0
david

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




RE: Regex

2002-12-06 Thread Steve Main
Thanks Gang,

I ended up with 

 if ( $line =~ m/^(ORA-\d+):/ ) {



-Original Message-
From: Paul Kraus [mailto:[EMAIL PROTECTED]] 
Sent: Friday, December 06, 2002 11:11 AM
To: [EMAIL PROTECTED]; Perl
Subject: RE: Regex


Ummm no your are correct. I assumed it was imbedded in other text so do
this instead.
m/\bORA-(\d+)\b/

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] 
 Sent: Friday, December 06, 2002 2:03 PM
 To: [EMAIL PROTECTED]
 Subject: RE: Regex
 
 
  m/\s*ORA-(\d+)\s+/
 
 Correct me if I'm wrong, but wont this match fail if there are no 
 spaces after
 ORA-600
 
 I would think this is better
 if ($line =~ m/ORA-(\d+)/){$number = $1;}
 
   Hello list,
   
   I am trying to code a regex to pull out the number part of
   ORA-600 or 600.

   I have started with   if ($line =~ m/^(ORA-)(\-[0-9]*)$/) 
  { but this
   is obviously wrong.
   
   Anyone out there willing to get me on the right track?
   
   thanks
   
   Steve
   
   --
   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]

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




This perl script does nothing....

2002-12-06 Thread Jonathan Daniels
Hi, 

Hopefully this isn't too stupid of a question.  Thanks in advance for any
help.

Can anyone tell me why, when I feed a file of the following format

Date,Time,Action,Result,Client,Server,From,To,To,To,...,Subject,Size,SMTPID

20021128,9,Message Accepted,,10.0.0.1,,[EMAIL PROTECTED],[EMAIL PROTECTED],...

This type of line many more times

To the following script it does nothing.  Nothing at all.  No errors, just
returns to the command prompt.


#!/usr/bin/perl

while (){

chomp;

if (/^.*\@/g){ # find the first @ remember where it is.

if (/\G(domain)/i){#go back and look for domain

print ;  #if you find domain print the line.
}

}

else{

print No Match.\n;


}
   
}

 

Thanks,

Jonathan



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




Re: Difference between $count++ and ++$count

2002-12-06 Thread Dr. Poo

HAHAHAHAHAHA! 

-Chris

On Friday 06 December 2002 03:51 pm, [EMAIL PROTECTED] wrote:
 He forgot to mention the:

 use Advil;

 $pills = new Advil(2);
 unless($pills-take(orally)) {
   sleep 40;
 }

 http://danconia.org


 

 On Fri, 6 Dec 2002 16:22:19 -0500 (EST), Jeff 'japhy' Pinyan 
[EMAIL PROTECTED] wrote:
  On Dec 6, Paul Johnson said:
  On Fri, Dec 06, 2002 at 11:58:37AM -0500, Danny Miller wrote:
   Strictly speaking, ++$count is faster than $count++.
  
  Strictly speaking, perl will convert $count++ to ++$count if it can.
 
  Strictly speaking, there is another major difference no one has mentioned
  yet (and that many people might have trouble understanding).  Using
  $count++ returns a NUMBER OR STRING, and then increments $count's value.
  ++$count increments $count's value, and returns THE SCALAR ITSELF.
 
  How does this matter?  Well, watch:
 
$i = 2;
$j = ++$i / ++$i;
 
  What do you think $j will be?  3/4?  Nope.  4/4, or 1.  The reason is
  because the ++$i form is a footnote type of thing.  Basically it means
  increment $i, but leave $i here whereas $i++ means return $i's value,
  and then increment it.
 
  Want to have your mind hurt?
 
$i = 2;
@j = (++$i, ++$i, ++$i);
 
  What do you think @j will be?  (5,5,5)?  Yes, it will.  The elements of
  the list ARE $i themselves, and each element's expression increments $i
  once; so $i becomes 5, and then the list is ($i, $i, $i), and all those
  are 5.  (Contrast this with ($i++, $i++, $i++), where the list is
  (2,3,4), NOT ($i,$i,$i).)
 
  Here's the brain-hurting:
 
$i = 2;
$j = ++$i + ++$i + ++$i;
 
  What do you think $j will be?  3 + 4 + 5 = 12?  No.  5 + 5 + 5 = 15?  No.
  (NO!?)  It will be 13.  4 + 4 + 5.  HOW does Perl manage that?  It's
  because ++$i isn't executed until it's reached, and the THIRD one isn't
  reached until the first two have been evaluated:
 
$j = (++$i + ++$i) + ++$i;
# ++$i sets $i to 3
# ++$i sets $i to 4
# ($i + $i) returns 8
# ++$i sets $i to 5
# 8 + $i returns 15
 
  CRAZY.  Or logical.  Both, really.
 
  Oops.  This is [EMAIL PROTECTED]  Sorry. ;)
 
  --
  Jeff japhy Pinyan  [EMAIL PROTECTED] 
  http://www.pobox.com/~japhy/ RPI Acacia brother #734  
  http://www.perlmonks.org/   http://www.cpan.org/ stu what does y///
  stand for?  tenderpuss why, yansliterate of course. [  I'm looking for
  programming work.  If you like my work, let me know.  ]
 
 
  --
  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]