Re: Concatenation Question
From: Matt Garrish (matthew.garrish_at_sympatico.ca)
Date: 12/13/03
- Next message: Malcolm Dew-Jones: "Re: @ISA specific to instance rather than class?"
- Previous message: Sam Holden: "Re: Concatenation Question"
- In reply to: Chip: "Concatenation Question"
- Next in thread: Chip: "Re: Concatenation Question"
- Reply: Chip: "Re: Concatenation Question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 12 Dec 2003 22:50:17 -0500
"Chip" <ccarpenter@erols.com> wrote in message
news:jLvCb.456$xH2.307902@news1.news.adelphia.net...
> How can I add a ".jpg" extension to a string?
>
> I'm trying the following with 12345 as the input.
>
> #!/usr/bin/perl -w
> print "Please enter the item picture number to remove: ";
> my $number=<STDIN>;
> my $path=http://someplace.com/images/;
> my $ext=".jpg";
> my $picture="$path . $number . $ext";
> system rm $picture;
> print "$picture has been removed";
> __END__
>
> The output I'm hoping for is:
> http://someplace.com/images/12345.jpg has been removed
>
> What I get is:
> http://someplace.com/images/12345 has been removed
>
You couldn't possibly be getting that output based on the code above. For
one, it would never run because your $path variable is not quoted. Second,
when you read from STDIN, you also get the carriage return (\n). Third,
your extension is statically defined, so it must appear somewhere in your
output. And finally, you're not concatenating your string when you put it in
double quotes. Fixing your above code to run produces the following result:
http://someplace.com/images/ . 12345
. .jpg has been removed
If you post your real code, someone might be able to help you.
Matt
- Next message: Malcolm Dew-Jones: "Re: @ISA specific to instance rather than class?"
- Previous message: Sam Holden: "Re: Concatenation Question"
- In reply to: Chip: "Concatenation Question"
- Next in thread: Chip: "Re: Concatenation Question"
- Reply: Chip: "Re: Concatenation Question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|