> -----Original Message-----
> From: lorid

> Im  want to set the $photo_year and $photo_month to another 
> value if it 
> is not already set.
> 
> my $ARGV[0]  will sometimes be passed a string like 
> this:nvIGRA with no 
> date at end and sometimes with date nvIGRA200511
> if it does not have date I need to set it another way but cant get 
> syntax of !defined
> 

this will work:

my $filename = $ARGV[0];
if ( $filename =~ /nvIGRA(\d{4})(\d{2})/ ) {
        my $photo_year=$1;
        my $photo_month=$2;
}
$photo_year=2005 unless defined $photo_year;
$photo_month=7 unless defined $photo_month;
if ($photo_month<10) {
        $photo_month="0".$photo_month;
}


note:  if you can have other strings other than "nvIGRA" change that
part into a regular expression.




> 
> 
> my $filename = $ARGV[0];
> my $photo_year;
> $photo_year= substr($filename,6,4);
> my $photo_month ;
> $photo_month= substr($filename,10,2);
> #This just blows my web page
> if(!defined $photo_year){
>   $photo_year ="2005";
> }
> 
> 
> #I have also tried
> if(defined $qphoto_year){
>    #test
>    $test1 ="Im defined";
>  }
>  else{
>     $test2 ="Im Not defined";
>     print "$test2";
>    }
> 
> How come It always returns Im defined ,even when no date is 
> passed should I do some kind of checking on my $ARGV[0] 
> before doing the 
> asignment $photo_year= substr($filename,6,4);
> 
> 
> help appreciated
> 
> thanks
> lori
> _______________________________________________
> Perl-Win32-Users mailing list 
> Perl-Win32-Users@listserv.ActiveState.com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> 

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to