I suggest you read perlfunc:split as well as the File::Basename documentation, and for gods sake, Use strict warnings and diagnostics or die. As you can see from the above code (which you should run), the reason print "$title[1]\n"; doesn't print anything is because @title is empty, its as simple as that. If you had warnings turned on you would've been warned, so please always use warnings and strict , they'll save you a lot of grief (and use diagnostics if you're not accustomed to using warnings and strict).#!/usr/bin/perl -w use strict; local $^W=1; use Data::Dumper; my $file ="test.html"; my @title = split (".", $file); print "$file\n"; print "$title[0]\n"; print "$title[1]\n"; print "$title[2]\n"; warn Dumper(\@title); @title = split (/\./, $file); print "$file\n"; print "$title[1]\n"; warn Dumper(\@title); use File::Basename; ## remember, suffix's are regex patterns my ($name,$path,$suffix) = fileparse($file,"\Q.html\E"); print "path $path\n"; print "name $name\n"; print "sufx $suffix\n";
____________________________________________________
** The Third rule of perl club is a statement of fact: pod is sexy.
In reply to Re: Re: print statement problem
by PodMaster
in thread print statement problem
by cal
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |