Re: COMPLEX ARRAY STRUCTURE

2004-08-10 Thread Ramprasad A Padmanabhan
Luis Daniel Lucio Quiroz wrote:
You are wrong,
I need some more flexible, 

I dont know what attributes will be added, that's why I need array be coded on 
fly,with somthin like this

$result = $ldap-add( 'cn=Barbara Jensen, o=University of Michigan,
c=US', attr =$attrs);
so $attrs array is formed on user commands
:-P
LD
 

Luis, You still dont have to access the object directly. 
if $attrs is an object created from the users input , so be it.

#Create a hash array of all user inputs. say
%hash = get_user_input();
# Have an array of all possible optional fields like
@ALL_FIELDS =  qw ( mail l ou o .) ;
# Create your attrs array
$attrs = {};
foreach (@ALL_FIELDS ) {
  if($hash{$_}) {
   $$attrs{$_}  = $hash{$_};   # Just make sure your input is trimmed 
for leading spaces  and lagging spaces or remove them here
 }
}

# Now  add this to your ldap entries
$result = $ldap-add( $dn, attr =$attrs);
IMHO that is simpler than poking at the structure and neater
HTH
Ram

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



Re: Net::FTP Help !

2004-08-10 Thread Kelvin Wu
my @raw_list = $ftp-dir($remote_dir);
my @files;
for (@raw_list) {
  # Skip directory and symblink
  next if $_ =~ /^d|^l/;

  # Store file name
  if ($_ =~ /(.+)(\d\d:\d\d) (.+)/) {
next if ($2 eq '.' or $2 eq '..');
push @files, $2;
  }
}


On Mon, 9 Aug 2004 19:38:19 -0600, Wiggins d Anconia
[EMAIL PROTECTED] wrote:
 
  Hi Guys and Gals ,
 
   I'm new to perl ... Here is my problem ..
 
  I'm connecting fine to the remote computer and logging in fine .. what I
  want to do is  a get all files from the remote directory . Here is is a
  snippet of the code
 
  $ftp-cwd($remote_dir)
  or die cannot change working directory , $ftp-message;
 
  # show current directory
  $ftp-pwd();
 
 
  @all_files = $ftp-ls();
 
  print @all_files;
 
 
  foreach $file(@all_files) {
 
  $ftp-get($file)
  or die cannot get file, $ftp-message;
  }
 
 
 
  The problem is that the remote directory has a subdirectory in it so the
  array reads it in @all_files = $ftp-ls; so when I go to do a
  $ftp-get($file) it reads the subdirectory name into it as well so it
  bombs out saying it cannot find file BLAH BLAH ... is there a way to
  read the directory without the subdirectory in there .. just the files I
  want to get .
 
 
 
  Hope this is clear ..
 
 
 
 You can use the 'dir' method to get a long listing, which should include
 the permissions string. Then you can step through the list and pull only
 those files that don't start with a 'd'.  This requires more parsing and
 is less precise but is the only way I know to do it. I thought someone
 was writing an extension that did this automatically but don't know if
 it has made its way to CPAN.
 
 http://danconia.org
 
 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/ http://learn.perl.org/first-response
 


-- 
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 Size Calculator

2004-08-10 Thread SilverFox
Jose Alves De Castro wrote:

 On Mon, 2004-08-09 at 14:53, David Dorward wrote:
 On 9 Aug 2004, at 14:34, SilverFox wrote:
 
  Hi all, I'm trying to writing a script that will allow a user to enter
  a
  number and that number will be converted into KB,MB or GB depending on
  the
  size of the number. Can someone point me in the right direction?
 
 What have you got so far? Where are you stuck? Getting user input
 (where from)? Working out which order of magnitude the number is?
 
 I wouldn't do that (the part of finding the order of magnitude)... I
 would probably keep on doing calculations while the numbers was greater
 then 1024... and in the end, when it was, the right letter to append
 would be based on the amount of calculations done...
 
 I remember reading something about this on use.Perl ... it was a while
 ago, and I'm not sure whether it ever got into a module, but the guy had
 written some wonderful code to do this :-)
 
 Converting between kilo and mega et al? Showing the output?
 
 Show us some code.
 
 --
 David Dorward
   http://dorward.me.uk/
 http://blog.dorward.me.uk/

I haven't put anything together as yet. Putting some if/elsif statement 
together would be the easies way I can think off. Something like:

$kilo= 1024;
$Mega= 1048576;
$gig= 1073741824;

print Please enter your number:\n;
chomp($num=STDIN);

if ($num = $gig) 
{
need code to do the convertion/rounding of given number
print you entered: $num\n;
print which is:
} elsif {
continue with the same format

}

The problem i'm having it converting/rounding the inputted number into a 
valid byte (KB/MB/GB) count.

SilverFox

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




RE: regex problem

2004-08-10 Thread DBSMITH
cool thanks I guess I am a wanna be programmer but do UNIX in real 
life.
So Data::Dumper shows me a structure of any scaler?  Could you show me an 
example?

thank you, 

Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams






Charles K. Clarkson [EMAIL PROTECTED]
08/09/2004 06:31 PM

 
To: [EMAIL PROTECTED]
cc: [EMAIL PROTECTED]
Subject:RE: regex problem


[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote:

: it is a system app call that populates the
: $EDM_nonactive_tapelist I am not sure what you mean
: I'm not sure. has the Orig strings in it is not a
: precise statement for a computer programmer.


I meant that has the Orig strings in it does not
tell us how the strings are represented. It does not
precisely define how the data is structured.


That statement does not accurately describe the
data. Here are two examples of strings listed in a
scalar. In both cases I could describe each of these
examples as a scalar variable with strings in it.

$baz = [
[ 'foo' ],
[ 'bar' ],
];

$baz = foo\nbar\n;

As computer programmers, we have to describe
data precisely. If you are uncertain how to describe
a structure try printing it with DATA::Dumper.


: the foreach with the split did work!

Great. I'm glad I could help.


HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328





checking all pieces of split data for NULL

2004-08-10 Thread Tim McGeary
I have a file of data that I want to safety check to ensure that there 
is data for each piece of the line being split.  Is there a fast way to 
say If any of these are '' then write to error log?

Thanks,
Tim
--
Tim McGeary
Senior Library Systems Specialist
Lehigh University
610-758-4998
[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



Re: File Size Calculator

2004-08-10 Thread mgoland
Quickest wya would be to get the left over from begining.

...

print Please enter your number:\n;
chomp($num=STDIN);

$bytes = $num % $kilo;
$num -= $bytes

...
HTH,
Mark G.

- Original Message -
From: SilverFox [EMAIL PROTECTED]
Date: Monday, August 9, 2004 12:06 pm
Subject: Re: File Size Calculator

 Jose Alves De Castro wrote:
 
  On Mon, 2004-08-09 at 14:53, David Dorward wrote:
  On 9 Aug 2004, at 14:34, SilverFox wrote:
  
   Hi all, I'm trying to writing a script that will allow a user 
 to enter
   a
   number and that number will be converted into KB,MB or GB 
 depending on
   the
   size of the number. Can someone point me in the right direction?
  
  What have you got so far? Where are you stuck? Getting user input
  (where from)? Working out which order of magnitude the number is?
  
  I wouldn't do that (the part of finding the order of 
 magnitude)... I
  would probably keep on doing calculations while the numbers was 
 greater then 1024... and in the end, when it was, the right 
 letter to append
  would be based on the amount of calculations done...
  
  I remember reading something about this on use.Perl ... it was a 
 while ago, and I'm not sure whether it ever got into a module, 
 but the guy had
  written some wonderful code to do this :-)
  
  Converting between kilo and mega et al? Showing the output?
  
  Show us some code.
  
  --
  David Dorward
http://dorward.me.uk/
  http://blog.dorward.me.uk/
 
 I haven't put anything together as yet. Putting some if/elsif 
 statement 
 together would be the easies way I can think off. Something like:
 
 $kilo= 1024;
 $Mega= 1048576;
 $gig= 1073741824;
 
 print Please enter your number:\n;
 chomp($num=STDIN);
 
 if ($num = $gig) 
 {
need code to do the convertion/rounding of given number
print you entered: $num\n;
print which is:
 } elsif {
 continue with the same format
 
 }
 
 The problem i'm having it converting/rounding the inputted number 
 into a 
 valid byte (KB/MB/GB) count.
 
 SilverFox
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/ http://learn.perl.org/first-response
 
 
 


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




Re: checking all pieces of split data for NULL

2004-08-10 Thread Tim McGeary
Jeff 'japhy' Pinyan wrote:
On Aug 10, Tim McGeary said:

follow-up question:  will this only be true if $item of @array is
completely empty?  This is the type of data for each $item of @array:
ID, name_f, name_l, email, id, contact, group, member
I am splitting this by commas into different $scalers to manipulate.
And I know that same of these fields are empty (to which I need to
report back to the people sending me the data).  It will NEVER happen
that a whole line is empty, but just one or two of the fields in each line.

I don't see how this changes things, really.  This is how I would do
things:
  my @field_names = qw( ID name_f name_l email id contact group member );
  my %long_names;
  @[EMAIL PROTECTED] = (
'ID', 'First Name', 'Last Name',
'Email Address', 'id', 'Contact', 'Group', 'Member',
  );
  while (INPUT) {
chomp;
my %record;
@[EMAIL PROTECTED] = split /,/;
if (my @empty = grep length $record{$_} == 0, @field_names) {
  empty_fields(@empty);
}
else {
  # process record
}
  }
Where the empty_fields() function would do something like:
  sub empty_fields {
my $msg = You left these fields empty: ;
$msg .= join , , @[EMAIL PROTECTED];
# displays $msg to the user somehow
  }
This makes my output unordered and extraneous.  I don't want to 
field_names to output, so I don't think a hash works for this.  But in 
its essense, it is what I need to do.  I just need to keep the 
field_names from outputting, too.  Just the data, in the same order I 
bring it in.

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



RE: Net::FTP Help !

2004-08-10 Thread Chris Federico
Thanks Kelvin  /Wiggins ..


Kelvin when you say next if $_ =~ /^d|^l/; are you pattern mattching
here ? Being new to this it seems confusing to me also:

 if ($_ =~ /(.+)(\d\d:\d\d) (.+)/) {
next if ($2 eq '.' or $2 eq '..');
push @files, $2;

In terms I can understand what is this doing ..


Thanks 

Chris


-Original Message-
From: Kelvin Wu [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 09, 2004 10:44 PM
To: [EMAIL PROTECTED]
Subject: Re: Net::FTP Help !

my @raw_list = $ftp-dir($remote_dir);
my @files;
for (@raw_list) {
  # Skip directory and symblink
  next if $_ =~ /^d|^l/;

  # Store file name
  if ($_ =~ /(.+)(\d\d:\d\d) (.+)/) {
next if ($2 eq '.' or $2 eq '..');
push @files, $2;
  }
}


On Mon, 9 Aug 2004 19:38:19 -0600, Wiggins d Anconia
[EMAIL PROTECTED] wrote:
 
  Hi Guys and Gals ,
 
   I'm new to perl ... Here is my problem ..
 
  I'm connecting fine to the remote computer and logging in fine .. 
  what I want to do is  a get all files from the remote directory . 
  Here is is a snippet of the code
 
  $ftp-cwd($remote_dir)
  or die cannot change working directory , $ftp-message;
 
  # show current directory
  $ftp-pwd();
 
 
  @all_files = $ftp-ls();
 
  print @all_files;
 
 
  foreach $file(@all_files) {
 
  $ftp-get($file)
  or die cannot get file, $ftp-message; }
 
 
 
  The problem is that the remote directory has a subdirectory in it so
the
  array reads it in @all_files = $ftp-ls; so when I go to do a
  $ftp-get($file) it reads the subdirectory name into it as well so
it
  bombs out saying it cannot find file BLAH BLAH ... is there a way to
  read the directory without the subdirectory in there .. just the
files I
  want to get .
 
 
 
  Hope this is clear ..
 
 
 
 You can use the 'dir' method to get a long listing, which should
include
 the permissions string. Then you can step through the list and pull
only
 those files that don't start with a 'd'.  This requires more parsing
and
 is less precise but is the only way I know to do it. I thought someone
 was writing an extension that did this automatically but don't know if
 it has made its way to CPAN.
 
 http://danconia.org
 
 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/ http://learn.perl.org/first-response
 


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





-
Visit our Internet site at http://www.reuters.com

Get closer to the financial markets with Reuters Messaging - for more
information and to register, visit http://www.reuters.com/messaging

Any views expressed in this message are those of  the  individual
sender,  except  where  the sender specifically states them to be
the views of Reuters Ltd.


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




Re: checking all pieces of split data for NULL

2004-08-10 Thread Jeff 'japhy' Pinyan
On Aug 10, Tim McGeary said:

follow-up question:  will this only be true if $item of @array is
completely empty?  This is the type of data for each $item of @array:

ID, name_f, name_l, email, id, contact, group, member

I am splitting this by commas into different $scalers to manipulate.
And I know that same of these fields are empty (to which I need to
report back to the people sending me the data).  It will NEVER happen
that a whole line is empty, but just one or two of the fields in each line.

I don't see how this changes things, really.  This is how I would do
things:

  my @field_names = qw( ID name_f name_l email id contact group member );
  my %long_names;
  @[EMAIL PROTECTED] = (
'ID', 'First Name', 'Last Name',
'Email Address', 'id', 'Contact', 'Group', 'Member',
  );

  while (INPUT) {
chomp;
my %record;
@[EMAIL PROTECTED] = split /,/;
if (my @empty = grep length $record{$_} == 0, @field_names) {
  empty_fields(@empty);
}
else {
  # process record
}
  }

Where the empty_fields() function would do something like:

  sub empty_fields {
my $msg = You left these fields empty: ;
$msg .= join , , @[EMAIL PROTECTED];
# displays $msg to the user somehow
  }

-- 
Jeff japhy Pinyan %  How can we ever be the sold short or
RPI Acacia Brother #734 %  the cheated, we who for every service
http://japhy.perlmonk.org/  %  have long ago been overpaid?
http://www.perlmonks.org/   %-- Meister Eckhart


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




Re: checking all pieces of split data for NULL

2004-08-10 Thread Jose Alves de Castro
On Tue, 2004-08-10 at 15:01, Tim McGeary wrote:
 I have a file of data that I want to safety check to ensure that there 
 is data for each piece of the line being split.  Is there a fast way to 
 say If any of these are '' then write to error log?

Let's say you have your line split in @line

if (grep /^$/, @line) {

  # then one of them is null

}

 Thanks,
 Tim

HTH,

jac

 -- 
 Tim McGeary
 Senior Library Systems Specialist
 Lehigh University
 610-758-4998
 [EMAIL PROTECTED]
-- 
José Alves de Castro [EMAIL PROTECTED]
  http://natura.di.uminho.pt/~jac


signature.asc
Description: This is a digitally signed message part


Re: checking all pieces of split data for NULL

2004-08-10 Thread Wiggins d Anconia
 I have a file of data that I want to safety check to ensure that there 
 is data for each piece of the line being split.  Is there a fast way to 
 say If any of these are '' then write to error log?
 
 Thanks,
 Tim
 

Do you mean something like?

foreach my $piece (split /\|/, $line) {
   if ($piece eq '') {
   print ERRORLOG Empty value;
   }
}
(Assumes split on '|' but doesn't have to)

Obviously this is not terribly useful as it doesn't tell you what was
empty, but there are lots of ways around that, obviously you will need
to know the column headings.

Does this help?  If not you might provide more information specifically
about what you are up to.

http://danconia.org

-- 
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 Size Calculator

2004-08-10 Thread Brian Gerard
And the clouds parted, and SilverFox said...

 Hi all, I'm trying to writing a script that will allow a user to enter a 
 number and that number will be converted into KB,MB or GB depending on the 
 size of the number. Can someone point me in the right direction?
 
 Example: 
 user enter: 59443
 Script will output: 58M
 
 SilverFox
 

Here's a little chunk that should give you about what you're looking
for, up to Tebibytes (2**40 bytes).  Note that I used the binary
prefixes[1] (Kibi, Mebi, Gibi, Tebi) as opposed to the base-10 versions
(Kilo, Mega, Giga, Tera).  Feel free to change them if you're so
inclined.  :)

--- Begin Chunk ---

our %ByteCount = (
  B = 1,
KiB = 2**10,
MiB = 2**20,
GiB = 2**30,
TiB = 2**40
);


sub prettybyte {
my $bytes = shift;

foreach my $unit ( qw{ TiB GiB MiB KiB B } ) {
if ($bytes = $ByteCount{$unit}) {
return sprintf(%4.3f $unit, $bytes/$ByteCount{$unit});
}
}
}

--- End Chunk ---

HTH[2]-
Brian

[1] http://www.alcyone.com/max/reference/physics/binary.html
-anyone remember offhand the URL to the /. story on these, btw?

[2] I'm a little rushed at the moment, so I don't have time to fill
in any details of how it works.  Let me know if you want/need an
explanation and I'll be happy to provide one.  :)


  /~~\
 | Brian Gerard  Some drink at the fountain of|
 | First initial + 'lists'  knowledge...others just gargle.   |
 | at technobrat dot com  |
  \__/

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




RE: checking all pieces of split data for NULL

2004-08-10 Thread Moon, John
-Original Message-
From: Tim McGeary [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 10, 2004 10:01 AM
To: [EMAIL PROTECTED]
Subject: checking all pieces of split data for NULL

I have a file of data that I want to safety check to ensure that there 
is data for each piece of the line being split.  Is there a fast way to 
say If any of these are '' then write to error log?

Thanks,
Tim


Assuming the you wish to split on a comma 
then:

print Bad data $data\n if $data =~ /,\s*,/ || $d =~ /,\s*$/;

hope this gives you some ideas...

jwm

-- 
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 Size Calculator

2004-08-10 Thread Charles K. Clarkson
SilverFox [EMAIL PROTECTED] wrote:

: 
: I haven't put anything together as yet. Putting
: some if/elsif statement together would be the
: easiest way I can think off. Something like:


We can see a few problems right off. All scripts
should start with 'strict' and 'warnings'. We need a
consistent naming convention for variables. If some
start with capitalized letters, there should be a
non-arbitrary reason for doing so.

: $kilo= 1024;
: $Mega= 1048576;
: $gig= 1073741824;


use strict;
use warnings;

my $kilobyte = 1024;
my $megabyte = 1024 ** 2;
my $gigabyte = 1024 ** 3;

 
: print Please enter your number:\n;
: chomp($num=STDIN);

chomp( my $value = STDIN );

: if ($num = $gig)
: {
: need code to do the convertion/rounding
: of given number print you entered:
: $num\n; print which is:
: } elsif {
: continue with the same format
: 
: }
: 
: The problem i'm having it converting/rounding the
: inputted number into a valid byte (KB/MB/GB) count.

I suppose that takes some basic math. To round
to a whole number, we examine the fraction to
determine whether we should adjust the whole number
up or down. It is important to separate the number
from the fraction.

   Luckily, Math::Round has the nearest() function.
To find the nearest number of units, we use this.

nearest( $unit, $number ) / $unit


Here's one solution. It's very generic. One
could easily adopt it for miles, yards, and feet
given a value in feet. I leave error checking to
you.


use strict;
use warnings;

use Math::Round 'nearest';

print Please enter your number:\n;
chomp( my $value = STDIN );

my %units = (
1024  = 'KB',
1024 ** 2 = 'MB',
1024 ** 3 = 'GB',
);

foreach my $unit ( sort {$b = $a} keys %units ) {
if ( $value = $unit ) {
printf %s = %s %s\n,
$value,
nearest( $unit, $value ) / $unit,
$units{ $unit };
last;
}
}

__END__


We still need to handle values smaller than
1024, but this solution might make that easier
to do. It won't handle non-positive values, though.


my %units = (
1024 ** 0 = 'Bytes',
1024 ** 1 = 'KB',
1024 ** 2 = 'MB',
1024 ** 3 = 'GB',
);


HTH,

Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328












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




Re: checking all pieces of split data for NULL

2004-08-10 Thread JupiterHost.Net

Tim McGeary wrote:
I have a file of data that I want to safety check to ensure that there 
is data for each piece of the line being split.  Is there a fast way to 
say If any of these are '' then write to error log?
How about this:
for(@lines) {
  chomp;
  print ERRLOG 'Blank line' if $_ eq '';
  # where ERRLOG is a previously opened file handle
  # you could do if !$_; but that would also match '0'
}
HTH :)
Lee.M - JupiterHost.Net
Thanks,
Tim
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: checking all pieces of split data for NULL

2004-08-10 Thread Tim McGeary
this didn't go through the first time...  resending...
Jeff 'japhy' Pinyan wrote:
On Aug 10, Tim McGeary said:

I have a file of data that I want to safety check to ensure that there
is data for each piece of the line being split.  Is there a fast way to
say If any of these are '' then write to error log?

Assuming you store the data in an array, you can simply say:
  if (grep length == 0, @data_members) {
print LOG error: empty fields found in this dataset\n;
  }
Something to that effect should work.
follow-up question:  will this only be true if $item of @array is
completely empty?  This is the type of data for each $item of @array:
ID, name_f, name_l, email, id, contact, group, member
I am splitting this by commas into different $scalers to manipulate.
And I know that same of these fields are empty (to which I need to
report back to the people sending me the data).  It will NEVER happen
that a whole line is empty, but just one or two of the fields in each line.
Does that change the scope of this suggestion?


--
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 Size Calculator

2004-08-10 Thread Brian Gerard
And the clouds parted, and Brian Gerard said...
 
 [1] http://www.alcyone.com/max/reference/physics/binary.html
   -anyone remember offhand the URL to the /. story on these, btw?
 

...never mind.  Found it.  (uncaught typo on my first google query... DOH!)

http://slashdot.org/articles/99/08/10/0259245.shtml


  /~~\
 | Brian Gerard  Give me liberty or give me something |
 | First initial + 'lists' of equal or lesser value   |
 | at technobrat dot com   from your glossy 32-page catalog.  |
  \__/

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




Re: checking all pieces of split data for NULL

2004-08-10 Thread Tim McGeary
Tim McGeary
Senior Library Systems Specialist
Lehigh University
610-758-4998
[EMAIL PROTECTED]

Jeff 'japhy' Pinyan wrote:
On Aug 10, Tim McGeary said:

follow-up question:  will this only be true if $item of @array is
completely empty?  This is the type of data for each $item of @array:
ID, name_f, name_l, email, id, contact, group, member
I am splitting this by commas into different $scalers to manipulate.
And I know that same of these fields are empty (to which I need to
report back to the people sending me the data).  It will NEVER happen
that a whole line is empty, but just one or two of the fields in each line.

I don't see how this changes things, really.  This is how I would do
things:
  my @field_names = qw( ID name_f name_l email id contact group member );
  my %long_names;
  @[EMAIL PROTECTED] = (
'ID', 'First Name', 'Last Name',
'Email Address', 'id', 'Contact', 'Group', 'Member',
  );
  while (INPUT) {
chomp;
my %record;
@[EMAIL PROTECTED] = split /,/;
if (my @empty = grep length $record{$_} == 0, @field_names) {
  empty_fields(@empty);
}
else {
  # process record
}
  }
Where the empty_fields() function would do something like:
  sub empty_fields {
my $msg = You left these fields empty: ;
$msg .= join , , @[EMAIL PROTECTED];
# displays $msg to the user somehow
  }

since I have this already:
foreach $item (@banner_array) {
my ($patron_id, $name_f, $name_l, $email, $disc_id, $contact,
$pwd, $un, $group, $code) = split(/,/,$item);
can I just simply do:
if ($patron_id | $name_f | $name_l | ... eq '') {
send to error log
???
| = OR, but maybe I'm not correct with that.
Tim

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



RE: checking all pieces of split data for NULL

2004-08-10 Thread Bob Showalter
Tim McGeary wrote:
 I have a file of data that I want to safety check to ensure that there
 is data for each piece of the line being split.  Is there a fast way
 to say If any of these are '' then write to error log?

   die One or more fields is zero length\n if grep !length, @fields;

   die One or more fields is all whitespace\n if grep $_ !~ /\S/, @fields;

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




Re: checking all pieces of split data for NULL

2004-08-10 Thread Tim McGeary

Jeff 'japhy' Pinyan wrote:
On Aug 10, Tim McGeary said:

I have a file of data that I want to safety check to ensure that there
is data for each piece of the line being split.  Is there a fast way to
say If any of these are '' then write to error log?

Assuming you store the data in an array, you can simply say:
  if (grep length == 0, @data_members) {
print LOG error: empty fields found in this dataset\n;
  }
Something to that effect should work.
Yes, they are indeed in an array.  Excellent.  I'll try this out.  Thank 
you.

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



Checking if URL is on a list.

2004-08-10 Thread Jimstone77
I know there is a much simpler way to do this. What this does is check a URL 
written with and without www.  or trailing / against a list of urls that (one 
at a time) are placed in $siteurl2. 

$FORM{'siteurl'} is the site url being submitted.
$alternativeurl is $FORM{'siteurl'} without the www. if with.
$xalternatives is $FORM{'siteurl'} with the www. if without.

This works ok it seems, but it's horrible code. There must be a better way to 
write this. Any help will be appreciated.

  if (($FORM{'siteurl'} =~ /$siteurl2$/) || ($FORM{'siteurl'} =~ 
/$siteurl2\/$/) || ($alternativeurl =~ /$siteurl2$/) || ($alternativeurl =~ 
/$siteurl2\/$/) || ($xalternatives =~ /$siteurl2$/) || ($xalternatives =~ 
/$siteurl2\/$/)) {
  print Found 1 \n;
  }


Re: checking all pieces of split data for NULL

2004-08-10 Thread Jeff 'japhy' Pinyan
On Aug 10, Tim McGeary said:

I have a file of data that I want to safety check to ensure that there
is data for each piece of the line being split.  Is there a fast way to
say If any of these are '' then write to error log?

Assuming you store the data in an array, you can simply say:

  if (grep length == 0, @data_members) {
print LOG error: empty fields found in this dataset\n;
  }

Something to that effect should work.

-- 
Jeff japhy Pinyan %  How can we ever be the sold short or
RPI Acacia Brother #734 %  the cheated, we who for every service
http://japhy.perlmonk.org/  %  have long ago been overpaid?
http://www.perlmonks.org/   %-- Meister Eckhart


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




Web Application with PERL or ASP.NET

2004-08-10 Thread Joe Echavarria
Hi there,

  The company i work is considering two tools for the
web version of a loan system.  I need to prove that
perl is better that ASP.NET for the project. Can
anyone help me ?, is posible with perl have controls
?, data grids ?, date controls ?, the way that asp.net
works ?, why perl is better ?, give examples of robust
web applications writtern in perl , links, examples,
etc. anything that could help me prove that perl is
better for the project. 

  Thanks.



__
Do you Yahoo!?
Yahoo! Mail is new and improved - Check it out!
http://promotions.yahoo.com/new_mail

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




Re: checking all pieces of split data for NULL

2004-08-10 Thread Tim McGeary
Jeff 'japhy' Pinyan wrote:
On Aug 10, Tim McGeary said:

I have a file of data that I want to safety check to ensure that there
is data for each piece of the line being split.  Is there a fast way to
say If any of these are '' then write to error log?

Assuming you store the data in an array, you can simply say:
  if (grep length == 0, @data_members) {
print LOG error: empty fields found in this dataset\n;
  }
Something to that effect should work.
follow-up question:  will this only be true if $item of @array is 
completely empty?  This is the type of data for each $item of @array:

ID, name_f, name_l, email, id, contact, group, member
I am splitting this by commas into different $scalers to manipulate. 
And I know that same of these fields are empty (to which I need to 
report back to the people sending me the data).  It will NEVER happen 
that a whole line is empty, but just one or two of the fields in each line.

Does that change the scope of this suggestion?

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



RE: regex problem

2004-08-10 Thread Chris Devers
On Tue, 10 Aug 2004 [EMAIL PROTECTED] wrote:
So Data::Dumper shows me a structure of any scaler?  Could you show me 
an example?
Data::Dumper is a tool for showing the structure of *any* data.
As is often the case, the perldoc has some of the best documentation:
perldoc Data::Dumper
It starts out with this:
NAME
   Data::Dumper - stringified perl data structures, suitable
   for both printing and eval
SYNOPSIS
   use Data::Dumper;
   # simple procedural interface
   print Dumper($foo, $bar);
   # extended usage with names
   print Data::Dumper-Dump([$foo, $bar], [qw(foo *ary)]);
   # configuration variables
   {
 local $Data::Dumper::Purity = 1;
 eval Data::Dumper-Dump([$foo, $bar], [qw(foo *ary)]);
   }
   # OO usage
   $d = Data::Dumper-new([$foo, $bar], [qw(foo *ary)]);
  ...
   print $d-Dump;
  ...
   $d-Purity(1)-Terse(1)-Deepcopy(1);
   eval $d-Dump;
And goes on to describe usage details  more examples.
Good luck with it!

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



Re: checking all pieces of split data for NULL

2004-08-10 Thread Jeff 'japhy' Pinyan
On Aug 10, Tim McGeary said:

  sub empty_fields {
my $msg = You left these fields empty: ;
$msg .= join , , @[EMAIL PROTECTED];
# displays $msg to the user somehow
  }

How do I force that AND not output both parts of the hash since I just
want the values, not the keys.

What do you mean, both parts of the hash?  My empty_fields() function
only displays the long names of the fields.

-- 
Jeff japhy Pinyan %  How can we ever be the sold short or
RPI Acacia Brother #734 %  the cheated, we who for every service
http://japhy.perlmonk.org/  %  have long ago been overpaid?
http://www.perlmonks.org/   %-- Meister Eckhart


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




Re: Checking if URL is on a list.

2004-08-10 Thread Wiggins d Anconia
 
 I know there is a much simpler way to do this. What this does is check
a URL 
 written with and without www.  or trailing / against a list of urls
that (one 
 at a time) are placed in $siteurl2. 
 
 $FORM{'siteurl'} is the site url being submitted.
 $alternativeurl is $FORM{'siteurl'} without the www. if with.
 $xalternatives is $FORM{'siteurl'} with the www. if without.
 
 This works ok it seems, but it's horrible code. There must be a better
way to 
 write this. Any help will be appreciated.
 
   if (($FORM{'siteurl'} =~ /$siteurl2$/) || ($FORM{'siteurl'} =~ 
 /$siteurl2\/$/) || ($alternativeurl =~ /$siteurl2$/) ||
($alternativeurl =~ 
 /$siteurl2\/$/) || ($xalternatives =~ /$siteurl2$/) || ($xalternatives =~ 
 /$siteurl2\/$/)) {
   print Found 1 \n;
   }
 
 

I am not entirely sure I follow but does this do it?

if ($siteurl2 =~ /^(?:www.)?$FORM{'siteurl'}\/?$/) {
   print Matched;
}

Aka optionally 'www.' followed by the submitted URL, with an optional
trailing slash.

If not come back and someone will get you sorted.

http://danconia.org

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




Re: Web Application with PERL or ASP.NET

2004-08-10 Thread JupiterHost.Net

Joe Echavarria wrote:
Hi there,
Hello,
  The company i work is considering two tools for the
web version of a loan system.  I need to prove that
perl is better that ASP.NET for the project. Can
anyone help me ?, is posible with perl have controls
?, data grids ?, date controls ?, the way that asp.net
works ?, why perl is better ?, give examples of robust
web applications writtern in perl , links, examples,
etc. anything that could help me prove that perl is
better for the project. 

One thing clueless management will be likely to pay attention to is cost.
Perl is free and well documented, supported etc. ASP has to run on
expensivly licensed servers and is as unreliable as any other inscure 
windows trash. You'll likely need to reword it so as not to insult any 
ignorant, MS slaved, folks .

Perl is also very very flexible, search.cpan.org has many many modules 
that allow you to easily do many tasks. Like .NET ans SOAP, among 
thousand of other things.

Deveoping in Perl is quickk and easy to learn and lends itself to easy 
maintaining. (Especially if you doo smart thins right from the start, 
like use strict and warnings)

Just my .02 ;p
HTH :)
Lee.M - JupiterHost.Net
  Thanks.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Web Application with PERL or ASP.NET

2004-08-10 Thread Chris Devers
Hi.
On Tue, 10 Aug 2004, Joe Echavarria wrote:
 The company i work is considering two tools for the web version of a 
loan system.  I need to prove that perl is better that ASP.NET for the 
project. Can anyone help me ?
Maybe, with concrete questions of reasonable scope.
is posible with perl have controls ?
What is a control? Is this an ASP term? Please describe what you mean by 
controls -- what functionality are you hoping for here?

data grids ?
You mean like tables /or matrices? Sure, no problem.
date controls ?
In what way[s] are you hoping to control dates? Please clarify this.
the way that asp.net works ?
It probably isn't safe to assume that a list for Perl Beginners isn't 
going to be populated with a lot of people that know a lot about ASP, so 
you should probably clarify what it is about ASP that you would like to 
do with Perl. Chances are that Perl can do most anything ASP can, but 
it's hard to make comparisons when this are this vague :-)

why perl is better ?
This is a subjective issue, so without having a clearer idea about what 
properties of ASP are being considered, it's hard to say how Perl might 
be better. Well, not hard -- impossible.

give examples of robust web applications writtern in perl , links, 
examples, etc.
This is probably what you want:
http://perl.oreilly.com/news/success_stories.html

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



PERL and Mobile Devices.

2004-08-10 Thread Joe Echavarria
Hi there,

  can i write applications with perl for mobile
devices , 



__
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail 

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