Re: Printing has me confused

2001-05-31 Thread Ken

Well, I made a wild stab in the dark and though you might have a control character at 
the end of something.

When I run this code(note the \r at the end of rname):
$ltr = "LETTER";
$rname = "MICROFILM\r";
$numltrs = 4;
$rdate = "30May01";
$pdate = "31May01";
$cntr=1;
$new_fn="$ltr.$rname.$numltrs.$rdate.$pdate.$cntr";
print "new_fn=$new_fn";

I get this as the result:
.4.30May01.31May01.1ILM

The results aren't identical but close enough to assume there is a control code in 
there somehwere.

If you're reading this input from a file maybe try using a chomp?

Hope this helps!
Ken

  - Original Message - 
  From: Gary Luther 
  To: [EMAIL PROTECTED] 
  Sent: Thursday, May 31, 2001 12:00 PM
  Subject: Printing has me confused


  I am writing a program and am being baffled by what is happening.  Here is a section 
of the debug session:

DB<1>
  main::(/common/bin/whaduname.LTR:98):
  98: $new_fn="$ltr.$rname.$numltrs.$rdate.$pdate.$cntr";
DB<1>
  main::(/common/bin/whaduname.LTR:99):
  99: print "New FN = $new_fn\n";
DB<1> print $new_fn
  .4.30May01.31May01.1  < notice that $ltr and $rname are not present
DB<2> print $ltr  <=== $ltr has a value
  LETTER
DB<3> print $rname <== $rname has a value
  MCROFILM
DB<4> print $numltrs
  4
DB<5> print $rdate
  30May01
DB<6> print $pdate
  31May01
DB<7> print $cntr
  1
DB<8> n
  .4.30May01.31May01.1FILM <== where did the FILM come from?? I dont work for Kodak!
  main::(/common/bin/whaduname.LTR:102):
  102:$last_old_name = $old_name;

  Am I losing my mind??   Here is what I expect in $new_fn ==> 
LETTER.MCROFILM.4.30May01.31May01.1
   
  TIA

  --
  -
  "They that can give up essential liberty 
 to obtain a little temporary safety 
 deserve neither liberty  nor safety."  

  -- Benjamin Franklin 
  -
  RGary Luther
  RR  RR   SAF
  RR  RR UTABEGAS  2500 Broadway
  RR RRHelena, MT 59602
   [EMAIL PROTECTED]
  RR RR  ULE !!
  RR  RR   Visit our website at
  RR   RR  http://www.safmt.org




Re: sprintf

2001-05-31 Thread Ken

%s prints out strings

For a complete list look at:
perldoc -f sprintf

Skip to the part that begins(about the second 24 line page):
Perl's "sprintf" permits the following universally-known conversions

- Original Message - 
From: "Nichole Bialczyk" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, May 31, 2001 4:12 PM
Subject: sprintf


> i know that for numbers you can use sprintf %u, %i etc
> 
> is there something similair for alphnumerics?
> 
> nichole
> 




Re: printf and other stuff

2001-06-01 Thread Ken

Remove the ()'s and it works.

For the 0's:
printf "On %02d/%02d/%04d At %02d:%02d you wrote:\n\n", $month, $mday,
$year, $hour, $min;
see perldoc -f printf for more info.
- Original Message -
From: "David Gilden" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, June 01, 2001 1:05 PM
Subject: printf and other stuff


> Good afternoon,
>
> Is there a way to combine the last two statements?
>
> #!/usr/bin/perl -w
>
> $sort_order =0;
>
> $sort_type = ($sort_order) ? 'Newest First' : 'Oldest First';
> # are the () optional?
>
> print $sort_type;
>
>
> ##this does not work
>
> print ($sort_order) ? 'Newest First' : 'Oldest First';
>
> printf question--
>
> ### get time
> my($sec, $min, $hour, $mday, $month, $year) = (localtime)[0..5];
> $year += 1900;
> $mday = "0" . $mday if $mday < 10;
> $month++; # perl counts from -1 on occasion
> $month = "0" . $month if $month < 10;
> 
>
> -- later in the same file --
>
> print TOFILE "On $month/$mday/$year At $hour:$min you wrote:\n\n";
>
> how do I use print to provide a leading '0' to $min, such that
> I get 5:01 and not 5:1
>
>
> Thanks!
>
> Dave G.
>
>




Re: i'm warning you, this is a toughie!

2001-06-04 Thread Ken

The problem here is that most web servers give the outside world acces to
files under the WWW root directory.  Since /tmp is not one of the
directories under the WWW root you can't get to it.

I have never done this myself but you might want to try to make a symbolic
link in the WWW root directory to the /tmp directory, like this (this
assumes you are in the WWW root dir):

ln -s /tmp tmp

The only drawback to this is that now anyone can access your /tmp directory.
You may want to consider making a subdirectoy such as /tmp/log and linking
that(also in WWW root):

ln -s /tmp/logs logs

Hope this helps!
Ken
- Original Message -
From: "Nichole Bialczyk" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, June 04, 2001 3:33 PM
Subject: i'm warning you, this is a toughie!


> the bossman has requested the following:
>
> he wants my logfiles written to our server in the /tmp directory. my
> scripts are in the cgi-bin of our afs account. even though the files are
> set with 777 permissions, the outside world can not write to these files.
> here is part of one of my scripts:
>
> #don't log these machines into the logfile
> my @my_addr = qw(r-squirrel.cc.umr.edu poohbear.cc.umr.edu
vixen.cc.umr.edu
> helix.cc.umr.edu);
>
> #determine the name and location of the logfile
> my $logfile = "/tmp/newlog.txt";
>
> #if the user is one of our machines, don't login
> foreach my $address(@my_addr) {
>if ($ENV{'REMOTE_HOST'} eq $address) {
>   &redir;
>   exit;
>}
> }
>
> &log;
> &redir;
> exit;
>
> sub log {
>unless (open(LOG,">>$logfile")) {
>   print "Content-type: text/html\n\n";
>   print "Couldn't open $logfile\n";
>   exit;
>}
>#the logfile is opened
>
>
> etc, etc
>
> if you can solve this one, then i declare you resident genius of perl.
> (at least until i come up with another problem)
>
> :) nichole
>




Re: Installing and configuring DBI and DBD::Oracle

2001-06-08 Thread Ken

I am going to assume you installed the precompiled binaries from active
state.

Type in at a command prompt window:
perl -v

Look for the line that mentions which binary build it is...
Mine says: "Binary build 626 provided by ActiveState Tool Corp"

If yours says 6xx you want the following link:
http://www.activestate.com/PPMPackages/zips/6xx-builds-only/

If it says 5xx you want this:
http://www.activestate.com/PPMPackages/zips/5xx-builds-only/

Download the files and follow the instructions in the readme file.

- Original Message -
From: "EOIN SHALLOO" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, June 08, 2001 2:43 AM
Subject: Installing and configuring DBI and DBD::Oracle


> > Hi,
> >
> > I hope someone can help as I am new at Perl and configuring its setup.
> >
> > Setup: NT Service Pack 5
> > Oracle iAS 1.0.2.1 (with Apache Apache/1.3.12 Server)
> > Oracle 8.1.7 Release3
> > Perl 5.00503
> >
> >





Re: regex matching

2001-06-14 Thread Ken

\d only matches one digithere's a way to extract each number from an ip:
use strict;
my( $ip );
print "Enter a string with an IP:";
$ip = ;
$ip =~ m/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
print "$1\n";
print "$2\n";
print "$3\n";
print "$4\n";

Or if you just want the ip from the line:
use strict;
my( $ip );
print "Enter a string with an IP:";
$ip = ;
$ip =~ m/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/;
print "The ip is: $1\n";

To just make sure what you have is an ip (and only an ip) is:
m/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;



- Original Message - 
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, June 14, 2001 9:12 AM
Subject: regex matching


> i have a basic knowledge of regex but i want to know if there is a
> simpler way to pull patterns out of a line.
> 
> if i have a line like:
> 
>   here is a sample with 123.456.123.456 in the middle.
> 
> m/\d\.\d\.\d\.\d/ will match the entire line. is there an easy way to
> get only the ip address?
> 
> thanks..
> 
> Brian T. Wallace
> Engineer
> 
> 




Re: regex matching

2001-06-14 Thread Ken

Doesn't {1,3} mean minimum of 1 and maximum of 3 of whatever character comes
before the {}'s?

I ran this code with the following ip:
192.168.0.34
It works fine.

- Original Message -
From: "John Edwards" <[EMAIL PROTECTED]>
To: "'Ken'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
Sent: Thursday, June 14, 2001 9:40 AM
Subject: RE: regex matching


> "To just make sure what you have is an ip (and only an ip) is:
> m/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;"
>
> Not true. An IP can only consist of numbers ranging from 0 to 255. Your
> example will match an 'IP' that looks like this;
>
> 311.497.999.587
>
> for instance.
>
> The example I gave isn't perfect (and I nicked the essentials of it from
the
> Perl Cookbook) but it will at least not match on completely wrong IPs.
>
> John
>
> -Original Message-
> From: Ken [mailto:[EMAIL PROTECTED]]
> Sent: 14 June 2001 16:32
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: Re: regex matching
>
>
> \d only matches one digithere's a way to extract each number from an
ip:
> use strict;
> my( $ip );
> print "Enter a string with an IP:";
> $ip = ;
> $ip =~ m/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
> print "$1\n";
> print "$2\n";
> print "$3\n";
> print "$4\n";
>
> Or if you just want the ip from the line:
> use strict;
> my( $ip );
> print "Enter a string with an IP:";
> $ip = ;
> $ip =~ m/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/;
> print "The ip is: $1\n";
>
> To just make sure what you have is an ip (and only an ip) is:
> m/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
>
>
>
> - Original Message -
> From: <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, June 14, 2001 9:12 AM
> Subject: regex matching
>
>
> > i have a basic knowledge of regex but i want to know if there is a
> > simpler way to pull patterns out of a line.
> >
> > if i have a line like:
> >
> >   here is a sample with 123.456.123.456 in the middle.
> >
> > m/\d\.\d\.\d\.\d/ will match the entire line. is there an easy way to
> > get only the ip address?
> >
> > thanks..
> >
> > Brian T. Wallace
> > Engineer
> >
> >
>
>
> --Confidentiality--.
> This E-mail is confidential.  It should not be read, copied, disclosed or
> used by any person other than the intended recipient.  Unauthorised use,
> disclosure or copying by whatever medium is strictly prohibited and may be
> unlawful.  If you have received this E-mail in error please contact the
> sender immediately and delete the E-mail from your system.
>
>
>




Re: regex matching

2001-06-14 Thread Ken

Ok, strike my previous comments.

My apologies for wasting your time.


- Original Message -
From: "Ken" <[EMAIL PROTECTED]>
To: "John Edwards" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Thursday, June 14, 2001 9:45 AM
Subject: Re: regex matching


> Doesn't {1,3} mean minimum of 1 and maximum of 3 of whatever character
comes
> before the {}'s?
>
> I ran this code with the following ip:
> 192.168.0.34
> It works fine.
>
> - Original Message -
> From: "John Edwards" <[EMAIL PROTECTED]>
> To: "'Ken'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>;
> <[EMAIL PROTECTED]>
> Sent: Thursday, June 14, 2001 9:40 AM
> Subject: RE: regex matching
>
>
> > "To just make sure what you have is an ip (and only an ip) is:
> > m/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;"
> >
> > Not true. An IP can only consist of numbers ranging from 0 to 255. Your
> > example will match an 'IP' that looks like this;
> >
> > 311.497.999.587
> >
> > for instance.
> >
> > The example I gave isn't perfect (and I nicked the essentials of it from
> the
> > Perl Cookbook) but it will at least not match on completely wrong IPs.
> >
> > John
> >
> > -Original Message-
> > From: Ken [mailto:[EMAIL PROTECTED]]
> > Sent: 14 June 2001 16:32
> > To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> > Subject: Re: regex matching
> >
> >
> > \d only matches one digithere's a way to extract each number from an
> ip:
> > use strict;
> > my( $ip );
> > print "Enter a string with an IP:";
> > $ip = ;
> > $ip =~ m/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/;
> > print "$1\n";
> > print "$2\n";
> > print "$3\n";
> > print "$4\n";
> >
> > Or if you just want the ip from the line:
> > use strict;
> > my( $ip );
> > print "Enter a string with an IP:";
> > $ip = ;
> > $ip =~ m/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/;
> > print "The ip is: $1\n";
> >
> > To just make sure what you have is an ip (and only an ip) is:
> > m/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
> >
> >
> >
> > - Original Message -
> > From: <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Thursday, June 14, 2001 9:12 AM
> > Subject: regex matching
> >
> >
> > > i have a basic knowledge of regex but i want to know if there is a
> > > simpler way to pull patterns out of a line.
> > >
> > > if i have a line like:
> > >
> > >   here is a sample with 123.456.123.456 in the middle.
> > >
> > > m/\d\.\d\.\d\.\d/ will match the entire line. is there an easy way to
> > > get only the ip address?
> > >
> > > thanks..
> > >
> > > Brian T. Wallace
> > > Engineer
> > >
> > >
> >
> >
> > --Confidentiality--.
> > This E-mail is confidential.  It should not be read, copied, disclosed
or
> > used by any person other than the intended recipient.  Unauthorised use,
> > disclosure or copying by whatever medium is strictly prohibited and may
be
> > unlawful.  If you have received this E-mail in error please contact the
> > sender immediately and delete the E-mail from your system.
> >
> >
> >
>
>




Re: Another Regex Question

2001-06-21 Thread Ken

One thing to do would be to test for Tide in the line(Assuming all tide data
ends with the word "Tide") right away...then do special stuff for each case
in an if:

if( /Tide$/ ) # If last word in line is Tide
{
}
else # Must be lunar
{
}

And just a note, if you're just going to put the date and time fields back
together, don't seperate them in your pattern match.

($date, $time, ... ) = ^(\d+-\d+-\d+)\s+(\d+:\d+)...$/

- Original Message -
From: "Jack Lauman" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, June 21, 2001 3:48 PM
Subject: Another Regex Question


> I'm trying to create a CSV file from the text data below.  Lines
> containing High and Low Tide data have 9 fields, lines having
> sunrise/sunset and lunar data have 8 fields.
>
> How you differentiate between the two conditions?
>
> 2000-12-03 11:30 AM PST   9.39 feet  High Tide
> 2000-12-03  4:15 PM PST   Sunset
> 2000-12-03  7:56 PM PST   First Quarter
> 2000-12-04  3:42 AM PST   2.81 feet  Low Tide
> 2000-12-04  7:48 AM PST   Sunrise
>
> <->
>
> while () {
>
> ($year, $month, $mday, $hour, $minute, $am_pm, $tz, $height, $cond)
> =
> ^(\d+)-(\d+)-(\d+)\s+(\d+):(\d+)\s+([A-Z]{2})\s+([A-Z]{3})\s+
> ([0-9A-Za-z-.\s]{11})\s+(\w+\s+\w+)/;
>
> $year and $started++;
>
> if ($cond) {
> ($year, $month, $mday, $hour, $minute, $am_pm, $tz, $cond) =
> /^(\d+)-(\d+)-(\d+)\s+(\d+):(\d+)\s+([A-Z]{2})\s+([A-Z]{3})\s+
> ([A-Za-z\s])/;
>
> $date = "$year-$month-$mday";
> $time = "$hour:$minute";
> # Strip the leading and trailing spaces from $height
> StripLTSpace($height);
>
> printf OUTFILE "%s\,%s\,%s\,%s\,%s\,%s\n",
> $date, $time, $am_pm, $tz, $height, $cond;
> }
>
> }
>
> $started or print STDERR "Didn't find a tides line";
>
> close(INFILE);
> close(OUTFILE);
> print STDERR "\n";
>
> 1;
>




Re: Simple Split Question

2001-06-29 Thread Ken

Well, the reason it's not working is that there is only one Dimview between
pairs, for a hash you need seperators between all elements.  Here's a way to
do it, although I bet others can come up with a quicker/more efficient way:


my (%hash);
$_ = 'DimView 1 "All" DimView 2 "Some" DimView 3 "Most" DimView 4 "None"';


s/DimView file://g;
s/\"//g;
%hash = split( / / );


# Note, for those of you who have an option in your email program to
highlight web addresses the DimView line may have an extra file: in it.
Mine does *mumble* Took me a few minutes to figure out why!


- Original Message -
From: "Seitz, Scott" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, June 28, 2001 2:32 PM
Subject: Simple Split Question


> I'm having trouble with what I think is a very simple split question.
>
> I've got a line of text something like:
>
> DimView 1 "All" DimView 2 "Some" DimView 3 "Most" DimView 4 "None"
>
> I want a hash with (1, "All", 2, "Some", 3, "Most", 4, "None")
>
> I'm spitting on /DimView/, but I can't get the syntax to throw it into the
> hash correct.  Can one of you thow me a couple of lines of code to get me
> through this?
>
> Thanks,
>
> Scott
>




Re: string position

2001-07-05 Thread Ken

Oh oh oh!  I want to try!

use strict;

my( $var, $long_var );
$var = '123456';
$long_var = ' ' x 19 . $var;
print "$long_var\n";

*in the distance you hear the sounds of someone beating something with a
stick*

- Original Message -
From: "F.H" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, July 05, 2001 9:31 AM
Subject: string position


> Hi,
> I'd like to be able to print a string at a specific location . Is there
any function that does that.
> $test = "abcd';
> I want to print $test at position 20-25.
> I appreciate if someone can help
>
> Thanks
> I.S
> __
> Get your own FREE, personal Netscape Webmail account today at
http://webmail.netscape.com/
>




Re: Text file parsing - one chunk v char by char

2001-07-05 Thread Ken


$/ = "¬";

Then while() will only bring in each record.


- Original Message -
From: "Mike Breeze" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, July 05, 2001 1:23 PM
Subject: Text file parsing - one chunk v char by char


> Hi there,
>
> I'm writing some code that has to parse a text file containing a series
> of records. The records are a direct export from a third party DB and
> are delimited by the "¬" char (I hope that comes out on all your email
> clients but I guess it doesn't really matter.
>
> What bothers me is that the text file contains only one line which in
> turn contains many records. The test files I have are only 300 or 400K,
> but I'm a bit worried at the risk of receiving a huge file to parse
> which may leave me wanting for memory.
>
> I'm used to parsing files where each record is written to it's own line.
> I.e.
>
> while (  ) {
> my $job = Job->new();
> chomp;
> $job->FromStr( $_ );
> push ( @{ $self->{people} }, $job );
> }
>
> I could do:
>
> while (  ) {
> my @jobs = split /\¬/;
> foreach my $jobstr ( @jobs ) {
>  my $job = Job->new();
>  job->FromStr( $jobstr );
>  push ( @{ $self->{people} }, $job );
> }
> }
>
> But this seems to me to be a little clunky given that I may receive a
> HUGE one lined file one day. Is this a valid risk, or am I being too
> careful?
>
> Cheers
>
> Breezy
>
>




Re: padding numbers with spaces

2001-07-06 Thread Ken

Try %5.1f in your sprintf

The first number is the width of the field, in this case your format, @,
is specifying 5 wide.

Alernatively you could make your format @##.# and get rid of the sprintf
$average =  $total / $scores;

- Original Message -
From: "David Gilden" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, July 06, 2001 11:06 AM
Subject: padding numbers with spaces


> Good day,
> Thanks in advance to of you great folks on this list!
> Dave G.
>
> I am trying with out much success to get the following to happen:
>
> Using this statement:
>
> $average =  sprintf ("%2.1f", ($total / $scores));
>
> I want my numbers to line up like so: [note the left padding with the ' ']
>
> fred 72 18.0  # with or with out the trailing '0'
> joan 15  3# would like to know how to accomplish both!
> john 21  3.5
> 
>
> this what you might get after running the script as is:
> --
> fred 72 18.0
> joan 15 3.0
> john 21 3.5
>
>
> --- script --
>
>
> open (GRADES, "grades.txt") || die "Can't open grades $!\n";
>
> while  ($line=){
> ($student,$grade)= split(" ",$line);
> $grades{$student} .= $grade . " ";
> }
>
> foreach $student (sort keys %grades){
> $total = 0;
>
> @grades = split (" ",$grades{$student});
> foreach $grade (@grades){
> $total+= $grade;
> $scores++;
> }
>
> $average =  sprintf ("%2.1f", ($total / $scores));
> write;
> }
>
>
>
> format STDOUT_TOP =
> Page @<<
> $% # page number variable
> Student Score Average
> -
> .
>
>
> format STDOUT =
> @<<  @<<@
> $student,$grades{$student},$average
> .
>
>




Re: MID in Visual Basic...

2001-07-12 Thread Ken

susbtr is almost identical to mid, but better (isn't that true for most of
perl?)

perldoc -f susbtr

- Original Message -
From: "Sebadamus" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, July 12, 2001 9:24 AM
Subject: MID in Visual Basic...


> In Visual I used the MID function to get a part of a text... por ex.
"price
> = 33.10" and I could get using "=" and EOL as delimiters the price "33.10"
>
> Can you tell me if I should use the SPLIT function in perl???
>
> Thanks...
>
> Seba.
>
>




Re: MID in Visual Basic...

2001-07-12 Thread Ken

Ack!  Typo!

substr

- Original Message -
From: "Ken" <[EMAIL PROTECTED]>
To: "Sebadamus" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Thursday, July 12, 2001 12:18 PM
Subject: Re: MID in Visual Basic...


> susbtr is almost identical to mid, but better (isn't that true for most of
> perl?)
>
> perldoc -f susbtr
>
> - Original Message -
> From: "Sebadamus" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, July 12, 2001 9:24 AM
> Subject: MID in Visual Basic...
>
>
> > In Visual I used the MID function to get a part of a text... por ex.
> "price
> > = 33.10" and I could get using "=" and EOL as delimiters the price
"33.10"
> >
> > Can you tell me if I should use the SPLIT function in perl???
> >
> > Thanks...
> >
> > Seba.
> >
> >
>
>




Re: cannot fix an error - "Bus error (core dumped) "

2001-07-31 Thread Ken

When I remove the incomplete elsif this runs fine on my system (with an
added line before the while to read in @line @line =
scalar();)

What version of Perl are you running?  Did you install it?  Did it past all
of the tests?

Can you send us a complete sample program that gives this same error?

Ken

- Original Message -
From: "Narendran Kumaraguru Nathan" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, July 31, 2001 5:09 AM
Subject: cannot fix an error - "Bus error (core dumped) "


> Hai Guys,
>
>   I am compiling a perl code (arround 200 lines). I run it with perl -w
(so that I can see all the
> warnings). It
> reports no warnings and executes. All is fine till I give one input ( like
1..5 ) meaning that I
> need actions 1 to 5
> to be done. Atonce the following error is printed in the screen and the
program quits.
> error>> Bus error (core dumped)
>
>   The user can specify a command or a series of command if the input is >1
then only one command
> (for 1)
> is executed. if the input is >1 2 , then execution of 2 follows execution
of 1 . If the input is
> >1..5 , then
> I wish actions 1 to 5 to be executed one after another.
>
> Now, the way I have implemented  is below
> foreach (@line) {
> if ( $_ =~ /\.\./) {  # if the input has two consecutive .'s
>  ($s, $e) = split /\.\./, $_;  # split with the dots to get start and
end
>  push @line, $s;  # append to the input line
>  while ( $s <= $e ) { push @line, $s++; };
> }elsif ($_ ==  #  next comparison
> # specify to execute commands some input
> }
>
> Can anyone give me a clue why this happens?? Or is there a better way of
doing this?
> Thanks & Regards,
> Naren.
>
>
> --
> 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: boolean logic - what am I doing wrong?

2001-08-03 Thread Ken

You forgot the attlist[$x] =~ before the second match.

- Original Message - 
From: "Ron Woodall" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, August 02, 2001 10:51 AM
Subject: boolean logic - what am I doing wrong?


> Hi All:
> 
> A bit of a conundrum here.
> 
> while (attlist[$x] =~ m| 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: Tertiary Operator Question

2001-08-13 Thread Ken

It's a precedence problem.  I've been trying to parenthesize this according
to the precedence chart in "Programming Perl" but haven't been having any
luck.  Maybe someone elses brain is working better than mine and can tell us
how this is being seen by Perl with parens!

If you put parens around the final assignment it works:
$num == 3 ? $nextnum = 4 : ($nextnum="unknown");


Here is a better way to do it:
$nextnum = ( $num == 3 ? 4 : "unknown");

- Original Message -
From: "David Rankin" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, August 13, 2001 3:50 PM
Subject: Tertiary Operator Question


Hi Everybody,

I'm having trouble figuring out the way the tertiary operator evaluates
and returns data.  Here's what I don't get . . .

If I do this:

#!/usr/bin/perl -w
use strict;
my $num=3;
$num==3 ? print "Num equals 3" : print "Num does not equal 3";

I get what I'd expect, "Num equals 3" gets printed.

But, if I do this:

#!/usr/bin/perl -w
use strict;
my $num=3;
my $nextnum;
$num==3 ? $nextnum=4 : $nextnum="unknown" ;
print $nextnum;

It prints "unknown".  I'd expect it to print "4" because $num==3 would
evaluate to true.

I've looked in all my books and perldoc but everything seems to say the
same thing:  If the operand before ? is true then operand before : is
evaluated and returned, otherwise, the operand after : is evaluated and
returned.

If anyone can clarify the results I'm getting, I'd really appreciate it.

Thanks!

-Dave




--
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: Tertiary Operator Question

2001-08-13 Thread Ken

When I run the line outputted from the Deparse inplace of his original code
I get errors!  What's up with that?

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

my $num=3;
my $nextnum;
((($num == 3) ? ($nextnum = 4) : $nextnum) = "unknown");
print $nextnum;


- Original Message -
From: "Paul Johnson" <[EMAIL PROTECTED]>
To: "David Rankin" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Monday, August 13, 2001 4:09 PM
Subject: Re: Tertiary Operator Question


> On Mon, Aug 13, 2001 at 05:50:14PM -0400, David Rankin wrote:
>
> > #!/usr/bin/perl -w
> > use strict;
> > my $num=3;
> > my $nextnum;
> > $num==3 ? $nextnum=4 : $nextnum="unknown" ;
> > print $nextnum;
> >
> > It prints "unknown".  I'd expect it to print "4" because $num==3 would
> > evaluate to true.
>
> You're being hit by precedence.
>
> $ perl -MO=Deparse,-p -e '$num==3 ? $nextnum=4 : $nextnum="unknown"'
> ((($num == 3) ? ($nextnum = 4) : $nextnum) = 'unknown');
>
> But if you are assigning to the same variable in both branches, you're
> better off writing like this:
>
>   $nextnum = $num == 3 ? 4 : "unknown";
>
> $ perl -MO=Deparse,-p -e '$nextnum = $num == 3 ? 4 : "unknown"'
> ($nextnum = (($num == 3) ? 4 : 'unknown'));
>
> --
> Paul Johnson - [EMAIL PROTECTED]
> http://www.pjcj.net
>
> --
> 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]




how to use socketpair to run another program

2002-07-31 Thread Ken

I've looked at Programming Perl and the Perl Cookbook, but I'm just too dense 
to figure out how to do this.
I have an external program (not in perl, and not written by me). I want to 
send a string to it, have it do it's thing, then return the output to my perl 
program. Then, depending on the results, I might need to run the external 
program again with a different string.
I'm close with the following:
open BL, "|-", "bl -d /usr/local/share/bl"  #open program with parameters
or die "cant open bl fork: $!";
local $SIG{PIPE} = sub { die "bl pipe broke"}; 
print BL "stuff\n\n";   #send this to the program bl
close BL or die "bad close $!";

This sends the output to the screen, STDOUT. So I think my next step is to 
use a socketpair so I can gather the ouput and use it.
But I can't figure out how to set this up. 

Using the example in the Perl Cookbook (p. 575), here's the line that stumps 
me.
socketpair (CHILD, PARENT, AF_UNIX, SOCK_STREAM, PF_UNSPEC)

this is what I tried, along with other variations (no laughing please)
socketpair (CHILD |- "bl -d /usr/local/share/bl", PARENT, AF_UNIX, 
SOCK_STREAM, PF_UNSPEC)

Any help is appreciated
Ken

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




Re: could not find ParserDetails.ini in /usr/lib/perl5/vendor_perl/5.8.3/XML/SAX; also need some advice about XML parsing modules on CPAN

2004-10-11 Thread Ken Wolcott
Ken Wolcott wrote:
I suppose it is in bad taste to reply to one's own posting, but I have 
an update.

After reading some in the O'Reilly Perl & XML book, reading the email 
archives of this mailing list, several FAQS that some people mentioned 
from the mailing list archives and another reading of the CPAN man 
page for XML::Simple, I decided to try the OO interface, adding 
"ForceArray => 1, KeepRoot => 1, KeyAttr => 1" to my call to the 
parser.  It seems now that the formatting is nice and the closing tag 
is specified properly.  So, getting patient, calm, cool and collected 
rather than anxious solved part of the problem.  Now the problem that 
remains is the error/warning message in the subject line: "could not 
find ParserDetails.ini in /usr/lib/perl5/vendor_perl/5.8.3/XML/SAX" 
when using XML::Simple.  What do I need to do to fix that?

Again, replying to my own post as nobody has reponded :-(
I saw the "could not find ParserDetails.ini in 
/usr/lib/perl5/vendor_perl/5.8.3/XML/SAX" warning/error on a Fedora Core 
2 system, but did not see the error on three Red Hat 9 systems.  So I 
punted by not using the Fedora system.

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



how/where to install xyz.pm from CPAN (no perl Makefile.PL; make; make test; make install)??

2004-10-11 Thread Ken Wolcott
Hi;
 I see several very interesting CPAN modules regarding Rational/IBM 
ClearCase.  These are just *.pm files.  How/where do I install these?  I 
have root privs.  I want the modules to be available in the standard 
place(s).  I guess I should just look at the %INC hash and place it in a 
"good" location?

 A more general question along the lines of "giving me a fishing pole" 
instead of "giving me a fish"...I can go to 
(http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&group=perl.beginners) 
to search for archived postings, but what meaningful search string would 
I provide in order to obtain answers pertinent to my question above?

 I have the 3rd edition of the camel book and refer to it frequently.  
I have several other perl books (mostly O'Reilly) as well.  I don't 
remember seeing this topic addressed.

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



Re: how/where to install xyz.pm from CPAN (no perl Makefile.PL; make; make test; make install)??

2004-10-11 Thread Ken Wolcott
Randy W. Sims wrote:
On 10/11/2004 11:01 PM, Ken Wolcott wrote:
Hi;
 I see several very interesting CPAN modules regarding Rational/IBM 
ClearCase.  These are just *.pm files.  How/where do I install 
these?  I have root privs.  I want the modules to be available in the 
standard place(s).  I guess I should just look at the %INC hash and 
place it in a "good" location?

 A more general question along the lines of "giving me a fishing 
pole" instead of "giving me a fish"...I can go to 
(http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&group=perl.beginners) 
to search for archived postings, but what meaningful search string 
would I provide in order to obtain answers pertinent to my question 
above?

 I have the 3rd edition of the camel book and refer to it 
frequently.  I have several other perl books (mostly O'Reilly) as 
well.  I don't remember seeing this topic addressed.

In general, you should never manually drop in modules. Is there no 
Makefile.PL or Build.PL file with the module? If not and it is on 
CPAN, the author should have his or her @$$ kicked. =)

What module(s) are you looking at?
Randy.
Hi Randy;
 That was a real bozo question of mine :-(
 I'm in a desperate rush to completely rewrite one of my build scripts 
as I have "scripted myself into a corner" :-(

 I can't seem to use a Perl CPAN XML module in conjunction with 
ClearCase, as I did not see the ClearCase Perl modules on CPAN until 
today, and the ClearCase commands I was calling where in a setview exec 
mode (trying to call bash for simplicity as I did not want to 
autogenerate perl to be run later).  If I then try to call the Perl 
XML:Simple module in bash (that won't work!), I then am writing a perl 
script, which autogenerates bash, which then calls a perl program to do 
XML, which by then I have lost the ClearCase setview exec context :-(  
Now I need to have this done by noon on Wednesday as I have to make a 
ClearCase label build using an Perl XML module in order to view/modify 
version strings in an XML file that is in ClearCase...

One example (did this with four modules):
http://search.cpan.org/
enter ClearCase into the search box and press the search button
choose the first entry in the response which is
http://search.cpan.org/~dsb/ClearCase-Argv-1.18/Argv.pm
now select the "Source" button near the top
I thought that this would provide the source of the module, not the 
source of the *.pm file that the POD was showing :-)

What I should have done:
http://search.cpan.org/
enter ClearCase into the search box and press the search button
choose the first entry in the response which is
http://search.cpan.org/~dsb/ClearCase-Argv-1.18/Argv.pm
click on the module name, which is:
http://search.cpan.org/~dsb/ClearCase-Argv-1.18/
Now I can select the compressed tarball :-)
I have now installed all four of the most likely suspects in the 
"proper" manner (perl Makefile.PL, make, make test, make install)...

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



Re: could not find ParserDetails.ini in /usr/lib/perl5/vendor_perl/5.8.3/XML/SAX; also need some advice about XML parsing modules on CPAN

2004-10-14 Thread Ken Wolcott
Wiggins d Anconia wrote:
See if I can actually get somewhere with this.  XML::Simple is just a
wrapper around one of the lower level XML parsers. Essentially any
parser can be used. XML::DOM and XML::SAX are two examples, within these
examples they can/do wrap lower level C libs, such as expat[1] or
libxml[2]. Alternatively they may also provide a pure Perl
implementation which is likely slower, but still correct.  Unless you
specifically request a specific parser XML::Simple will look for one
that is available and use it. In this case it appears that either you
specified or it came upon XML::SAX and attempts to use. Part of the
XML::SAX API allows for alternate parsers to be installed, including the
two mentioned above (expat and libxml), and also provides a PurePerl
version.  The module also checks for a ParserDetails.ini to see if you
have written your own parser that you might prefer to load before the
others, or before the default pure Perl version is loaded. It appears
that the file should be installed at installation time or bootstrapped
by the Makefile.PL but this is kinda unclear to me.  You can check the
top of the source for XML::SAX to see some pod like comments about that
file as well as the format it should take.  

So if I had to guess, the RH9 systems probably came installed with
either of the parsers (or both) and the FC system did not. It would be
pretty simple to have this problem if you didn't install all of the dev
libraries, or selected specific packages, etc. Alternatively a previous
version of XML::SAX may have installed the file and newer ones don't. It
appears at some point that a makefile touched the file in place, and
that may have been removed.  I also suspect that it is working since the
PurePerl parser is installed with XML::SAX and it is falling back to it.
And the message you are seeing is just a warning.  So you might check
for the various libraries, check their versions, check the versions of
XML::Simple/XML::SAX, and make sure that the Perl modules were installed
against the most recent versions of those libs. To quiet the warning if
you so desire it appears you can touch the ParserDetails.ini file in the
directory that XML::SAX is installed.
Take all of this with as large of a grain of salt as you wish, I am no
XML expert
http://danconia.org
[1] http://expat.sourceforge.net/
[2] http://www.xmlsoft.org/
Ah hah... addendum:
http://perl-xml.sourceforge.net/faq/#parserdetails.ini
http://danconia.org
   

Thanks for your response.  I have bookmarked that faq.  I did apply the 
suggested fix.

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



could not find ParserDetails.ini in /usr/lib/perl5/vendor_perl/5.8.3/XML/SAX; also need some advice about XML parsing modules on CPAN

2004-10-06 Thread Ken Wolcott
Hi;
 I have a Fedora Core 2 full install to which I installedXML::Simple 
manually (ie: download, extract, perl Makefile.PL, make, make test, sudo 
make install).  Some of the tests did not run since I did not have 
Tie::IxHash (?) installed.   The error message (could not find 
ParserDetails.ini in /usr/lib/perl5/vendor_perl/5.8.3/XML/SAX) is 
received when I try to run the enclosed perl program using the enclosed 
data file.  I also have enclosed the output.

Should I install Tie::IxHash?  I would like to have my XML output (after 
values are updated) formatted the same way my XML input was formatted.  
Will that help?

Do I need to upgrade *XML::SAX* 
<http://search.cpan.org/author/MSERGEANT/XML-SAX-0.12/SAX.pm>?

Since I want the initial formatting to be retained (is this possible) 
and I want the XML output to pass strict XML checking, do I need to give 
up on XML::Simple, or did I miss some options that would give me these 
characteristics?  I've been browsing about on CPAN for some while and 
there's quite a bit to research.  I need to implement this quickly though...

The expected size/complexity of the input XML is quite small and 
simple.  I just need the ability to quickly and reliably examine and 
possibly change the values associated with a specified set of XML tags.  
I need to be able to a quickly add or remove XML tags from my list to 
examine/modify.  It looked like XML::Simple fit the bill, but I see that 
the XML output that the closing XML tag is not strictly compliant (as 
" value " is "correct" while " value " is not).  I 
need to preserve the XML output in ClearCase that remains in a human 
"readable" form, ie: well-formatted...

Thanks in advance for your comments and advice,
Ken Wolcott
*
?xml version="1.0" encoding="UTF-8"?>

1.0.10.6
acq
1
acq.img:b0e264df482d069d4e9d6e037abe

*
*
#!/usr/bin/perl
use strict;
use warnings;
use XML::Simple;
use Data::Dumper;
my $label = "XXX"; # sanitized :-)
my $version = substr ($label, 7, (length ($label) - 11));
my $tag;
my $changes = 0;
my $xml_source = "index.xml";
my $hashref = XMLin ($xml_source);
print "contents of hash prior to modification:\n";
print "###\n";
print Dumper ($hashref);
print "###\n";
$tag = "version";
if ($hashref -> {$tag} ne $version) {
   $hashref -> {$tag} = $version;
   $changes++;
}
if ($changes) {
   print "contents of hash after modification:\n";
   print "###\n";
   print Dumper ($hashref);
   print "###\n";
}
*
**./xml_simple.pl
could not find ParserDetails.ini in /usr/lib/perl5/vendor_perl/5.8.3/XML/SAX
contents of hash prior to modification:
###
$VAR1 = {
 'version' => 'XX',
 'file' => 'file:md5sum',
 'maxhwversion' => '1',
 'type' => 'acq'
   };
###
contents of hash after modification:
###
$VAR1 = {
 'version' => 'XX',
 'file' => 'file:md5sum',
 'maxhwversion' => '1',
 'type' => 'acq'
   };
###

***
*
perl -v
This is perl, v5.8.3 built for i386-linux-thread-multi
*
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>



Re: could not find ParserDetails.ini in /usr/lib/perl5/vendor_perl/5.8.3/XML/SAX; also need some advice about XML parsing modules on CPAN

2004-10-06 Thread Ken Wolcott
Ken Wolcott wrote:
Hi;
 I have a Fedora Core 2 full install to which I installedXML::Simple 
manually (ie: download, extract, perl Makefile.PL, make, make test, 
sudo make install).  Some of the tests did not run since I did not 
have Tie::IxHash (?) installed.   The error message (could not find 
ParserDetails.ini in /usr/lib/perl5/vendor_perl/5.8.3/XML/SAX) is 
received when I try to run the enclosed perl program using the 
enclosed data file.  I also have enclosed the output.

Should I install Tie::IxHash?  I would like to have my XML output 
(after values are updated) formatted the same way my XML input was 
formatted.  Will that help?

Do I need to upgrade *XML::SAX* 
<http://search.cpan.org/author/MSERGEANT/XML-SAX-0.12/SAX.pm>?

Since I want the initial formatting to be retained (is this possible) 
and I want the XML output to pass strict XML checking, do I need to 
give up on XML::Simple, or did I miss some options that would give me 
these characteristics?  I've been browsing about on CPAN for some 
while and there's quite a bit to research.  I need to implement this 
quickly though...

The expected size/complexity of the input XML is quite small and 
simple.  I just need the ability to quickly and reliably examine and 
possibly change the values associated with a specified set of XML 
tags.  I need to be able to a quickly add or remove XML tags from my 
list to examine/modify.  It looked like XML::Simple fit the bill, but 
I see that the XML output that the closing XML tag is not strictly 
compliant (as " value " is "correct" while " value 
" is not).  I need to preserve the XML output in ClearCase that 
remains in a human "readable" form, ie: well-formatted...

Thanks in advance for your comments and advice,
Ken Wolcott
*
?xml version="1.0" encoding="UTF-8"?>

1.0.10.6
acq
1
acq.img:b0e264df482d069d4e9d6e037abe

*
*
#!/usr/bin/perl
use strict;
use warnings;
use XML::Simple;
use Data::Dumper;
my $label = "XXX"; # sanitized :-)
my $version = substr ($label, 7, (length ($label) - 11));
my $tag;
my $changes = 0;
my $xml_source = "index.xml";
my $hashref = XMLin ($xml_source);
print "contents of hash prior to modification:\n";
print "###\n";
print Dumper ($hashref);
print "###\n";
$tag = "version";
if ($hashref -> {$tag} ne $version) {
   $hashref -> {$tag} = $version;
   $changes++;
}
if ($changes) {
   print "contents of hash after modification:\n";
   print "###\n";
   print Dumper ($hashref);
   print "###\n";
}
*
**./xml_simple.pl
could not find ParserDetails.ini in 
/usr/lib/perl5/vendor_perl/5.8.3/XML/SAX
contents of hash prior to modification:
###
$VAR1 = {
 'version' => 'XX',
 'file' => 'file:md5sum',
 'maxhwversion' => '1',
 'type' => 'acq'
   };
###
contents of hash after modification:
###
$VAR1 = {
 'version' => 'XX',
 'file' => 'file:md5sum',
 'maxhwversion' => '1',
 'type' => 'acq'
   };
###

***

*
perl -v
This is perl, v5.8.3 built for i386-linux-thread-multi
*

I suppose it is in bad taste to reply to one's own posting, but I have 
an update.

After reading some in the O'Reilly Perl & XML book, reading the email 
archives of this mailing list, several FAQS that some people mentioned 
from the mailing list archives and another reading of the CPAN man page 
for XML::Simple, I decided to try the OO interface, adding "ForceArray 
=> 1, KeepRoot => 1, KeyAttr => 1" to my call to the parser.  It seems 
now that the formatting is nice and the closing tag is specified 
properly.  So, getting patient, calm, cool and collected rather than 
anxious solved part of the problem.  Now the problem that remains is the 
error/warning message in the subject line: "could not find 
ParserDetails.ini in /usr/lib/perl5/vendor_perl/5.8.3/XML/SAX" when 
using XML::Simple.  What do I need to do to fix that?

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



What search string do I use on google or perldoc so that I know how to display a specified range of lines from a file (like sed -n 24, 48p filename)?

2004-10-22 Thread Ken Wolcott
A fishing pole question rather than a fish question :-)
What search string do I use on google or perldoc so that I know how to 
display a specified range of lines from a file (like sed -n 24, 48p 
filename)?

s2p no longer operates the way I used to use it back in perl 3x days :-)
man s2p really didn't help me understand what perl syntax would give me 
the desired result that sed does :-(

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



perl problems

2004-12-13 Thread Ken Gillett
I've been running RH 8 on my server for some time and regularly ran a 
fairly complex perl script that parsed an XML file and contained the 
following line:-

last if /^\t{0,2}<$tag>$/;
which would exit the loop at the end of that 'section' as $tag in fact 
contained "/dict". On upgrading to RH 9 this all fell apart and I spent 
the best part of a day trying to find out why and where it was failing. 
Strangely, it WOULD work if I replaced $tag with the literal string it 
contained (i.e. /dict) or when it found the line beginning with a 
single tab (i.e. way further down the file), but would NEVER recognise 
2 tabs and using $tag.

 On investigation I discovered that the above works perfectly with RH 
8's Perl 5.8.0.55 (and my Mac's 5.8.1), but NOT with RH 9's 5.8.0.88. I 
upgraded to 5.8.5 and all's well again:-)

Is this a known problem with that version of Perl or as usual am I the 
first to discover a bug in such a widely used piece of software?


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



hash of array

2005-01-16 Thread Ken Gillett
I'm trying to store a named array in a hash(%dbm), which ought to be 
entirely possible. with the key,value pairs being the name and array 
respectively.

I'm using the following line to add items to the array:-
push @{ $dbm{ $name } }, "$ID";
So the key in $name has ID added as an extra member of its array. This 
is done repeatedly with many new items added to the arrays for 
different names. But, the first one is somehow always missed. Whatever 
this script adds to the arrays, the first one somehow misses and is 
simply not in the array, although all other members are there as 
expected.

I know there can be referencing problems in complex data structures, 
but I am sure the code is correct, in particular because whatever tests 
I do with test scripts that add multiple array items for many names 
(keys), they always work perfectly. I'm using the exact same code and 
setting up variables in the same way, but it works in one and not the 
other.

This is the real puzzle. I am never surprised when code doesn't do what 
I expect, but in this case it works perfectly in the test scripts, 
exactly as expected and required, but in the real script in which it 
actually needs to work, the first attempt to add an item always fails 
and I am at a loss to understand what the reason could be.

Can anyone shed any light on why this 'push'ing onto the array might 
fail for the first item only? If I have some ideas about that I can 
investigate further as to how this might occur in one script but not 
the other.

Please???

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



hash of arrays

2005-01-16 Thread Ken Gillett
Why do I think of a possible solution within minutes of sending a 
question to this list:-(

One difference between the scripts is that the one which fails ties the 
hash to a Berkeley DB file and this is the cause. Without that the 
first item is always successfully added, but once tied to the file it 
misses the first one.

Great.
Now I need to figure out how to prevent this. Anyone any ideas on that?

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



tie hash variable to file

2005-01-19 Thread Ken Gillett
I want to pass a string to a subroutine and use that as the name of the 
hash to tie to a dbm file (or use dbmopen). But I can't make it work 
with a hash reference in the sub routine.

If I use the same code outside the sub or hard code the hash name (i.e. 
no ref) within the sub it all works perfectly.

Can anyone enlighten me how I can use the string within the sub to make 
the name of the hash variable, tie/dbmopen it and be able to use the 
hash outside the sub? 'Cos I'm stuck:-(

Thanks.

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



tie DB_File flags

2005-01-24 Thread Ken Gillett
Information about these has proved hard to come by, but having 
ascertained what I need to use I find another problem. I want to 
calculate the flags to use beforehand, but if I try

tie %$dbm, "DB_File", $dbf, $dbflags, $mode, $DB_HASH;
even though $dbflags contains O_RDONLY I get the following error:=
	Argument "O_RDONLY" isn't numeric in subroutine entry at 
/usr/lib/perl5/5.8.6/i686-linux/DB_File.pm

This is caused by using the variable for the flags and if I replace 
that with the actual string (no quotes) it works fine, so it's happy 
with $dbf and $mode.

I'm using 5.8.6, but the problem also exists with 5.8.5 at least.
Can anyone suggest how I can get around this and use a variable for the 
flags?


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



Re: tie DB_File flags

2005-01-28 Thread Ken Gillett
On 26 Jan 2005, at 14:47, Marcello wrote:
Ken Gillett ha scritto:
Information about these has proved hard to come by, but having 
ascertained what I need to use I find another problem. I want to 
calculate the flags to use beforehand, but if I try
tie %$dbm, "DB_File", $dbf, $dbflags, $mode, $DB_HASH;
even though $dbflags contains O_RDONLY I get the following error:=
Argument "O_RDONLY" isn't numeric in subroutine entry at 
/usr/lib/perl5/5.8.6/i686-linux/DB_File.pm
You are passing the string "O_RDONLY" to the subroutine, no the value 
of O_RDONLY.

Maybe this works (untested):

$dbflags = O_RDONLY;
Because PERL wouldn't let me. BUT, I just tried it again and it didn't 
complain and the 'tie' worked perfectly, even when using 
O_RDWR|O_CREAT|O_TRUNC. :-)

tie %$dbm, "DB_File", $dbf, $dbflags, $mode, $DB_HASH;

In the meantime since first noticing the problem I have done some 
extensive re-writing of my code, so whatever I had that was causing the 
problem has obviously been corrected (without me knowing what it was). 
Anyway, the important point is that it now works as expected, so at 
least my expectations were correct.

Thanks.

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



Re: file input/output

2005-02-03 Thread Ken Gillett
On 3 Feb 2005, at 06:24, Elliot Holden wrote:
okay this may seem like a simple problem but here it goes:
when running the the script below from the unix (mac osx) command line 
the "survey.txt" file is created and "this a test!!!" is written to 
the file. But when running it from a browser the file is Not created 
and "Browser test" is displayed in the browser. So in essennce when 
running from a browser the file creation section of the script is 
being skipped over. Please, please, please, why is this happening, 
somebody? I've tried it on diffferent browsers - Mozilla, IE.

open(OUTFILE, ">>survey.txt");
print OUTFILE "this is a test!!!\n";
close(OUTFILE);
print "Browser test\n";

Maybe I'm being too simplistic here, but where exactly are you looking 
for the file to be created?

When run from the command line the file will get created in that 
directory (folder), but when you use the browser it will depend on what 
the web server thinks is the current directory (probably the document 
root) as it is the server that creates the file, not the browser. 
However, I am assuming you are running the script as a CGI - you've not 
made entirely clear just how you are using the browser to run the 
script.


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



hash speed

2005-02-13 Thread Ken Gillett
I have a script that creates a hash, up to several thousand key=>value 
pairs. Each value is a string that is created by adding to it 
repeatedly, maybe hundreds of times, each addition probably about 10 
bytes.

I can do this in (at least) 2 ways. One is to repeatedly concatenate ( 
.= ) the additional string onto a scalar variable and then, once it has 
been fully created, to add this variable to the hash with its 
appropriate key. The other is to directly add onto the hash value 
itself, no other variable involved.

My question is:-
Which is faster in operation?
I don't know enough about the internal workings of perl's memory 
structures (actually I know nothing about that:-) to be able to hazard 
a guess at this. Maybe it makes no measurable difference, but maybe one 
is definitely the better modus operandi.

Can anyone answer this?

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



Re: Request for regex: Strip last dash in a record

2005-02-15 Thread Ken Simon
[EMAIL PROTECTED] wrote:
If you just want to remove the last occuring '-' character, then the
following would work.
s/(.*)-(.*)/$1$2/;

Well, huh.  That does work.  Though it reminds me only of how little I
understand why.
Thanks,  you've made it look easy.
His regex works because perl uses greedy regular expression matching.  This 
means that perl matches the longest string possible when you use the first .*. 
Which means the first .* ($1) matches all the -'s except for the last one.

A bit less confusing regex, IMO, would be
s/(.*)-([^-])/$1$2/;
Which defines the second backreference to be specifially characters that aren't 
-'s.
--
Ken Simon
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>



Re: hash speed

2005-02-16 Thread Ken Gillett
On 15 Feb 2005, at 17:43, Jay wrote:
On Tue, 15 Feb 2005 09:48:23 -0500, Wiggins d'Anconia
<[EMAIL PROTECTED]> wrote:
Please bottom post, and reply-all so that everyone can help and be 
helped.

Nope. That's a here are the tools that you should be able to determine
on your own which is faster. " teach a man to fish "
http://danconia.org
Ken Gillett wrote:
That's a no then?
On 14 Feb 2005, at 15:00, Wiggins d'Anconia wrote:
Ken Gillett wrote:
I have a script that creates a hash, up to several thousand
key=>value pairs. Each value is a string that is created by adding 
to
it repeatedly, maybe hundreds of times, each addition probably 
about
10 bytes.
I can do this in (at least) 2 ways. One is to repeatedly 
concatenate
( .= ) the additional string onto a scalar variable and then, once 
it
has been fully created, to add this variable to the hash with its
appropriate key. The other is to directly add onto the hash value
itself, no other variable involved.
My question is:-
Which is faster in operation?
I don't know enough about the internal workings of perl's memory
structures (actually I know nothing about that:-) to be able to
hazard a guess at this. Maybe it makes no measurable difference, 
but
maybe one is definitely the better modus operandi.
Can anyone answer this?

perldoc Benchmark
Check the list archives for examples of usage on other problems.
To elaborate on the "no" a little: there are a host of things that
affect execution.  Diifferent processes use system resources in
differnt ways.  Some take more memory, some take more processor time.
Some scale lineraly, some have a high initial overhead.  Different
architectures and processors are optimised for different tasks.  The
list goes on.  Often, you'll find that the fastest solution for a
small data set isn't the fastest for a larger one, and vice versa.  No
one on this list is you, sitting at your computer, with your data.  So
none of us can tell you what's best.  Here are some things to think
about.  Generally, assigning to a temporary variable is slower than
modifying a vaule directly (because it incurs the overhead of creating
the variable).  On the other hand, hashes take up a lot of memory, and
modifying large hases can be time consuming.  So it would be
reasonbale to expect that for a "small" data set, modifying the hash
directly would be faster, but that on a "large"--in terms of
bytes--data set assigning to a temp variable might possibly be faster,
because it only modifies the hash once.  But only Becnchmark will tell
you what large and small mean for your system in this situation, and
where the tradeoff happens for you.  Remember, too, that your results
will change depending on what the rest of your program is doing, and
the available system resources.  Each platform also has its own
quirks.
Look into the archives for some of the recent threads on Benchmarking,
and you'll see why the answer to your original question has to be no.
Brilliant, thank you for that informative reply. It's what I was trying 
to allow for in my original question, that there are vagaries involved 
which can affect the outcome. It's not the answer I wanted, but it IS 
an answer. Thanks.

As an extension to my question, what about when repeatedly adding to a 
data set that needs to be written to a file? Will it be quicker to 
write each line directly to the file, or repeatedly add to a variable 
then write that to the file in one hit?

My guess is that this will have a more definitive answer since the 
speed difference between writing to a variable and writing to a file 
will make it a more obvious outcome and indeed my experience indicates 
that writing to a file is measurably slower. But does anyone have any 
in depth knowledge of these processes.

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



Re: 5.6.0 to 5.8.6 problems.

2005-02-16 Thread Ken Simon
Richey wrote:
I am trying to upgrade from Perl 5.6.0 to  5.8.6 on Slackware 7.1  becasue 
some of the Perl Modules that I am trying to install whine about 5.6.0 and 
they want atleast 5.6.1.   Since this box is going live after I finish 
setting it up now is a better time to go ahead and upgrade to 5.8.6. 
Everything runs fine, no errors or complaints during the compile but when I 
finish and run perl -v it returns that it is 5.6.0.   What am I missing? 
Below are the steps I am taking to install 5.8.6.

make distclean
rm -fv config.sh Policy.sh
sh Configure -de
make
make test
make install

It probably installed the perl binary to /usr/local/bin/perl, or something 
similar.  Do a `which perl` and find out where your current perl is (probably 
/usr/bin/perl), and install perl to that prefix. (ie. run ./configure 
--prefix='/usr')

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



Re: hash speed

2005-02-17 Thread Ken Gillett
On 16 Feb 2005, at 17:40, Jay wrote:
On Wed, 16 Feb 2005 08:13:02 +, Ken Gillett <[EMAIL PROTECTED]> wrote:
As an extension to my question, what about when repeatedly adding to a
data set that needs to be written to a file? Will it be quicker to
write each line directly to the file, or repeatedly add to a variable
then write that to the file in one hit?
My guess is that this will have a more definitive answer since the
speed difference between writing to a variable and writing to a file
will make it a more obvious outcome and indeed my experience indicates
that writing to a file is measurably slower. But does anyone have any
in depth knowledge of these processes.
Ken,
Again, it will really depend.  How "big" is the hit going to be?  Big
enough that storing the data in memory will eat up your RAM and force
you to swap?  If you're dealing with thousands of lines, you may not
want to store them all in memory, especially if you're like me,
running a database server on a PII/133 with 16M of RAM.  On the other
hand, if you're on a brand new P4 with 2G of DDR2, who really cares?
Of course if your data set is multiple terabytes, even 2G isn't going
to be enough.
OK, not as clear-cut as I thought. Bit more trial and error required.
Thanks.

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



splitting by number

2005-02-17 Thread Ken Gillett
I have a problem that is not exactly a perl problem, but I do have to 
implement it in perl, although the implementation is not the problem. 
Sorry if that's a bit obscure.

I have thousands ( <50,000 ) of numerically named files that I need to 
store in 2 different location so that the ratio of numbers of files in 
each location is maintained at a preset ratio. The files will be 
repeatedly created and I want to ensure that each time this is done, 
the same named file is placed in the same location it was last time, 
therefore a simple alternating process or one that looks at the 
existing numbers of files would not be suitable, since at each 
generation of the files they would be unlikely to end up in the same 
place.

So I really want something that examines the file name and makes a 
decision based on that, so that every time it sees the same name, it 
will be placed in the same location - unless there's another way to 
enforce the same rule?

The file names are numbers between 10 and 10,000,000, with no 
grouping/order to the naming that would skew the result - assume an 
even distribution.

Initially the storage requirements are 2:1, so simply dividing the name 
by 3 would (I think) work, i.e. if the name is exactly divisible by 3 
or not could determine in which location to place it. But if I need to 
change that to e.g. 3:2 it's not so simple and the ratio needs to be 
flexible so that it can be easily set and/or changed for different 
setups.

BTW, the background to this is that the list of files will be symlinks 
to (currently mostly mp3) music files and a larger number of far 
smaller supporting regular files (mostly text, some binary). The entire 
structure is to be created on the main server then rsync'd up to a 
player device which has 2 HDs for the storage, hence the 2 different 
locations and the need to ensure the files are in the same location 
every time, otherwise rsync will waste a lot of time deleting and 
re-copying files simply because they're in a different directory from 
last time and when playing with almost 100Gb of data this is to be 
avoided at all costs.

Hope some of you can bring some brain power to work on this as my head 
hurts...


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



Re: splitting by number

2005-02-18 Thread Ken Gillett
On 17 Feb 2005, at 21:40, Doug Essinger-Hileman wrote:
On 17 Feb 2005 at 11:27, Ken Gillett wrote:
Initially the storage requirements are 2:1, so simply dividing the
name by 3 would (I think) work, i.e. if the name is exactly divisible
by 3 or not could determine in which location to place it. But if I
need to change that to e.g. 3:2 it's not so simple and the ratio needs
to be flexible so that it can be easily set and/or changed for
different setups.
Ken,
I think that the mod function would work, and would allow you to
easily change the ratio in the future.
In the present, you would use mod 3, and the answer would determine
where to put the files, with 0 and 1 going onto one hard drive and 2
going onto the other. So, for filename 10, the remainder is 1, and it
would go onto the first harddrive. Filename 11 (remainder 2) would go
onto the second. Filename 12 (remainder 0) would go onto the first,
etc.
When you need to change the ratio, you simply change the details. In
your example (ratio 3:2), you would use mod 5, and send remainders 0,
1 & 2 onto the one hard drive, and remainders 3 & 4 onto the other.

That's very much what I had in mind, but I couldn't figure how to 
automatically set up which remainders go to which HD. I want just the 
ratio to be specified and everything else to be calculated. However, I 
think I can see how to do that now.

Thanks for the replies that provided the inspirition.

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



Using SSL and Perl to Gather Process Information

2001-05-16 Thread Ken Hammer


 I need to write a perl script that will gather system information
from remote machines. I must communicate to the remote machines
using SSL.  I'm thinking I can use the Socket method to accomplish
this, but I have had little luck in figuring it out.

 Can anyone point me in the right direction?

 Thank you.

-- 
Ken Hammer
Information Technology Central Services
University Of Michigan
[EMAIL PROTECTED]



question

2001-05-31 Thread KeN ClarK

Acquired this script that will email data entered on form. Simple enough.
Email does arrive but with what appeared as template information. So, I
edited that part of the script.

My question is (provided the rest of the script performs correctly) is the
below snippet right? This is where the email being generated gets the
information. From the html page that houses the form, the below (like
locat) are in the html.

#begin snippet

if($mail_out) {

body = "email: $in{email}
state: $in{state}
pname: $in{pname}
locat: $in{locat};"

#end of snippet

I am unable to answer if the mail is properly sent because this is for a
user on my system who is out-of-touch. The mail is forwarded off-site.

The page that serves this is http://www.quantifier.org/~bobby/pinscr.html

ANY help is appreciated. I am curious if it belongs inside of "..." since
the template mail that was sent all resided inside.

Ken
-- 
_
[EMAIL PROTECTED]
http://www.quantifier.org
_
Put your trust in those who are worthy.




my own answer

2001-05-31 Thread KeN ClarK

post about whether syntax of snippet with mail data being correct--it is.
I didn't read his mail but did change the script to send to me instead.
It works!!!

Thanks for everything else...

Ken


-- 
_
[EMAIL PROTECTED]
http://www.quantifier.org
_
If you just try long enough and hard enough, you can always manage to
boot yourself in the posterior.
-- A.J. Liebling, "The Press"




getting pop & forwarding it to local

2001-05-31 Thread KeN ClarK

Want to retrieve email from ISP pop server and view it locally. running
sendmail. use PINE.

Found module at CPAN but not sure it is what I want. MAIL::POP3Client was
it. ANYone use this? Other ideas? I have tried it but had no luck. Not
sure if I am barking up a wrong tree...

As you see have pretty much zero perl experience. BUT WILLING TO LEARN,
and wanting...

Ken

-- 
_
[EMAIL PROTECTED]
http://www.quantifier.org
_
If you want to make God laugh, tell him about your plans.
-- Woody Allen




MAIL::POP3

2001-05-31 Thread KeN ClarK

I haven't done much of anything yet. But of course figured out how
fetchmail can do this and send it to my user locally. So that is working.
BUT, if a perl script that is cron'd will use less resources, I'd prefer
that. Plus, I need to learn Perl. It fails when it

use Mail::POP3Client; because I don't have this module, right? SO that's
what I thought I dloaded...I renamed it to POP3Client.pl Was that wrong?
Obviously. Or does my script call a module I still need to go and get?


#!/usr/bin/perl
use Mail::POP3Client;
$pop = new Mail::POP3Client( USER =>"myusername",
 PASSWORD => "mypassword",
 HOST => "pop.mail.server.com");
for( $1 = 1; $i <= $pop->Count(); $i++ ) {
foreach( $pop->Head( $i ) ) {
 /^(From|Subject);\s+/i && print $_, "\n";
}
}

a. perl path is correct.
b. the requisite stuff like user pass and server are correct...This is
supposed to get headers... looking at it I see the first thing it says is
to use itself, right? then it assigns a new instance to $pop...

The error I get when running perl -cw POP3Client.pl is "Can't locate
Mail/POP3Client.pm in @INC..." Well, once again, I think I see where .pm
is a perl module (I told you I was a beginner...)

Need direction, guidance, counseling, advice, and stern hand-slapping.

Ken

-- 
_
[EMAIL PROTECTED]
http://www.quantifier.org
_
The only perfect science is hind-sight.




Re: MAIL::POP3

2001-06-01 Thread KeN ClarK

Fetchmail is working wonderfully, but I am going to give Mail::Audit a go.
I appreciate everyone's advice.

Ken

On 1 Jun 2001, Piers Cawley wrote:

> Paul Johnson <[EMAIL PROTECTED]> writes:
>
> > On Thu, May 31, 2001 at 08:58:40PM -0400, KeN ClarK wrote:
> > > I haven't done much of anything yet. But of course figured out how
> > > fetchmail can do this and send it to my user locally. So that is working.
> > > BUT, if a perl script that is cron'd will use less resources, I'd prefer
> > > that.
> >
> > I would be extremely surprised if fetchmail wasn't far cheaper to run
> > than a Perl solution.
>
> Mail::Audit (a procmail replacement by Simon Cozens) comes with a script
> which you can run to turn it into a fetchmail replacement as well. The
> idea is that you can just leave it running in daemon mode and it'll
> deliver mail etc without having to fork off extra processes.
>
> Assuming you've got your filtering scripts sorted out properly, this
> will probably be the most lightweight solution going.
>
> And it's Perl. And it's available from CPAN. Result.
>
>

-- 
_
[EMAIL PROTECTED]
http://www.quantifier.org
_
Without adventure, civilization is in full decay.
-- Alfred North Whitehead




Re: append a file to another file - copy

2001-06-01 Thread KeN ClarK

So anycrack could write to it prior to it being 'moved' right? And then
you have non-world-writeable data under the premise it is untampered.
What's the difference?

Ken

On Fri, 1 Jun 2001, Nichole Bialczyk wrote:

> well, so the copy didn't work. it required me to place 'use File::Copy;'
> in my script, but i got an error message.
>
> to be more specific, i want to do this: read and delete all of the lines
> from a log file, except for the first one. i keep thinking grep, but
> isn't that only a unix command? and it doesn't delete.
>
> basically, for anyuser to write to my logfile, it has to be world
> writeable. but my boss doesn't like the possibility of someone tampering
> with our data. unfortunately, we are restricted to afs and anyone could
> write to that file. so here is the compromise:
>
> i am writing a script that will read and delete all of the lines, but the
> first one, and copy the data into a file in a directory where there
> aren't any write permissions. we are going to run this script every night
> at 11:59 PM to gather the day's logfile.
>
> don't ask me, i just work here :)
>

-- 
_
[EMAIL PROTECTED]
http://www.quantifier.org
_
Pardon me, but do you know what it means to be TRULY ONE with your BOOTH!




perl to build html

2001-06-03 Thread KeN ClarK

I bought O'Reilly's PERL In A Nutshell last evening and have been lurking
here for awhile. I'm curious if any answers exist for this question:

I want to take mp3's in a directory and create html page with href links
to these files. There are far too many of them to just create the page
raw. Assuredly this can be done. W/Linux, I've figured out how to recreate
the page all the way to reading the *.mp3 contents...but then I get stuck.
I have limited language experience.

Any suggestions?

Ken

-- 
_
[EMAIL PROTECTED]
http://www.quantifier.org
_
Prediction is very difficult, especially of the future.
- Niels Bohr




newbie prob/different flavor

2001-06-25 Thread KeN ClarK

I am using cyclonic webmail . apache is set to serve the
directory. You get index listing @ http://www.quantifier.org/cyclonic/ and
when I type quantifier.org/cyclonic/cyclonic.pl I get the text of the
script itself. Now I would think Something needs to invoke the script. But
what? This is how I interpreted the INSTALL file's directions. When ran
from command line (Linux, perl 5.6) with -w I get no errors and the screen
stouts html to the screen. But that doesn't get served by apache.

If anyone uses a webmail interface to get local mail off their box,
please reply. I don't want to reinvent the wheel when I am just
beginning to learn to walk...

Thanks.

Ken

-- 
_
[EMAIL PROTECTED]
http://www.quantifier.org
_
All life evolves by the differential survival of replicating entities.
-- Dawkins




from one problem to the next emumail...

2001-06-26 Thread KeN ClarK

SO I am closer to webmail. http://www.quantifier.org/emu/ will forward to
the cgi script the way the index.html page tells it to. ALL of the
directories are recursively set up in apache. Why does it serve the script
itself like text? Do I need to define the type in the second line of the
script? HAS ANYONE had this issue?

Ken

-- 
_
[EMAIL PROTECTED]
http://www.quantifier.org
_
"Ada is PL/I trying to be Smalltalk.
-- Codoso diBlini




Newbie system call question

2001-07-18 Thread Ken Cole

if from the command line a run

/dir1/dir2/progname ar1 arg2 arg3 -p /dev/null

it works.

if I do:

@args = ("/dir1/dir2/prgname","arg1","arg2","arg3","-p /dev/null");
$rc = system @args;

The application stops with an error saying the -p /dev/null is an
invalid argument.

It is a standard argument for the app telling it where to "put" its
output.

It doesn't matter in what order I put the arg I still get the same error
message.

I am so confused :-(

Ken Cole


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




RE: Newbie system call question

2001-07-18 Thread Ken Cole

Hello,

> Seems like you're stuck again.  Okay, the problem here is the
> ">/dev/null".  Notice the ">" sign over there.  It's the shell
> redirection metacharacter which causes "the shell" to pipe
> the output of
> one script to a file.  When you use "system" in list context,
> like you're
> doing, you will not be able to use any shell metacharacters
> "> < | & && ...".  The output of the program will go to STDOUT
> automatically--cannot be forwarded or piped.

Thanks for the detail, I prefer to understand why, not just how to make
things work.

> 1.  Use the one-argument call to system just like you type
> your command
> from the shell.
> system "/dir1/dir2/prgname arg1 arg2 arg3 -p /tmp/kc >/dev/null";

Did this, works fine.

> 2.  Check if "progname" has an option to shut it up.  "Usually -q"

No

> If you're the one who wrote that program, then implement -q.

Not me so not possible.

> 3.  Use the backticks and throw away the output:
> `/dir1/dir2/prgname arg1 arg2 arg3 -p /tmp/kc >/dev/null`;
> But this is bad since poor perl will do its best collecting data that
> you'll throw away anyways.

Will stick with 1.

> 4.  Probably there are 10 MWTDI.

ditto

Thanks for the help. Much appreciated.

ken Cole


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




I need to create a module - I think - and don't know how

2001-07-19 Thread Ken Cole

Hi everyone,

I am starting to write a number of perl programs.  Most relate around a
particular application which has numerous environmental variables.  The
variables can be set from a number of places and those places have a
hierarchy as to which takes precedence over the others.

I have therefore written a perl sub routine that builds up a hash of
environmental variables and their respective values and then use them in
my scripts.

I no longer want to maintain this sub routine in every script I write
regarding this application.

Do I need to create a module and put this routine in it?

If so how?

Do I declare it as a function in the module and then call it from my
other scripts?

All help as usual gratefully appreciated.

Ken Cole


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




help with email submit

2001-07-21 Thread ken clark

Help. I am very new. I am using this script to create a guestbook entry; 
however I want it to ALSO email the results to me. I am willing to figure 
this out myself if someone can point me in the right direction.  There are 
several late night comments included. Ignore those of course...

Ken
*

#!/usr/bin/perl -w

use 5.004;
use strict;
use CGI qw(:standard);
use Fcntl qw(:flock);

sub bail {
my $error = "@_";
print h1("Unexpected Error"), p($error), end_html;
die $error;
}

my(
$CHATNAME,
$MAXSAVE,
$TITLE,
$cur,
@entries,
$entry
);

$TITLE = "I/O";
#$BOBBY = "your last ditch effort at input on my server";
$CHATNAME = "/usr/tmp/chatfile";
#either this must be a huge number, or you need to learn how to embed html
#into a perl script.  but in order to keep it from being kicked out
#the bottom on chatfile, this must be huge.  so figure out how
$MAXSAVE = 1000;

print header, start_html ("you are not a beautiful or unique snowflake");
print h1($TITLE);

#print header, start_html ($TITLE), h1($TITLE); 
#print body bgcolor="#00" fontface="#FF"

#print ("your last ditch effort at input on my server");
#print ("the only say you will ever have at quantifier.org");
print h2("never allow yourself to believe that your opinions are important");
#print ($BOBBY);

$cur = CGI->new();
if ($cur->param("message")) {
$cur->param("date", scalar localtime);
#$cur->param("date", (date +"%D %H:%M"));
@entries = ($cur);
}

open(CHANDLE, "+< $CHATNAME") || bail("cannot open $CHATNAME: $!");

flock(CHANDLE, LOCK_EX) || bail("cannot flock $CHATNAME: $!");

while (!eof(CHANDLE) && @entries < $MAXSAVE) {
$entry = CGI->new(\*CHANDLE);
push @entries, $entry;
}
seek(CHANDLE, 0, 0) || bail("cannot rewind $CHATNAME: $!");
foreach $entry (@entries) {
$entry->save(\*CHANDLE);
}
truncate(CHANDLE, tell(CHANDLE)) ||
bail("cannot truncate $CHATNAME: $!");
close(CHANDLE) || bail("cannot close $CHATNAME: $!");

print hr, start_form;
print ("email:", $cur->textfield(
-NAME => "name",
-SIZE => 35));
#watch, this is rediculously backwards.  drunk.
print ("name:", $cur->textfield(
-NAME => "..email",
#how do i make spaces so i can take out ..email?
-SIZE => 35));
print p h2("input:", $cur->textfield(
-NAME => "message",
-OVERRIDE => 1,
-SIZE => 100));
print p(submit("send"), reset("clear"));
print end_form, hr;

print h2("output:");
foreach $entry (@entries) {
#was only three
printf("%s %s [%s]:  %s",
#print date
$entry->param("date"),
$entry->param("email"),
#mod here, too, remember its backwards.
$entry->param("name"),
$entry->param("message"));

print br();
}
print end_html;

-- 
_
[EMAIL PROTECTED]   
http://www.quantifier.org
_
The Pig, if I am not mistaken,
Gives us ham and pork and Bacon.
Let others think his heart is big,
I think it stupid of the Pig.
-- Ogden Nash

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




RE: I need to create a module - I think - and don't know how

2001-07-22 Thread Ken Cole

Hi Jos,

> That's a good idea Joni,
>
> however, personally, i'd always add a constructor, no matter
> how basic...
>
> you could do something like this (add this to the file joni
> described):
>
> sub new { return bless {}, shift }

Lost me here :(

> this will indicate that this object belongs to that package you just
> wrote...
> this makes things a lot more flexible, and you can store
> information in the
> object too (it's really just a hash reference)
>
> here's how you'd use it:
>
> my $obj = new Package_name;
>
> and if you had the function 'blaa' Joni described, you would
> access that as:
>
> $obj->blaa( $arg1, $arg2 );

My function returns a hash.  How do I access it from the calling
program?

> so just like a normal subroutine, only now you got it in a
> nice and cool
> object.
>
> say you'd build lots and lots of methods in taht package
> name, you can have
> them, instead of giving return values,
> store stuff in your object (cuz it's just a hash ref remember! )
>
> like so for example:
>
> $obj->{foo} = 'bar';
>
> now every subroutine that is called in that package thru $obj
> has access to
> the value belonging to 'foo'
> or can even overwrite it...
>
> I am feeling i'm getting a bit technical here... if there's a
> desire i write
> a tutorial about basic packages, please let me know

That would be good.  I did finf some other writings on packages/modules
but they too
have left me wondering.

> you can view some other tuts i wrote on http://japh.nu already
> (or http://japh.nu/index.cgi if you want to see the
> experimental/work in
> progress stuff )
>

Thanks

Ken


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




RE: Cgi Win xp Perl

2003-01-07 Thread Ken Lehman
Try putting the -T after the -w at the top of your perl script, make sure
that your script ends in .cgi and your iis is setup to run scripts and
change 

print $q->header ("text/plain");

to 

print $q->header ("text/html");


-Original Message-
From: Paul Kraus [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 07, 2003 3:02 PM
To: Perl
Subject: Cgi Win xp Perl


I am running on a windows xp pro desktop with iis installed. I have
active state Perl installed and have been using it with out a problem. I
just started to play with cgi and I am having a lot of problems getting
it to work right. I have a static html form that's action calls the
following script. When it I hit submit all it does is display it as if
it was a text file. If I rename it to .pl then it tries to download it.
However if I have just call another test cgi script that displays some
html then it runs fine (also named .pl) with one exception it tells me
that it is to late to do -T.

So basically I need to find out how to call this script from my form and
have it execute.
Second I need to find out how to get .cgi scripts to load instead of
displaying or trying to download.
Third I need to know how to pass the -t to the compiler before my script
executes. (I am assuming this is a problem with Perl on windows not
using the shebang. Even though -w works odd.)

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

my $q=new CGI;
print $q->header ("text/plain");
print "These are the parameters I received:\n\n";

my ($name, $value);
foreach $name ($q->param){
  print "$name:\n";
  foreach $value ($q->param($name)){
print "\t$value\n";
  }
}


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




The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


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




RE: Cgi Win xp Perl

2003-01-07 Thread Ken Lehman
Is this path right? This looks like a unix path and your trying this on
windows right?
> #!/usr/bin/perl -w

Anyway I setup my XP box to run perl, I am sorry to say I forget exactly
what I did but I know I had to set something up in IIS settings. 
Sorry, you might get faster help from the cgi mailing list.
-Ken

-Original Message-
From: Paul Kraus [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, January 07, 2003 3:11 PM
To: 'Ken Lehman'; 'Perl'
Subject: RE: Cgi Win xp Perl


It still just displays the contents of my script rather then running it.

Do I need to some how associate .cgi with Perl?

> -Original Message-
> From: Ken Lehman [mailto:[EMAIL PROTECTED]] 
> Sent: Tuesday, January 07, 2003 3:12 PM
> To: 'Paul Kraus'; Perl
> Subject: RE: Cgi Win xp Perl
> 
> 
> Try putting the -T after the -w at the top of your perl 
> script, make sure that your script ends in .cgi and your iis 
> is setup to run scripts and change 
> 
> print $q->header ("text/plain");
> 
> to 
> 
> print $q->header ("text/html");
> 
> 
> -Original Message-
> From: Paul Kraus [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, January 07, 2003 3:02 PM
> To: Perl
> Subject: Cgi Win xp Perl
> 
> 
> I am running on a windows xp pro desktop with iis installed. 
> I have active state Perl installed and have been using it 
> with out a problem. I just started to play with cgi and I am 
> having a lot of problems getting it to work right. I have a 
> static html form that's action calls the following script. 
> When it I hit submit all it does is display it as if it was a 
> text file. If I rename it to .pl then it tries to download 
> it. However if I have just call another test cgi script that 
> displays some html then it runs fine (also named .pl) with 
> one exception it tells me that it is to late to do -T.
> 
> So basically I need to find out how to call this script from 
> my form and have it execute. Second I need to find out how to 
> get .cgi scripts to load instead of displaying or trying to 
> download. Third I need to know how to pass the -t to the 
> compiler before my script executes. (I am assuming this is a 
> problem with Perl on windows not using the shebang. Even 
> though -w works odd.)
> 
> #!/usr/bin/perl -w
> use strict;
> use CGI;
> 
> my $q=new CGI;
> print $q->header ("text/plain");
> print "These are the parameters I received:\n\n";
> 
> my ($name, $value);
> foreach $name ($q->param){
>   print "$name:\n";
>   foreach $value ($q->param($name)){
> print "\t$value\n";
>   }
> }
> 
> 
> Paul Kraus
> Network Administrator
> PEL Supply Company
> 216.267.5775 Voice
> 216-267-6176 Fax
> www.pelsupply.com
> 
> 
> --
> --
> 
> The views and opinions expressed in this email message are 
> the sender's own, and do not necessarily represent the views 
> and opinions of Summit Systems Inc.
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


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




RE: Perl book

2003-01-15 Thread Ken Lehman
Pink is first edition, blue is second edition, i think there is a third
edition out now, may as well go for the latest and greatest
-Ken

-Original Message-
From: Robbie Staufer [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 15, 2003 12:20 PM
To: [EMAIL PROTECTED]
Subject: Re: Perl book


There is a pink and a blue camel book from O'Reilly.  What is the
difference, and which comes most highly recommended?

Robbie

--
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Robbie Staufer
NCAR/SCD
1850 Table Mesa Dr. Rm. 42
Boulder, CO. 80305
(303) 497-1836



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



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


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




How do I test a variable to see if it is a scalar or a hash?

2003-01-23 Thread Ken Lehman
How do I test a variable to see what type of variable it is(scalar, array,
hash, etc...)?
What I am trying to accomplish is I have a hash and some values are scalar
data and some values are nested hashes and
I need a way to tell the difference.
Book or web site references are welcome, thanks in advance.
-Ken



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


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




RE: Formatting Variables.

2003-02-11 Thread Ken Lehman
Have you tried using printf?

-Original Message-
From: Ramón Chávez [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 11, 2003 9:07 AM
To: [EMAIL PROTECTED]
Subject: Formatting Variables.


Hello boys and girls.

Is there a way to give format to a Variable.

I mean, if I don't want to get printed 3.1415926535 (Or any irrational
number) but something like 3.14, is there a way to use format??

Or I need to make some string treating (more lines)??

Thank you everyone.

-rm-


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



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


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




howto: open/create a file as executable

2003-03-28 Thread Ken Lehman
Is it possible to open/create a file with open that does not exist and give
it a umask that makes it executable, say for the purpose of generating shell
scripts?

For example, say

open OUT_FILE, MAGIC_UMASK, "/scripts/new_script";

where the current umask is 2.
Is the only option to chmod the file after it has been created?

Thanks for any help.
-Ken



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


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



Newbie not getting expected values from s/// operator

2003-05-30 Thread Ken Tozier
I wrote a simple script to extract some of the info Photoshop 6 embeds 
in jpeg files through the "file info" dialog box and find that I can 
extract the info no problem with:

open(PROPS, 'egrep -a \']+)>[^<]*\' 
"botanical-garden12-full.jpg" | ');

Doing print ; shows that the info I'm looking for is indeed 
extracted.

Next I try to loop through the results and extract parts of each string 
like so:

$tmp = "";
while ()
{
$tmp .=  s/]+)>([^<]*)/$1: $2/;
}
Doing a "print" on $tmp, yeilds

1

None of the lines in "PROPS" contain a single digit character so why am 
I getting a string of 1's?

Thanks for any help

Ken



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


Re: Newbie not getting expected values from s/// operator

2003-05-30 Thread Ken Tozier
That did the trick, Thanks.

Ken

On Friday, May 30, 2003, at 04:26 AM, Halkyard, Jim wrote:
Without testing or really investigating this I'd say you're getting the
'exit status' of the s/// operation. As you've written it the 
substitution
is working on $_ and you're appending the return value to $tmp each 
time
through.

Try this:

$tmp = "";
while ()
{
s/]+)>([^<]*)/$1: $2/;
$tmp .= $_;
}
That should do the substitution on $_, and then append the modified $_ 
to
$tmp.

Jim



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


RE: Newbie not getting expected values from s/// operator

2003-05-31 Thread Ken Tozier
On Friday, May 30, 2003, at 08:24 AM, Kipp, James wrote:
Next I try to loop through the results and extract parts of
each string
like so:
$tmp = "";
while ()
{
$tmp .=  s/]+)>([^<]*)/$1: $2/;
}
Doing a "print" on $tmp, yeilds

1

None of the lines in "PROPS" contain a single digit character
so why am
I getting a string of 1's?
you assigning the return value of the s/// statement to temp. the 1's 
are
telling  you the statement is true.
An earlier poster emailed me directly with the solution
s/]+)>([^<]*)/$1: $2/;
$tmp .= $_;
Thanks to both of you for responding

Ken

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


Splicing sub input into a regular expression

2003-05-31 Thread Ken Tozier
I just put the finishing touches on some Perl code that reads info from 
Photoshop jpeg files but when trying to package it up inside a 
subroutine, I'm having trouble using the input variable.

For example in the naked code I wrote:
open(PROPS, 'egrep -a \']+)>[^<]*\' 
"file.jpg" | ');

but when trying to package inside subroutine like so:

sub GetPhotoInfo($inPhotoPath)
{
	open(PROPS, 'egrep -a \']+)>[^<]*\' 
$inPhotoPath | ');
}

The script just hangs (seems like it's waiting for standard input from 
the keyboard):

Also tried the dot operator to build the expression out of the input 
and it's constituent parts, but got the same result.

How does one actually use passed in variables in Perl?

Thanks

Ken

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


Re: Splicing sub input into a regular expression

2003-05-31 Thread Ken Tozier
That did the trick. Thanks,

Ken

On Friday, May 30, 2003, at 07:19 PM, James Edward Gray II wrote:

On Friday, May 30, 2003, at 06:10  PM, Ken Tozier wrote:

sub GetPhotoInfo($inPhotoPath)
This should be:  sub GetPhotoInfo

{
	open(PROPS, 'egrep -a \']+)>[^<]*\' 
$inPhotoPath |
All sub routine parameters are passed in the @_ variable.  To get the 
first of those $_[0], should do the trick.  So replace $inPhotoPath 
with $_[0] in the line above.

 ');
}
Hope that helps.

James



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


Returning arrays from subroutines... how?

2003-06-01 Thread Ken Tozier
I'm sure this is an easy one but after Googling for hours, I still 
don't get it. Given the following subroutine, how do I return the 
result array? Nothing I try works.

sub GetMarmots
{
@result = ();
$result{'steppe marmot '} = 4;
$result{'himalayan marmot'} = 3;
$result{'mongolian marmot'} = 1;
$result{'woodchuck'} = 6;
    
return @ result;
}
Thanks in advance,

Ken

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


Re: Returning arrays from subroutines... how?

2003-06-02 Thread Ken Tozier
Thanks for answering David, Jeff and Beau. My script works like a charm 
now.

Ken

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


Passing arrays/associative arrays into subroutines ... how?

2003-06-02 Thread Ken Tozier
Here's the flip side of yesterday's array question. Now that I know how 
to pass associative arrays out of a routine, I'm having trouble trying 
to use them in other routines. The best I can figure from reading is 
that I need to pass them by reference, but in practice, the terminal 
always fills up with "uninitialized value" messages when I try to use 
the array values inside subroutines. Could someone show me how to make 
this work?

Thanks in advance,

Ken

my %wombatStats = GetWombat();
my $description = DescribeCritter(\% wombatStats);
print $description;
sub DescribeCritter
{
	my %input_rec = $_[0];
	my $result = "";
	
	$result .= $input_rec{'name'}
	$result .= ' is a '.$input_rec{'kind_of_animal'}
	$result .= ' whose favorite past time is eating '. 
$input_rec{'favorite_food'}
	$result .= ' and '. $input_rec{'favorite_hobby'}
	$result .= ' on the beach in '. $input_rec{'favorite_vacation_spot'}
	return $result;
}

sub GetWombat
{
my %result = ();
$result{'kind_of_animal'} = "wombat";
$result{'name'} = "Theodore";
$result{'favorite_food'} = "nachos";
$result{'favorite_hobby'} = "burping";
$result{'favorite_vacation_spot'} = "Cancun";
return %result;
}
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Passing arrays/associative arrays into subroutines ... how?

2003-06-02 Thread Ken Tozier
On Sunday, June 1, 2003, at 04:35 PM, James Edward Gray II wrote:
On Sunday, June 1, 2003, at 03:27  PM, Ken Tozier wrote:

my $description = DescribeCritter(\%wombatStats);
This is passing a hash to a hash.  No reference required for that.  
Just drop the \.  I also believe you have a space after the % that 
shouldn't be there.

Hope that helps.

James

No luck. Dropping the \ in 'my $description = 
DescribeCritter(\%wombatStats);' didn't fix the problem.

Directly before I pass "wombatStats" to the DescribeCritter, routine I 
do a print "$_ => $wombatStats{$_}\n" for (sort keys % wombatStats); 
and everything looks fine. As soon as I get into the subroutine however 
and do the following:

my %inRecord = $_[0];

the terminal spits out "Odd number of elements in hash assignment at 
..." followed by " Use of uninitialized value in concatenation (.) at 
..." when I try to grab one of the values. Am I assigning the "my" 
variable wrong?

Thanks,

Ken

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


hex to dec and dec to hex

2003-06-11 Thread Ken Lehman
Is there an easy way to go back and forth between decimal and hex in perl.
I know of the hex function which solves my hex to dec problem but how about
a dec->hex function or module? I need the value which is why printf isn't
working for me.
Thanks for any help.
-Ken



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


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



HOWTO:Dynamically getting all of the global variables and their v alues

2003-07-01 Thread Ken Lehman
I would like to write a function that will get all the global variables that
are declared in my script plus their values( which will all be strings if
that matters). This is what I have so far:

my ( $varName, $globValue );

while ( ($varName, $globValue) = each %main:: )
{
  print "\$$varName $globValue \n";
}


This prints a whole lot of stuff including function names but the variables
are not in here. My goal is to have this function pick up the variables
dynamically everytime the script is run, get the values and do some
varification before getting into the meat of the script, without having to
add or remove the variables manually from the sub whenever I add or remove a
variable from the script. 
Thanks in advance for any help
-Ken



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


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



CPAN problem

2003-07-19 Thread Ken Gordon
Running Perl 5.8.0 on Mac OS 10.1.5, when I try to connect the CPAN, the 
first time I enter a command I get the following errors. Any suggestions?

dyld:: Too many arguments.
_Perl_safefree
_Perl_safemalloc
_Perl_saferealloc
_Perl_sv_2pv
_perl_call_sv
_perl_eval_sv
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: CPAN problem - Corrected

2003-07-20 Thread Ken Gordon
I found the solution to my problem at:

http://www.mail-archive.com/fink-
[EMAIL PROTECTED]/msg02454.html

Running Perl 5.8.0 on Mac OS 10.1.5, when I try to connect the CPAN, 
the first time I enter a command I get the following errors. Any 
suggestions?

dyld:: Too many arguments.
_Perl_safefree
_Perl_safemalloc
_Perl_saferealloc
_Perl_sv_2pv
_perl_call_sv
_perl_eval_sv
-- To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Ken Gordon
(780) 910-7652
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


What Type Of Data Structure Is This?

2002-09-30 Thread Ken Hammer


 A strange question.

 I'm using the following data structure to
store information from a data base query:

$tablename{"$table"} = {
"table_name"=> ["$table"],
"index_name"=> ["$index_name"],
"columns"   => ["@column_name"],
"type"  => ["$index_type"],
"tablespace"=> ["$tablespace_name"]

 This works great and I can later extract the info
from this structure. I have 2 questions. What type of
structure is this and how do I add to it?

 When I try to add more info from a subsequent query like
this:

$tablename{$table} = {
"con_name"  =>  ["$constraint_name"],
"con_type"  =>  ["$type"],
"rem_con_name"  =>  ["$r_constraint_name"],
"created_by"=>  ["$generated"]
};

 I lose all the previous information, so that only the above
is now stored.
 What have I done, how do I do what I want, and am I in over my head?

-- 
Ken

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




RE: What Type Of Data Structure Is This (Summary)

2002-09-30 Thread Ken Hammer


 The structure is a hash of hashes. Thanks
to:
   nkuipers <[EMAIL PROTECTED]>
   Robin Cragg <[EMAIL PROTECTED]>
   Timothy Johnson <[EMAIL PROTECTED]>

who correctly pointed this also to me. They
also provided some information on how to add
items to the array, and an easier way to 
populate the hash. I was using an anonymous
hash method.

Thanks Again

Original Post:

 A strange question.

 I'm using the following data structure to
store information from a data base query:

$tablename{"$table"} = {
"table_name"=> ["$table"],
"index_name"=> ["$index_name"],
"columns"   => ["@column_name"],
"type"  => ["$index_type"],
"tablespace"=> ["$tablespace_name"]

 This works great and I can later extract the info
from this structure. I have 2 questions. What type of
structure is this and how do I add to it?

 When I try to add more info from a subsequent query like
this:

$tablename{$table} = {
"con_name"  =>  ["$constraint_name"],
"con_type"  =>  ["$type"],
"rem_con_name"  =>  ["$r_constraint_name"],
    "created_by"=>  ["$generated"]
};

 I lose all the previous information, so that only the above
is now stored.
 What have I done, how do I do what I want, and am I in over my head?

-- 
Ken Hammer
University Of Michigan

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




Printing A Hash of Hashes

2002-09-30 Thread Ken Hammer


 From a previous post I needed to identify
a particular data structure. It is a hash of hashes. 
Now, I need to print the hash out.
 I'm using the code from the "Programing
Perl" 3rd edition from O'Reilly on how
to print out the hash and of course I'm
having a problem.

 This is from Chapter 9, page 281 slighly
changed to reflect my values:

for $table ( keys %tablename) {
print "Table Name: $table \n";

for $items ( keys %{ $tablename{$table} } ) {
print "\t$items=$tablename{$table}{$items}\n ";

}

print "\n";

 Here are the results:

Table Name: TURBINE_PERMISSION 
con_name=ARRAY(0x216de8)
index_name=TURBINE_PERMISSION_PK
con_type=ARRAY(0x216c8c)
columns=PERMISSION_ID
created_by=ARRAY(0x211a50)
type=NORMAL
rem_con_name=ARRAY(0x211b04)
tablespace=CTNG

 This is the code that created the hash of hashes.
It was done in 2 parts:

 First part (initilizing):

$tablename{"$table"} = {
"index_name"=> $index_name,
"columns"   => @column_name,
"type"  => $index_type,
"tablespace"=> $tablespace_name

};

 Adding to the hash:

$tablename{$table} -> {con_name} = [$constraint_name];
$tablename{$table} -> {con_type} = [$type];
$tablename{$table} -> {rem_con_name} = [$r_constraint_name];
$tablename{$table} -> {created_by}   = [$generated];

 The above is from the help (thank you) from a previous post.

 Why am I getting the value in the first part, and the
memory location for the second part? In other words, the key/values
print out as expected from the initializing loop, but not from
the "adding" part?

-- 
Ken Hammer
University Of Michigan

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




Re: Printing A Hash of Hashes

2002-09-30 Thread Ken Hammer

Mark Anderson wrote:
> 
> Why are you wrapping these in arrays?  If you used:
> $tablename{$table} -> {con_name} = $constraint_name;
> $tablename{$table} -> {con_type} = $type;
> $tablename{$table} -> {rem_con_name} = $r_constraint_name;
> $tablename{$table} -> {created_by}   = $generated;
> 
> Then you would get the values in your print, instead of array indexes.
> 
  Bingo!!! That was it Mark! Thank you!

> I hope that I answered your question above.  The other option is to test
> each value to see if it is an array, and then dereference it correctly, but
> I don't think that's what you are looking for.
> 
> /\/\ark

-- 
Ken Hammer
University Of Michigan

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




Getting A File Name

2002-10-16 Thread Ken Cole

Hi,

I have a directory in which there are files such as:

fred.1
fred.2
fred.3

The suffix increases and older files get deleted so there are always 3 fred.* files in 
the directory at any one time.

I need to get the name of the file with the highest suffix so I can go and do some 
other stuff with it.

I have tried lots of different things but to no significant outcome.

Any suggestions?

Thanks

Ken

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




RE: Getting A File Name

2002-10-16 Thread Ken Cole

Thanks Vinai,

For the code and the explanations.

Ken

> -Original Message-
> From: vinai AR [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, October 17, 2002 1:54 PM
> To: Ken Cole; [EMAIL PROTECTED]
> Subject: RE: Getting A File Name
> 
> 
> I think this script will help u.
> Assume that u r in the directory where u have these three 
> files.(If not
> use chdir and move to that directory).
> 
> @file_List = 
> 
> On executing the above statement @file_List will have all the three
> files fred.*.
> 
> map {$_ =~ s/fred.//} @file_List
> 
> The above statement removes the "fred." from each file name and the
> @file_List array will only have the extension part of each file.
> 
> My $ext = 0;
> foreach $val (@extension)
> {
>   $ext = $val if($val > $ext);
> } 
> 
> Now the variable $ext will have the highest suffix value.
> 
> We can generate the file name with the below statement.
> $file_Name = "fred.$ext";
> 
> The full code is below
> 
> @file_List = ;
> map ($_ =~ s/fred.//gi, @file_List);
> my $ext = 0;
> foreach $val (@file_List)
> {
>       $ext = $val if($val > $ext);
> } 
> $file_Name = "fred.$ext";
> print "$file_Name\n";
> 
> Rgds,
> vinai
> -Original Message-
> From: Ken Cole [mailto:[EMAIL PROTECTED]] 
> Sent: Wednesday, October 16, 2002 7:44 AM
> To: [EMAIL PROTECTED]
> Subject: Getting A File Name
> 
> 
> Hi,
> 
> I have a directory in which there are files such as:
> 
> fred.1
> fred.2
> fred.3
> 
> The suffix increases and older files get deleted so there are always 3
> fred.* files in the directory at any one time.
> 
> I need to get the name of the file with the highest suffix so I can go
> and do some other stuff with it.
> 
> I have tried lots of different things but to no significant outcome.
> 
> Any suggestions?
> 
> Thanks
> 
> Ken
> 
> -- 
> 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]




Getting A File Name

2002-10-18 Thread Ken Cole
Hi,

I have a directory in which there are files such as:

fred.1
fred.2
fred.3

The suffix increases and older files get deleted so there are always 3 fred.* files in 
the directory at any one time.

I need to get the name of the file with the highest suffix so I can go and do some 
other stuff with it.

I have tried lots of different things but to no significant outcome.

Any suggestions?

Thanks

Ken

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




howto: array index inside a foreach loop

2002-11-22 Thread Ken Lehman
Say I have a foreach loop that I used to modify elements when they match a
pattern that I am searching for, but there is one special case where I get a
match and I need the index for that element. Can I get that index or do I
have to go with a for() loop. If this can be done how would I use it?
Thanks in advance
Ken


# something along these lines
foreach $temp_string (@array_of_strings)
{
 if ($temp_string =~  /^CRASH/)
 {
   $array_of_strings[$this_is_what_I_need - 1] = "LOOK OUT!";
 }


}



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


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




RE: howto: array index inside a foreach loop

2002-11-22 Thread Ken Lehman
yeah sorry, my problem is not quite as simple as the example. I just put
that in to try and illustrate my point. I'm not trying to do a straight
replace, I need to replace an element only if I find a certain string
somewhere else.

-Original Message-
From: david [mailto:[EMAIL PROTECTED]]
Sent: Friday, November 22, 2002 4:12 PM
To: [EMAIL PROTECTED]
Subject: Re: howto: array index inside a foreach loop


Ken Lehman wrote:

> Say I have a foreach loop that I used to modify elements when they match a
> pattern that I am searching for, but there is one special case where I get
> a match and I need the index for that element. Can I get that index or do
> I have to go with a for() loop. If this can be done how would I use it?
> Thanks in advance
> Ken
> 
> 
> # something along these lines
> foreach $temp_string (@array_of_strings)
> {
>  if ($temp_string =~  /^CRASH/)
>  {
>$array_of_strings[$this_is_what_I_need - 1] = "LOOK OUT!";
>  }
> 
> 
> }
> 

sorry i might be missing your point but why not just:

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

my @array_of_strings = qw(CRASH Windoes use linux);

s/^CRASH/LOOK OUT!/ for(@array_of_strings);

print join("\n",@array_of_strings),"\n";

__END__

prints:

LOOK OUT!
windoes
use
linux

david

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



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


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




does perl have boolean variables?

2002-12-04 Thread Ken Lehman
I can't say:

#!/yadayada/perl -w
use strict;

$seen = true;

if( $seen )
{
 #whatever
}
else
{
 #something different
}

I get a bareword error, I'm using perl 5.004_04. Does perl support booleans
like this, do I need to use a package?
Thanks in advance
-Ken



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


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




RE: include .pl in html

2002-12-11 Thread Ken Lehman
This works where I am at, you could give it a try



-Original Message-
From: Adam Wilson [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, December 10, 2002 11:27 AM
To: [EMAIL PROTECTED]
Subject: include .pl in html


Hi,

can anyone help me, i want to include the ouput of a perl file within an
html file, without using a seperate frame. I am familiar with php, is there
a way to include like there is in php? Or do i have to output the HTML from
the perl script? 

Any help very much appreciated... i left my books at home!!!

Adam.



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


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




HOWTO use system call on windows with a space in the path

2002-12-11 Thread Ken Lehman
I would like to write a perl script for windows that in the right situation
fires off another program, the problem is I can't get it to work using
system or exec calls. The file is in the program files directory I tried 
system("c:\program files\etc...") and some variations but I can't get it to
work
Help is appreciated
Thanks in advance.
-Ken



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


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




catch kill -9 from unix command prompt

2002-12-17 Thread Ken Lehman
Is there a way for my program to execute a few lines of code before dying
when it is sent a kill -9 from a unix shell? The book I have says no, I
don't want to ignore the signal, just some clean up.
Thanks.
-Ken



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


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




Re: Weekly list FAQ posting

2004-04-05 Thread Ken Wolcott
On Mon, 2004-04-05 at 11:00, [EMAIL PROTECTED] wrote:
> NAME
> beginners-faq - FAQ for the beginners mailing list

...nice FAQ snipped for brevity...

Could you please add something to the subject line
stating that this email message is pertinent to the
beginners perl list...something like:

Subject: [Beginning Perl] Weekly List FAQ posting

Thanks,
Ken


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




Re: How do you invoke a Clearcase View?

2004-05-20 Thread Ken Wolcott
On Thu, 2004-05-20 at 10:20, PerlDiscuss - Perl Newsgroups and mailing
lists wrote:
> Does anyone know how to call a Clearcase setview from Perl, where you can
> change directories and move around the vob, and compile files?

I write the contents I wish to execute in a ClearCase setview -exec call
to a file using perl, then call system to cleartool setview -exec
filename view_name.  Actually, I use commmand pipes in perl now rather
than calling system so that if I wish to filter on potential errors I
can do that where it's not easy to do that with the output coming from a
system call or backticks.

  I do all kinds of ClearCase things with perl, but not via the
ClearCase CPAN module(s) such as what can be found at:

http://cpan.uwinnipeg.ca/search?query=clearcase&mode=dist

But I'll be looking into those as I find time.

Hope this helps,
Ken Wolcott



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




garbage errors when number of characters in script exceeds some number

2004-07-12 Thread Ken Rearick
I wrote an application last week and when I attempted to compile it on 
both a sun and pc using perl5 I keep getting garbage error message when 
the character count of the source was greater than about 16,000 
characters. If I went into the source and removed white spaces to reduce 
the character count below this point the compile would work fine. But as 
soon as I added additional functionality that increased the character 
count above some magic number I would start getting these garbage error 
messages until I deleted more white space. The application works but the 
source is very had to read with no indenting and no comments.

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



Re: garbage errors when number of characters in script exceeds some number

2004-07-13 Thread Ken Rearick
I discovered last night that if I eliminate the switch statements the
problem go away. This morning I also tried moving the use switch in side the
if blocks containing the switch statements. This also eliminated the
problem.


"Ken Rearick" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I wrote an application last week and when I attempted to compile it on
> both a sun and pc using perl5 I keep getting garbage error message when
> the character count of the source was greater than about 16,000
> characters. If I went into the source and removed white spaces to reduce
> the character count below this point the compile would work fine. But as
> soon as I added additional functionality that increased the character
> count above some magic number I would start getting these garbage error
> messages until I deleted more white space. The application works but the
> source is very had to read with no indenting and no comments.
>



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




finding Makefiles which containing a backslash continuation character where the next line is blank or whitespace

2004-08-03 Thread Ken Wolcott
Hi;

  I need to find Makefiles that contain a backslash line continuation
character followed by a blank (or whitespace only) line.  I tried a
regular expression first but just couldn't get it right.  I then tried
comparing by a pair of strings, but that isn't right either.

First try:

#!/usr/bin/perl

use strict;
use warnings;
use diagnostics;

my $valid_string = "sample text\\n second line is valid\n";
my $invalid_string = "sample text \\n   \n";
if ($invalid_string =~ m|\\\n\W$|) {
print "INVALID\n" ;
} else {
print "valid\n";
}
if ($valid_string =~ m|\\\n\W$|) {
print "INVALID\n" ;
} else {
print "valid\n";
}


Second try:

#!/usr/bin/perl

use strict;
use warnings;
use diagnostics;

foreach my $file (@ARGV) {
open (MAKEFILE, $file) or die "ERROR: Unable to open " . $file . "
for reading, $!";
my $line_before = "";
my $linecount;
while (my $line = ) {
chomp $line;
$linecount++;
print "DEBUG: " . ($linecount-1) . " line (before)  = |" .
$line_before . "|\n";
print "DEBUG: " . $linecount . " line (current) = |" . $line
. "|\n\n";
if ($line_before =~ m|\\$|) {
print $file . " has a backslash continuation to a following
blank line at or near line " . $linecount . "\n" if ($line =~ m|^\W*$|);
} else {
$line_before = $line;
}
}
close (MAKEFILE);
}


The first one reports both strings as valid, so the regex is wrong?

The second one incorrectly reports that all Makefiles have one or more
lines with continuation (\) characters at the end of the line followed
by a blank (or whitespace only) line.

Please help,
Thanks in advance,
Ken Wolcott



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




Re: finding Makefiles which containing a backslash continuation character where the next line is blank or whitespace

2004-08-04 Thread Ken Wolcott
John;

  Thank you very much for the help...works like a charm...now I'll try
to study it carefully to understand how to use this the next time I need
something like this...

Cool...

Ken Wolcott

On Tue, 2004-08-03 at 20:20, John W. Krahn wrote:
> Ken Wolcott wrote:
> > Hi;
> 
> Hello,
> 
> >   I need to find Makefiles that contain a backslash line continuation
> > character followed by a blank (or whitespace only) line.  I tried a
> > regular expression first but just couldn't get it right.  I then tried
> > comparing by a pair of strings, but that isn't right either.
> > 
> > [snip code]
> 
> This will do what you want:
> 
> #!/usr/bin/perl
> use strict;
> use diagnostics;
> 
> while ( <> ) {
>  my $line_num = $.;
>  if ( /\\\s*$/ ) {
>  my $line_before;
>  if ( ( $line_before = <> ) =~ /^\s*$/ ) {
>  print "$ARGV has a backslash continuation to a following blank line at 
> line $line_num\n";
>  }
>  else {
>  $_ = $line_before;
>  redo;
>  }
>  }
>  }
> 
> __END__
> 
> 
> 
> John
> -- 
> use Perl;
> program
> fulfillment


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




how do I handle filenames that have parens?

2004-08-13 Thread Ken Wolcott
Hi;

I have two perl scripts.  Once calls the other via a ClearCase setview
context (like a subshell).


The problem:
The current scripts do not handle filenames that have parens properly
and the parens are obviously mishandled by the shell.


The overall goal:
What I'm really trying to do is to generate a list of all flat files
and/or symlinks that are part of a specified ClearCase label so that I
can generate a tarball composed of those files/symlinks.  This should be
a trivial exercise, but Rational/IBM has made it more challenging than
it needs to be, but that is a topic for another mailing list :-(


example filenames that are problematic:
/very_long_path/lang/menu_chinese(taiwan)_taiwan.950.vim
/very_long_path/lang/menu_chinese(gb)_gb.936.vim


The error message:
sh: -c: line 1: syntax error near unexpected token `('
sh: -c: line 1: `/usr/atria/bin/cleartool describe \
/very_long_path/lang/menu_chinese(taiwan)_taiwan.950.vim | \
/bin/grep specified_label'
sh: -c: line 1: syntax error near unexpected token `('
sh: -c: line 1: `/usr/atria/bin/cleartool describe \
/very_long_path/lang/menu_chinese(gb)_gb.936.vim | \
/bin/grep specified_label'


The scripts:

try10.pl:
***
#!/usr/bin/perl

use strict;
use warnings;
use diagnostics;

my $cmd;
my $date = "/bin/date";
my $label = "specified_label";
my $ct = "/usr/atria/bin/cleartool";
my $dts = `$date +%Y%m%d_%H%M%S`;
chomp $dts;

my $view = "kwolcott.etram.test_view_" . $dts;
$cmd = $ct . " mkview -tag " . $view . " /opt/views/." . $view . ".vws";
print $cmd . "\n";
system ($cmd);
my $cfg_spec = "/tmp/cfg_spec_" . $dts;
open (CFG_SPEC, ">" . $cfg_spec) or die "ERROR: Unable to open " \
. $cfg_spec . " for writing, $!";
print CFG_SPEC "element * " . $label . "\n";
print CFG_SPEC "element * main/LATEST\n";
close (CFG_SPEC);
$cmd = $ct . " setcs -tag " . $view . " " . $cfg_spec;
print $cmd . "\n";
system ($cmd);
$cmd = $ct . " catcs -tag " . $view;
print $cmd . "\n";
system ($cmd);
$cmd = $ct . " setview -exec ~/ct_find_stuff/try10_body.pl " . $view;
print "\nThis may take quite some time...\n";
print $cmd . "\n";
system ($cmd);
print "\nDone\n";
***

try10_body.pl
**
#!/usr/bin/perl

use strict;
use warnings;
use diagnostics;

my $count;
my $date = "/bin/date";
my $dts = `$date +%Y%m%d_%H%M%S`;
chomp $dts;
my $grep = "/bin/grep";
my $label = "specified_label";
my $ct = "/usr/atria/bin/cleartool";
my $log = "/tmp/try10_" . $dts . ".log";
my $tarball_input_file = "/tmp/tarball_input_file_" . $dts;
my $unassociated = "/tmp/unassociated_" . $dts . ".log";
my $error_log = "/tmp/error_log_" . $dts . ".log";
my $cmd = $ct . " find -avobs -nxname -visible -follow -version \
lbtype_sub'(" . $label . ")' -print";
print $cmd . "\n";
open (LOG, ">" . $log) or die "ERROR: Unable to open " . $log . " for \
writing, $!";
open (ERRORS, ">" . $error_log) or die "ERROR: Unable to open " . \
$error_log . " for writing, $!";
open (TARBALL_INPUT_FILE, ">" . $tarball_input_file) or die "ERROR: \
Unable to open " . $tarball_input_file . " for writing, $!";
open (UNASSOCIATED, ">" . $unassociated) or die "ERROR: Unable to \
open " . $unassociated . " for writing, $!";
open (PIPE, $cmd . " 2>&1 |") or die "ERROR: Unable to execute " . \
$cmd  . " via a command pipe, $!";
while (my $line = ) {
$count++;
print "." unless ($count % 100);
chomp $line;
print LOG $line . "\n";
if ($line =~ m/ /) {
print ERRORS $line . "\n";
} else {
my $results = `$ct describe $line | $grep $label`;
if ($results =~ m/$label/) {
print TARBALL_INPUT_FILE $line . "\n";
} else {
print UNASSOCIATED $line . "\n";
}
}
}
print "\n";
close (PIPE);
close (LOG);
close (ERRORS);
close (TARBALL_INPUT_FILE);
close (UNASSOCIATED);
**



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




Re: how do I handle filenames that have parens?

2004-08-17 Thread Ken Wolcott
Randal;

  Thanks for answer I really needed to hear.

Ken

On Fri, 2004-08-13 at 18:36, Randal L. Schwartz wrote:
> >>>>> "Luke" == Luke Bakken <[EMAIL PROTECTED]> writes:
> 
> Luke> The simple solution is to be sure that single quotes are around the
> Luke> strings passed to the "describe" command:
> 
> >> my $results = `$ct describe '$line' | $grep $label`;
> 
> And of course fails if you have filenaems that have single quotes.
> 
> The *proper* solution is to not involve a shell.  See multi-arg
> pipe-open and multi-arg exec.
> 
> -- 
> 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!
-- 
Kenneth A. Wolcott
Consultant, Acquisition Systems - Clinical Systems Engineering
GE Healthcare Information Technologies
8200 West Tower Avenue, Milwaukee, WI 53223
TWR-2-00-195 (pillar F-3)
Phone:  414/362-2720
Email:  [EMAIL PROTECTED]


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




setting data in arays from a file

2003-11-12 Thread Ken Cole
Hi ALL,

I have GDGraph installed and is working well on a RH 7.3 box.

Now what I need to do is write some perl code to read in some data from a file that 
gets stored in arrays like this is hardwired.

$data = ([
["1st","2nd","3rd","4th","5th","6th","7th", "8th", "9th"],
[1,2,5,6,3,  1.5,   -1,-3,-4],
[   -4,   -3,1,1,   -3, -1.5,   -2,-1, 0],
[9,8,9,  8.4,  7.1,  7.5,8, 3,-3],
[  0.1,  0.0, -0.3, -0.4,  0.1,  0.5,  0.1, 0,   0.4],
]);   

The first line is the X axis labels and the others are data for a line graph that has 
four lines on it.  My final will have 3 lines to graph.

Can anyone help please.

Ken

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



RE: setting data in arays from a file

2003-11-13 Thread Ken Cole
Cool,

Thanks very much.

Ken

> -Original Message-
> From: Ramprasad A Padmanabhan [mailto:[EMAIL PROTECTED]
> Sent: Thursday, 13 November 2003 5:45 PM
> To: Ken Cole
> Cc: [EMAIL PROTECTED]
> Subject: Re: setting data in arays from a file
> 
> 
> Ken Cole wrote:
> > Hi ALL,
> > 
> > I have GDGraph installed and is working well on a RH 7.3 box.
> > 
> > Now what I need to do is write some perl code to read in 
> some data from a file that gets stored in arrays like this is 
> hardwired.
> > 
> > $data = ([
> > ["1st","2nd","3rd","4th","5th","6th","7th", "8th", "9th"],
> > [1,2,5,6,3,  1.5,   -1,-3,-4],
> > [   -4,   -3,1,1,   -3, -1.5,   -2,-1, 0],
> > [9,8,9,  8.4,  7.1,  7.5,8, 3,-3],
> > [  0.1,  0.0, -0.3, -0.4,  0.1,  0.5,  0.1, 0,   0.4],
> > ]);   
> > 
> > The first line is the X axis labels and the others are data 
> for a line graph that has four lines on it.  My final will 
> have 3 lines to graph.
> > 
> > Can anyone help please.
> > 
> > Ken
> 
> Assume You have the data in CSV ( comma sepeated values )
>file called $FILE
> 
> use Tie::CSV_File;
> tie my @data, 'Tie::CSV_File',"$FILE";
> 
> # Now @data conatins the data in exactly the same format as u require
> 
> Thats it , So simple
> Ram
> 
> 
> 
> 
> 
> 
> 
> NETCORE SOLUTIONS *** Ph: +91 22 5662 8000 Fax: +91 22 5662 8134
> 
> MailServ and FlexiMail: Messaging Solutions: http://netcore.co.in
> 
> Pragatee: Integrated Server-Software Suite: http://www.pragatee.com
> 
> Emergic Freedom: Server-centric Computing: http://www.emergic.com
> 
> BlogStreet: Blog Profiles and RSS Ecosystem: http://blogstreet.com
> 
> Deeshaa: Rural Development: http://www.deeshaa.com
> 
> Rajesh Jain's Weblog on Technology: http://www.emergic.org
> 
> 
> 
> 

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



Can I set '$!' ?

2003-12-16 Thread Ken Lehman
I want to be able to return a true or false value from a function in a
module and populate the $! variable with the specific errors. Is this
possible? Is there documentation on how to do this? I can find docs on how
to use $! but not how to set it. Thanks for any help
-Ken




The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.



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




RE: use unix commands

2002-02-20 Thread Ken Clark

This is easy to manipulate, though as time has went by I've found that
perl already can do what i try to do by using system commands. here's a
quick example with backticks, though it is not the only way, or correct
one dependent on your need.

this would require fortune to be in your path ahead of time. that can
easily be added...

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

my $fortune = `fortune`;

print "$fortune \n";

# ken
_
http://quantifier.org/ken GnuPG: 7C828670
location:  33:54:5.879N 83:19:16.824W
 12:05:01 up 21:06,  4 users
Questionable day.

Ask somebody something.

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




  1   2   3   4   5   >