RE: Please Help!!! Newbie Question

2005-09-01 Thread Bakken, Luke
Perl wrote:
> Hi List,
> 
> I have this script which actually returns the value of the filename
> with extension but If the file name is something like
> "c:\projects\text 009.txt" (having a space in filename which is
> common in windows). 
> This script only returns "text" instead of returning full name of
> file. Here is the script
> 
>   #!/usr/bin/perl
>   # file: basename.pl
>   use strict;
>   use File::Basename;
>   my $path = $ARGV[0];
>   my $base = basename($path);
>   my $dir  = dirname($path);
>   print STDOUT $base;
> 
> Any help/suggestion will be appreicated.
> 
> Thanks a lot.



You asked this question yesterday and I provided adequate help. Why did
you not go with that? Here is the email:

Perl wrote:
> I am new to perl so I need some help from the list with this script.
> It takes a value from command line and then returns afters processing.
> For example, If value is "c:\projects\test 2005.txt" the script will
> returns it as "test" (actually omitts any space in the directory or
> file name) while I want the full name of the file regardless of any
> space in the directory or filename.
> how can I get the value "test 2005.txt"?
> 
>   #!/usr/bin/perl
>   # file: basename.pl
>   use strict;
>   use File::Basename;
>   my $path = $ARGV[0];
>   my $base = basename($path);
>   my $dir  = dirname($path);
>   print STDOUT $base;
> 
> 
> any help will be greatly appreciated.
> 
> Thanks in advance.


It works for me:

C:\>perl -MFile::Basename -e"print basename q(c:\projects\test
2005.txt)"
test 2005.txt

How are you executing the script? Are you surrounding c:\projects\test
2005.txt with quotes when you call the script? If not, $ARGV[0] will
only contain "c:\projects\test".

Why not put a "print join ':', @ARGV" in your script and you'll see what
I mean.

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




Re: Need help... packages again -more

2005-09-01 Thread Luinrandir
Clark.. thanks for the help, I have to decode (look in my book and figure
out what you wrote) some of the code you wrote.
just wanna says thanks, but its way over my head :)  but look at the seconf
loop! i'm begining to understand how to use
those hidden , double secret invisable vars!-Lou

In the package:

@Countries=("Ireland","Iceland");

$Lord{Ireland}="Ambros:Baird:Cabhan:Dahey:Eirnin:Fergus:Glendan:Hugh:Innis:L
iam:Murtagh:Orin:Pierce:Quinn:Ronan:Scolaighe:Turlach:Luinrandir";

$Lord{Iceland}="Sigurður:Guðmundur:Jón:Gunnar:Ólafur:Magnús:Einar:Kristján:B
jörn:Bjarni";


in the program:

   foreach $Country(@NameList::Countries)
   {
   my @Lords=split (/:/,$NameList::Lord{$Country});
   print qq|1-$Country|;
   print qq|2-$NameList::Lord{$Country}|;
   foreach (@Lords)
   {
  print;
  print qq||;
   }
   }
results in HTML:
-Ireland
2-Ambros:Baird:Cabhan:Dahey:Eirnin:Fergus:Glendan:Hugh:Innis:Liam:Murtagh:Or
in:Pierce:Quinn:Ronan:Scolaighe:Turlach:Luinrandir
Ambros
Baird
Cabhan
Dahey
Eirnin
Fergus
Glendan
Hugh
Innis
Liam
Murtagh
Orin
Pierce
Quinn
Ronan
Scolaighe
Turlach
Luinrandir
1-Iceland
2-Sigurður:Guðmundur:Jón:Gunnar:Ólafur:Magnús:Einar:Kristján:Björn:Bjarni
Sigurður
Guðmundur
Jón
Gunnar
Ólafur
Magnús
Einar
Kristján
Björn
Bjarni

so I finally got it to work...
comments/thoughts?




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




Need help... packages again

2005-09-01 Thread Luinrandir
in the package:
@Countries=("Ireland","Iceland");

$Lord{Ireland}=("Ambros","Baird","Cabhan","Dahey","Eirnin","Fergus","Glendan
","Hugh","Innis",
"Liam","Murtagh","Orin","Pierce","Quinn","Ronan","Scolaighe","Turlach","Luin
randir");

$Lord{Iceland}=("Sigurður","Guðmundur","Jón","Gunnar","Ólafur","Magnús","Ein
ar",
"Kristján","Björn","Bjarni");

in the CGI / web page:

   foreach $Country(@NameList::Countries)
   {
   print qq|1-$Country|;
   print qq|2-$NameList::Lord{$Country}|;
   print qq|3-$NameList::Lord{Ireland}|;
}


on the webpage:

1-Ireland< 




Re: Please Help!!! Newbie Question

2005-09-01 Thread Randy W. Sims

Perl wrote:

Hi List,

I have this script which actually returns the value of the filename with
extension but If the file name is something like "c:\projects\text 009.txt"
(having a space in filename which is common in windows).
This script only returns "text" instead of returning full name of file.


Hi Perl,

Are you quoting the filename on the command line? Most shells split 
arguments on whitespace. In your example $ARGV[0] contains 
"c:\projects\text", and $ARGV[1] contains "009.txt".


Randy.


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




Re: tricky list comparison problem

2005-09-01 Thread Randy W. Sims

Jason Ross wrote:
Anyway, the issue I have is that I need to determine where there are 
gaps between the first sector and last sector (on the entire disk, not 
on a given partition).


So, for example, using the sample data below, I want to return "2097415 
- 69078878" as available sectors.


Hi Jason,

I find the Set::IntSpan module very useful for this type of thing:

#!/usr/bin/perl

use strict;
use warnings;

use Set::IntSpan;

# the last sector on disk
my $end_sect = 71127179;

# The complete range of sectors on the disk
my $range = Set::IntSpan->new( "0-$end_sect" );

# The ranges of used sectors
my $used = Set::IntSpan->new( 
'0-1048706,1048707-2097414,69078879-71127179' );


# Calculates the remaining unused sectors
my $unused = $range->diff( $used );

print $unused->run_list;

__END__


Sample data
I called this file "in".
If you change the name, you'll need to alter the last line of the script
--
* /dev/dsk/c1t0d0s2 partition map
*
* Dimensions:
* 512 bytes/sector
* 107 sectors/track
*  27 tracks/cylinder
*2889 sectors/cylinder
*   24622 cylinders
*   24620 accessible cylinders
*
* Flags:
*   1: unmountable
*  10: read-only
*
*  First SectorLast
* Partition  Tag  FlagsSector CountSector  Mount Directory
   0  2001048707   1048707   2097414   /
   1  301  0   1048707   1048706
   2  500  0  71127180  71127179
   7  800   69078879   2048301  71127179   /export/home



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




Please Help!!! Newbie Question

2005-09-01 Thread Perl
Hi List,

I have this script which actually returns the value of the filename with
extension but If the file name is something like "c:\projects\text 009.txt"
(having a space in filename which is common in windows).
This script only returns "text" instead of returning full name of file.
Here is the script

  #!/usr/bin/perl
  # file: basename.pl
  use strict;
  use File::Basename;
  my $path = $ARGV[0];
  my $base = basename($path);
  my $dir  = dirname($path);
  print STDOUT $base;

Any help/suggestion will be appreicated.

Thanks a lot.



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




Re: utf8::upgrade,utf8::encode and utf8::is_utf8 on EBCDIC platform

2005-09-01 Thread SADAHIRO Tomoyuki
Hello.
I think it is correct.

On EBCDIC platforms, perl uses UTF-EBCDIC instead of UTF-8,
nevertheless perl calls it "utf8."

In general chr(0xFF) (equals to "\xFF") in EBCDIC encodings
corresponds to U+009F, that is a single-octet control character;
thus a single octet sequence "\xFF" is well-form in UTF-EBCDIC too.

If you want to convert an interger to a character according to
Unicode scalar values, you can use pack('U'), but not chr().
For example, pack('U', 0xFF) should correspond to U+00FF
(y with diaeresis), everywhere (both on ASCII and on EBCDIC).

Regards,
SADAHIRO Tomoyuki

> Hi,
> 
>  This are the tetstcase i'm runing on EBCDIC platform,
> 
> my $b = chr(0x0FF);
> $p=utf8::upgrade($b);
> print "\n$p";
> 
> utf8::upgarde returns the number of octets necessary
> to represent the string as UTF-X.
> 
> EBCDIC output is 1 whereas ASCII platform output is 2.
> Is the return value i'm getting on EBCDIC is correct?
> 
> my $c=chr(0x0FF);
> print "before $c\n";
> print "\n";
> utf8::encode($c);
> print "after $c\n";
> print length($c);
> 
> On ASCII before is single octet repsentation and after
> encode is two byte , length is 2.
> 
> On EBCDIC it is single before and after encode and
> length is 1.
> 
> Is this correct on EBCDIC or is it a bug in code for
> EBCDIC ?
> 
> utf::is_utf8 test whether STRING is in UTF-8, so 0x0FF
> is UTF-8 on EBCDIC?




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




Net::SMTP and a hash of arrays

2005-09-01 Thread Ryan Frantz
Perlers,

 

I need to send an email to several different recipients, all at
different mail servers.  I thought that a hash of arrays (my first time)
would do the job nicely, but Net::SMTP complains that I can't "coerce
array into hash".

 

Here's my script (Win32):

 

# hash the recipients -> a hash of arrays!!  woohoo!

my %rcpts = (

  'mail.domain0.com' => [ '[EMAIL PROTECTED]', '[EMAIL PROTECTED]' ],

  'mail.domain1.com' => [ '[EMAIL PROTECTED]' ],

  'mail.domain2.com' => [ '[EMAIL PROTECTED]' ]

);

 

my $send_from = '[EMAIL PROTECTED]';

my $send_to = "Interested Parties"

my $subj = "Something happened...";

my $msg = "...and it's going to cost us...";

 

# test the HoA...

foreach my $server ( keys %rcpts ) {

  #print "$server: @{ $rcpts{$server} } \n";

 

  #my $email = Net::SMTP->new($server, Hello => $site, Debug => 5) or
warn "Unable to create email: $!\n";

  my $email = Net::SMTP->new($informed_smtp_host, Hello => $site) or
warn "Unable to create email: $!\n";

  $email->mail($send_from);

  $email->recipient(@{ rcpts{$server} });

  $email->data();

  $email->datasend("To: $send_to\n");

  $email->datasend("Subject: $subj\n");

  $email->datasend($msg);

  $email->dataend();

  $email->quit;

 

What gives?

 

ry

 

}



Re: tricky list comparison problem

2005-09-01 Thread Jason Ross
heh. i didn't realize i sucked this bad =)


On 9/1/05, John W. Krahn <[EMAIL PROTECTED]> wrote:
> > Anyway, the issue I have is that I need to determine where there are
> > gaps between the first sector and last sector (on the entire disk, not
> > on a given partition).
>
> How do you determine which partitions to skip and which not to skip?

Well, my initial thought was to skip partition 2 entirely (which is
reserved in Solaris as a means to address the entire disk, and would
therefore bork up the calculations). I've since realized that I can't
quite do that, I need to at least check if part2 is the only one
present first. Either way, it won't be part of the calculations
though.

Really, I should check all the partitions and see if the difference
between start and end sectors is == the total number of sectors ...

>
> > use strict();
>
> You are telling perl to load the 'strict' module and then you are telling the
> 'strict' module not to do anything (with the empty parentheses.) Why use the
> module if you don't want it to do anything?

*doh* . thanks.


> > sub get_vtoc($) {
>
> You really, really, *REALLY* shouldn't use "prototypes". If you want to check
> the arguments passed to your subroutine you should do something like this:
>
>  @_ == 1 or die "Wrong number of arguments passed to get_vtoc().\n";
>
>
> "Far More Than Everything You've Ever Wanted to Know about Prototypes in Perl"
> http://library.n0i.net/programming/perl/articles/fm_prototypes/

A very good read, noted and changed.


>
> > # if this is the bytes/sector line, split it
> > # and store the bytes per sector as $BPS
> > if($_ =~ /bytes\/sector/) {
> > our (undef, $BPS, undef) = split(/\s/, $_, 3);
>
> our() is lexically scoped just like my() and the only reason that this
> actually works is because strict is turned off and $BPS is a package variable.
>  To make this work correctly with strict you have to declare $BPS outside of
> the while loop.
>
> If you use split correctly that could be written as:
>
>  $BPS = ( split )[ 1 ];
>
> Then you wouldn't need the substitutions at the beginning of the loop.
>
> However *I* would write it like this:
>
>  if ( /(\d+)\s+bytes\/sector/ ) {
>  $BPS = $1;
>  }

I think this is the best example of regexp backreferencing I've seen.
At last, they make sense to me =)

I've changed this in the real script, and a few other places elsewhere to boot!

> > }
> >
> > # skip the the line if it starts with an * or is partition 2
> > next if(/^[\*|2]/);
>
> Your comment is incorrect, it should read "if it starts with an * or a | or is
> partition 2". Regular expression meta-characters are not special in a
> character class so you probably meant /^[*2]/.

I did indeed mean that. And now that you've got it working the right
way I realize it's totally not what I wanted. I need to leave the 2
out of it, because if partition 2 is the only one defined, I need to
return it. Many thanks for helping me catch this.

>
> > # put the pieces into the slices hash
> > $slices{$part} = {
> > bps => "$BPS",
> > tag => "$tag",
> > flag => "$flag",
> > part => "$part",
> > fsector => "$fsector",
> > lsector => "$lsector",
> > sectcount => "$sectcount",
> > mount => "$mount"
>
> perldoc -q quoting
>
> Found in /usr/lib/perl5/5.8.6/pod/perlfaq4.pod
>  What's wrong with always quoting "$vars"?

Read ... I don't quite get it, but I understood enough to realize that
I needed to unquote them or potentially suffer difficult to trace
errors later on. Done.


> This appears to do what you want (although there may be a module that does
> this better):
>
>  my @sec_range;
>  for my $sectors ( map [ @{ $_ }{ 'fsector', 'lsector' } ],
>  sort { $a->{ fsector } <=> $b->{ fsector } }
>  values %$slices ) {
>
>  if ( @sec_range && $sec_range[ -1 ][ 1 ] == $sectors->[ 0 ] - 1 ) {
>  $sec_range[ -1 ][ 1 ] = $sectors->[ 1 ];
>  }
>  else {
>  push @sec_range, $sectors;
>  }
>  }
>
>  print "Available sectors:\n";
>  print "\t0 - ", $sec_range[0][0]-1, "\n" if $sec_range[0][0];
>  print "\t", $sec_range[$_-1][1]+1, ' - ', $sec_range[$_][0]-1, "\n"
>  for 1 .. $#sec_range;


This does indeed do the right thing on the sample data. I'm working
through it slowly, and I kinda get it. I gotta admit, I'm lost in the
crypticism, but it looks like it  throws the firstsectors and
lastsectors into a hash, sorts the keys and values independantly, then
compares ?

I'm trying it on a second drive however, and am getting results that
don't look right ...

That drive has the following partitions defined:

*  First  Sector  Last
* Partition  Tag  FlagsSector   Count   Sector   Mount Directory
  0200 1048707 68030172  69078878   /
  1301  0   1048707   1048706
  2500  0   71127180  71127179
  7800  69078879   2048301  71127179/export/home


I would expect the script to return no 

Re: Parsing HTML

2005-09-01 Thread Scott Taylor

Jenda Krynicky said:
> From: "Scott Taylor" <[EMAIL PROTECTED]>
>> I'm probably reinventing the wheel here, but I tried to get along with
>> HTML::Parser and just couldn't get it to do anything.  To confusing, I
>> think.
>>
>> I simply want to get a list or real words from an HTML string, minus
>> all the HTML stuff.  For example:
>>
>> 
>
> use HTML::JFilter qw(StripHTML);
>  # http://www24.brinkster.com/jenda/#HTML::JFilter
>
> $plain_text = StripHTML($text_with_html);

Oops, sorry, there it is, just really slow. :)


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




Re: Parsing HTML

2005-09-01 Thread Scott Taylor

Jenda Krynicky said:
> From: "Scott Taylor" <[EMAIL PROTECTED]>
>> I'm probably reinventing the wheel here, but I tried to get along with
>> HTML::Parser and just couldn't get it to do anything.  To confusing, I
>> think.
>>
>> I simply want to get a list or real words from an HTML string, minus
>> all the HTML stuff.  For example:
>>
>> 
>
> use HTML::JFilter qw(StripHTML);
>  # http://www24.brinkster.com/jenda/#HTML::JFilter
>
> $plain_text = StripHTML($text_with_html);

Nice thought, but the link leads nowhere.  Cute comic though.

Thanks.

--
Scott

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




Re: tricky list comparison problem

2005-09-01 Thread John W. Krahn
Jason Ross wrote:
> Hello.

Hello,

> I'm having a bit of an issue with a script I'm working on. The goal is
> to parse the output of the solaris `prtvtoc` command and do some things
> based on it. I've got that part down, and am placing the bits I care
> about into a hash which is best written (I think ... ) as :
> 
> $partition-> {$property} = value
> 
> You can see what I mean in the code below...
> 
> Anyway, the issue I have is that I need to determine where there are
> gaps between the first sector and last sector (on the entire disk, not
> on a given partition).

How do you determine which partitions to skip and which not to skip?


> So, for example, using the sample data below, I want to return "2097415
> - 69078878" as available sectors.
> 
> I think to do that I need to iterate through all the last sectors and
> find out if ($current_lastsector + 1) is not present in the list of
> first sectors 
> 
> I'm not sure what the 'best' way to do that is given the structure of
> the hash (it having the $partition top level is throwing me off) ... and
> 
> I'm not convinced putting the startsectors and endsectors into 2 arrays
> and comparing via that method is a good way to do it (and even if it is,
> I'm not sure how to do that either ... )
> 
> Any thoughts on the 'best' way to do this ?
> 
> (Sample data and script are below, any other "optimizations" folks feel
> like chiming in with are welcome also ;-)
> 
> 
> Sample data
> 
> [snip]
> 
> Sample script
> --
> #!/usr/bin/perl

You should start your Perl programs with these two lines:

use warnings;
use strict;


> use strict();

You are telling perl to load the 'strict' module and then you are telling the
'strict' module not to do anything (with the empty parentheses.)  Why use the
module if you don't want it to do anything?


> sub get_vtoc($) {

You really, really, *REALLY* shouldn't use "prototypes".  If you want to check
the arguments passed to your subroutine you should do something like this:

@_ == 1 or die "Wrong number of arguments passed to get_vtoc().\n";


"Far More Than Everything You've Ever Wanted to Know about Prototypes in Perl"
http://library.n0i.net/programming/perl/articles/fm_prototypes/


>my $disk = shift;
>my %slices;
> 
>open(IN, "< $disk") or die("$!\n");
>   while() {
>  # make all tabs and spaces a single space
>  $_ =~ s/\s+/ /g;
>  # strip all leading spaces
>  $_ =~ s/^\s+//g;

You don't really need those two substitutions if you use split() correctly
later on.


>  # if this is the bytes/sector line, split it
>  # and store the bytes per sector as $BPS
>  if($_ =~ /bytes\/sector/) {
> our (undef, $BPS, undef) = split(/\s/, $_, 3);

our() is lexically scoped just like my() and the only reason that this
actually works is because strict is turned off and $BPS is a package variable.
 To make this work correctly with strict you have to declare $BPS outside of
the while loop.

If you use split correctly that could be written as:

   $BPS = ( split )[ 1 ];

Then you wouldn't need the substitutions at the beginning of the loop.

However *I* would write it like this:

   if ( /(\d+)\s+bytes\/sector/ ) {
   $BPS = $1;
   }


>  }
> 
>  # skip the the line if it starts with an * or is partition 2
>  next if(/^[\*|2]/);

Your comment is incorrect, it should read "if it starts with an * or a | or is
partition 2".  Regular expression meta-characters are not special in a
character class so you probably meant /^[*2]/.


>  # split the line into its componant parts
>  my($part, $tag, $flag, $fsector,
> $sectcount, $lsector, $mount) = split(/\s/, $_);

If you use split() with NO arguments then you won't need the two substitutions
at the beginning of the loop.  If you really want to include the arguments
then use ' ' instead of /\s/ as the first argument.


>  # put the pieces into the slices hash
>  $slices{$part} = {
> bps => "$BPS",
> tag => "$tag",
> flag => "$flag",
> part => "$part",
> fsector => "$fsector",
> lsector => "$lsector",
> sectcount => "$sectcount",
> mount => "$mount"

perldoc -q quoting

Found in /usr/lib/perl5/5.8.6/pod/perlfaq4.pod
   What’s wrong with always quoting "$vars"?


>  };
>   }
>close(IN);
>return \%slices;
> }

To summarize:

sub get_vtoc {
my $disk = shift;
my %slices;
my $BPS;

open my $IN, '<', $disk or die "$disk: $!\n";
while ( <$IN> ) {
# if this is the bytes/sector line, split it
# and store the bytes per sector as $BPS
if ( /(\d+)\s+bytes\/sector/ ) {
$BPS = $1;
}

# skip the the line if it starts with an * or is partition 2
next if /

RE: Need help... packages

2005-09-01 Thread Charles K. Clarkson
Luinrandir  wrote:
: OK.. maybe I'm trying to be too fancy.
:
: the package is:
: ###
: package Names;
: @Countries("Ireland","Wales");
: %Lord{Ireland}=("Bob","Tom");
: %Lord{Wales}=("Ted","Ned");
:
: return 1;
: #
: the program is:
: ###
: foreach $Country(@Names::Countries)
: {
: print qq|$Names::$Lord{$Country}|;
: }
: ###
:
: I have tried several variation on this.. can't get it to work.
: I need it to print the array of Ireland and then Wales.

And later:

: my alternative is this, in the program:
:
:@[EMAIL PROTECTED]::Countries;

I assume that should be Names and not NamesList.


package Names;

%Lords = (
Wales   => [ qw( Ted Ned ) ],
Ireland => [ qw( Bob Tom ) ],
);


use Names;

{
# Use a shorter name to access %Names::Lord
my $lords = \%Names::Lords;

foreach my $Country ( qw( Wales Ireland ) ) {

print "@{ $lords->{ $Country } }\n"
if exists $lords->{ $Country };
}
}

__END__


If you don't know the country names ahead of time
you can use the keys from %Names::Lord. @Names::Countries
array is not necessary.

use Names;

{
# Use a shorter name to access %Names::Lord
my $lords = \%Names::Lords;

foreach my $country ( keys %$lords ) {

print "@{ $lords->{ $country } }\n";
}
}


HTH,

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


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




utf8::upgrade,utf8::encode and utf8::is_utf8 on EBCDIC platform

2005-09-01 Thread mohammad yaseen
Hi,

 This are the tetstcase i'm runing on EBCDIC platform,

my $b = chr(0x0FF);
$p=utf8::upgrade($b);
print "\n$p";

utf8::upgarde returns the number of octets necessary
to represent the string as UTF-X.

EBCDIC output is 1 whereas ASCII platform output is 2.
Is the return value i'm getting on EBCDIC is correct?


my $c=chr(0x0FF);
print "before $c\n";
print "\n";
utf8::encode($c);
print "after $c\n";
print length($c);

On ASCII before is single octet repsentation and after
encode is two byte , length is 2.

On EBCDIC it is single before and after encode and
length is 1.

Is this correct on EBCDIC or is it a bug in code for
EBCDIC ?

utf::is_utf8 test whether STRING is in UTF-8, so 0x0FF
is UTF-8 on EBCDIC?





__ 
Do you Yahoo!? 
Yahoo! Mail - Helps protect you from nasty viruses. 
http://promotions.yahoo.com/new_mail

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




Re: Need help... packages

2005-09-01 Thread John W. Krahn
Luinrandir wrote:
> OK.. maybe I'm trying to be too fancy.
> 
> the package is:
> ###
> package Names;
> @Countries("Ireland","Wales");

The '@' sigil can only be in front of an array or a slice.  You probably meant:

@Countries = ( "Ireland", "Wales" );


> %Lord{Ireland}=("Bob","Tom");
> %Lord{Wales}=("Ted","Ned");

The '%' sigil can only be in front of a hash.  You probably meant:

$Lord{ Ireland } = [ "Bob", "Tom" ];
$Lord{ Wales }   = [ "Ted", "Ned" ];

Or:

%Lord = (
Ireland => [ "Bob", "Tom" ],
Wales   => [ "Ted", "Ned" ],
);


> return 1;

You can only return fron a subroutine.  You probably meant:

1;


> #
> the program is:
> ###
> foreach $Country(@Names::Countries)
> {
> print qq|$Names::$Lord{$Country}|;
 ^^^
Another syntax error.  And you don't need to quote scalars.

print $Names::Lord{ $Country };


> }
> ###

perldoc perl

[snip]

   perlsyn Perl syntax
   perldataPerl data structures

   perldsc Perl data structures intro
   perllol Perl data structures: arrays of arrays

   perlmod Perl modules: how they work
   perlmodlib  Perl modules: how to write and use
   perlmodstylePerl modules: how to write modules with style



John
-- 
use Perl;
program
fulfillment

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